diff --git a/frontend/src/lib/components/Container.svelte b/frontend/src/lib/components/Container.svelte index 90acd7b..3938150 100644 --- a/frontend/src/lib/components/Container.svelte +++ b/frontend/src/lib/components/Container.svelte @@ -40,7 +40,7 @@ .loading-overlay { position: absolute; top: 0; - left: 25%; + left: 17%; bottom: 0; display: flex; diff --git a/frontend/src/routes/dashboard/+page.svelte b/frontend/src/routes/dashboard/+page.svelte index eb17bd4..81027c8 100644 --- a/frontend/src/routes/dashboard/+page.svelte +++ b/frontend/src/routes/dashboard/+page.svelte @@ -18,12 +18,36 @@ return; } const payload = {}; + notifyMe(); // TODO: adjust URL const resp = await fetch('/api/interpretLaw'); updateFinished = true; }; + const notifyMe = () => { + if (!('Notification' in window)) { + // Check if the browser supports notifications + alert('This browser does not support desktop notification'); + } else if (Notification.permission === 'granted') { + // Check whether notification permissions have already been granted; + // if so, create a notification + const notification = new Notification('Hi there!'); + // … + } else if (Notification.permission !== 'denied') { + // We need to ask the user for permission + Notification.requestPermission().then((permission) => { + // If the user accepts, let's create a notification + if (permission === 'granted') { + const notification = new Notification('Hi there!'); + } + }); + } + + // At last, if the user has denied notifications, and you + // want to be respectful there is no need to bother them anymore. + }; + onMount(() => { updateCompanyData().finally(() => { updateFinished = true;