diff --git a/frontend/package.json b/frontend/package.json index 0e0242e..972df35 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite", + "dev": "vite --host", "build": "vite build", "preview": "vite preview", "check": "svelte-check --tsconfig ./tsconfig.json" diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 669f3cf..59a9c8c 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -8,8 +8,8 @@ let info: Info; let alarms: Alarm[]; - onMount(async () => { - Promise.all([ + function fetchdata() { + return Promise.all([ fetch("/api/info") .then((r) => r.json()) .then((data) => { @@ -21,6 +21,10 @@ alarms = data; }), ]); + } + + onMount(async () => { + await fetchdata(); }); @@ -33,7 +37,9 @@ {#if alarms} {#each alarms as alarm}
- + { + fetchdata(); + }} />
{/each} {/if} diff --git a/frontend/src/lib/AddAlarm.svelte b/frontend/src/lib/AddAlarm.svelte index 6339c44..aaebe8c 100644 --- a/frontend/src/lib/AddAlarm.svelte +++ b/frontend/src/lib/AddAlarm.svelte @@ -11,7 +11,8 @@
-
+ +
{#if closed} {:else} -
+
{ closed = true; @@ -28,7 +29,8 @@ > { closed = true; }} diff --git a/frontend/src/lib/Alarm.svelte b/frontend/src/lib/Alarm.svelte index bf1d875..64a914d 100644 --- a/frontend/src/lib/Alarm.svelte +++ b/frontend/src/lib/Alarm.svelte @@ -3,21 +3,45 @@ import MdRemoveCircle from 'svelte-icons/md/MdRemoveCircle.svelte' //@ts-ignore import MdAlarmOff from 'svelte-icons/md/MdAlarmOff.svelte' - import type { Alarm } from "../types"; + import { createEventDispatcher } from 'svelte'; export let alarm: Alarm; + + const dispatch = createEventDispatcher();
{alarm.time}
- - - + + + {#if alarm.disabled} +
Disabled
+ {/if} +
+
- - \ No newline at end of file diff --git a/frontend/src/lib/Info.svelte b/frontend/src/lib/Info.svelte index 04a1d1c..8e2cdd4 100644 --- a/frontend/src/lib/Info.svelte +++ b/frontend/src/lib/Info.svelte @@ -7,7 +7,6 @@ export let info: Info; - let duration = Duration.parse(info.nextAlarmIn); let localUTOffset = new Date().getTimezoneOffset() * -1 / 60; let serverTime = new ServerClock(info.serverTime) @@ -28,7 +27,9 @@

Local time not in sync with server

{/if }
+ {#if info.nextAlarmIn}
-
in {duration.sprintf("%hh %mm")} +
in {Duration.parse(info.nextAlarmIn).sprintf("%hh %mm")}
+ {/if}
diff --git a/frontend/src/types.ts b/frontend/src/types.ts index 9077f7a..1f916ff 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -1,8 +1,8 @@ export interface Info { alarms: number deviceId: string - nextAlarmAt: string - nextAlarmIn: string + nextAlarmAt?: string + nextAlarmIn?: string serverTime: string spotifyUser: string timezone: string @@ -13,4 +13,5 @@ export interface Info { export interface Alarm { name: string time: string + disabled: boolean }