From a640703f2da8815dc26ad1600a6f206be1624379 Mon Sep 17 00:00:00 2001
From: ivarlovlie <git@ivarlovlie.no>
Date: Wed, 1 Jun 2022 22:10:32 +0200
Subject: feat: Initial after clean slate

---
 apps/projects-web/src/app/index.svelte | 56 ++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 apps/projects-web/src/app/index.svelte

(limited to 'apps/projects-web/src/app/index.svelte')

diff --git a/apps/projects-web/src/app/index.svelte b/apps/projects-web/src/app/index.svelte
new file mode 100644
index 0000000..9dd2bf8
--- /dev/null
+++ b/apps/projects-web/src/app/index.svelte
@@ -0,0 +1,56 @@
+<svelte:options immutable={true}/>
+<svelte:window bind:online={online}/>
+
+<script>
+	import {logout_user} from "$app/lib/services/user-service";
+	import Router from "svelte-spa-router";
+	import {wrap} from "svelte-spa-router/wrap";
+	import {is_active} from "$shared/lib/session";
+	import UiWorkbench from "$app/pages/ui-workbench.svelte";
+	import NotFound from "$app/pages/not-found.svelte";
+	import Home from "$app/pages/home.svelte";
+	import Settings from "$app/pages/settings.svelte";
+	import Data from "$app/pages/data.svelte";
+	import PreHeader from "$shared/components/pre-header.svelte";
+
+	let online = true;
+
+	async function user_is_logged_in() {
+		if (!await is_active()) {
+			await logout_user("expired");
+		}
+		return true;
+	}
+
+	const routes = {
+		"/home": wrap({
+			component: Home,
+			conditions: [user_is_logged_in],
+		}),
+		"/": wrap({
+			component: Home,
+			conditions: [user_is_logged_in],
+		}),
+		"/settings": wrap({
+			component: Settings,
+			conditions: [user_is_logged_in],
+		}),
+		"/data": wrap({
+			component: Data,
+			conditions: [user_is_logged_in],
+		}),
+		"/ui-workbench": UiWorkbench,
+		"*": NotFound,
+	};
+</script>
+<PreHeader show="{!online}">You seem to be offline, please check your internet connection.</PreHeader>
+<Router
+        {routes}
+        restoreScrollState={true}
+        on:routeLoading={() => {
+            document.getElementById("loader").style.display = "inline-block";
+        }}
+        on:routeLoaded={() => {
+            document.getElementById("loader").style.display = "none";
+        }}
+/>
-- 
cgit v1.3

