From: PhiTux Date: Wed, 8 Jan 2025 21:41:00 +0000 (+0100) Subject: added read-page X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=3254881afc713da9a307525fd4ed121f4c81da52;p=DailyTxT.git added read-page --- diff --git a/frontend/src/lib/datepickerLogic.svelte b/frontend/src/lib/DatepickerLogic.svelte similarity index 94% rename from frontend/src/lib/datepickerLogic.svelte rename to frontend/src/lib/DatepickerLogic.svelte index 70b64be..6f2ba34 100644 --- a/frontend/src/lib/datepickerLogic.svelte +++ b/frontend/src/lib/DatepickerLogic.svelte @@ -13,7 +13,6 @@ let lastYear = $cal.currentYear; let isLoadingMarkedDays = false; function loadMarkedDays() { - console.log('a'); if ($cal.currentMonth === lastMonth && $cal.currentYear === lastYear) { return; } @@ -21,7 +20,6 @@ if (isLoadingMarkedDays) { return; } - console.log('b'); isLoadingMarkedDays = true; axios @@ -42,7 +40,6 @@ lastMonth = $cal.currentMonth; lastYear = $cal.currentYear; isLoadingMarkedDays = false; - console.log('c'); }); } diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index 3671ff9..1c89365 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -22,9 +22,13 @@ let inDuration = 150; let outDuration = 150; - /*let API_URL = dev - ? `${window.location.origin.replace(/:5173.*$/gm, '')}:8000` - : window.location.pathname.replace(/\/+$/, '');*/ + $effect(() => { + if ($readingMode) { + goto('/read'); + } else { + goto('/write'); + } + }); function logout() { axios diff --git a/frontend/src/routes/read/+page.js b/frontend/src/routes/read/+page.js new file mode 100644 index 0000000..d48ea95 --- /dev/null +++ b/frontend/src/routes/read/+page.js @@ -0,0 +1,8 @@ +import {redirect} from '@sveltejs/kit' + +export const load = () => { + const user = JSON.parse(localStorage.getItem('user')); + if (!user) { + throw redirect(307, '/login'); + } +} \ No newline at end of file diff --git a/frontend/src/routes/read/+page.svelte b/frontend/src/routes/read/+page.svelte new file mode 100644 index 0000000..5c67822 --- /dev/null +++ b/frontend/src/routes/read/+page.svelte @@ -0,0 +1,82 @@ + + + + + +
+
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
+
+
+
history
+
delete
+
+
+
+
+
+
+
+ + +
diff --git a/frontend/src/routes/write/+page.svelte b/frontend/src/routes/write/+page.svelte index ad7cffa..b52bf38 100644 --- a/frontend/src/routes/write/+page.svelte +++ b/frontend/src/routes/write/+page.svelte @@ -13,7 +13,7 @@ import { readingMode } from '$lib/settingsStore'; //import { read } from '$app/server'; import { API_URL } from '$lib/APIurl.js'; - import DatepickerLogic from '$lib/datepickerLogic.svelte'; + import DatepickerLogic from '$lib/DatepickerLogic.svelte'; /*let API_URL = dev ? `${window.location.origin.replace(/:5173.*$/gm, '')}:8000` @@ -256,32 +256,6 @@ toast.show(); }); } - - //#TODO Muss in die separate /read page (diese hier in /write umbenennen) - let isLoadingMonthForReading = false; - function loadMonthForReading() { - if (isLoadingMonthForReading) { - return; - } - isLoadingMonthForReading = true; - - axios - .get(API_URL + '/logs/loadMonthForReading', { - params: { - month: $cal.currentMonth + 1, - year: $cal.currentYear - } - }) - .then((response) => { - readingData = response.data; - }) - .catch((error) => { - console.error(error); - }) - .finally(() => { - isLoadingMonthForReading = false; - }); - } @@ -307,55 +281,36 @@ - {#if !$readingMode} - -
- -
-
-
- {$selectedDate.toLocaleDateString('locale', { weekday: 'long' })}
- {$selectedDate.toLocaleDateString('locale', { - day: '2-digit', - month: '2-digit', - year: 'numeric' - })} -
-
-
Geschrieben am:
- {logDateWritten} -
-
history
-
delete
+ +
+ +
+
+
+ {$selectedDate.toLocaleDateString('locale', { weekday: 'long' })}
+ {$selectedDate.toLocaleDateString('locale', { + day: '2-digit', + month: '2-digit', + year: 'numeric' + })}
- -
-
-
+
+
Geschrieben am:
+ {logDateWritten}
- {$selectedDate}
- {lastSelectedDate} +
history
+
delete
+
+
+
+
+ {$selectedDate}
+ {lastSelectedDate}
+
- - {:else} -
- {#each readingData as log} -
-
{log.day} | {log.date_written}
-
- {@html log.text} -
-
- {/each} -
- {/if} +