From c8b2ae30c81cef520bc6339dd4d66295c37b0fff Mon Sep 17 00:00:00 2001 From: Mutzi Date: Tue, 24 Oct 2023 12:50:04 +0200 Subject: [PATCH] Implemented routing instead of internal state --- frontend/package-lock.json | 20 +++++++ frontend/package.json | 1 + frontend/src/App.svelte | 62 +++++----------------- frontend/src/components/A.svelte | 8 +++ frontend/src/components/DeleteModal.svelte | 8 +-- frontend/src/components/DirViewer.svelte | 18 ++++--- frontend/src/components/LinkButton.svelte | 2 +- frontend/src/components/UploadModal.svelte | 8 ++- frontend/src/main.ts | 5 +- frontend/src/pages/Admin.svelte | 5 +- frontend/src/pages/Login.svelte | 9 ++-- frontend/src/pages/Profile.svelte | 4 +- frontend/src/pages/ResetPassword.svelte | 9 ++-- frontend/src/pages/Signup.svelte | 7 +-- frontend/src/pages/TfaSetup.svelte | 4 +- frontend/src/pages/View.svelte | 51 ++++++++++-------- frontend/src/routes.ts | 17 ++++++ frontend/src/store.ts | 18 +------ 18 files changed, 135 insertions(+), 121 deletions(-) create mode 100644 frontend/src/components/A.svelte create mode 100644 frontend/src/routes.ts diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 47f4bc8..cf4c1d2 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -11,6 +11,7 @@ "@microsoft/fetch-event-source": "^2.0.1", "filesize": "^10.1.0", "qrcode-svg": "^1.1.0", + "svelte-spa-router": "^3.3.0", "tailwind-merge": "^1.14.0" }, "devDependencies": { @@ -2619,6 +2620,14 @@ "node": ">=8.10.0" } }, + "node_modules/regexparam": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-2.0.1.tgz", + "integrity": "sha512-zRgSaYemnNYxUv+/5SeoHI0eJIgTL/A2pUtXUPLHQxUldagouJ9p+K6IbIZ/JiQuCEv2E2B1O11SjVQy3aMCkw==", + "engines": { + "node": ">=8" + } + }, "node_modules/relateurl": { "version": "0.2.7", "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", @@ -3037,6 +3046,17 @@ "node": ">=12" } }, + "node_modules/svelte-spa-router": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/svelte-spa-router/-/svelte-spa-router-3.3.0.tgz", + "integrity": "sha512-cwRNe7cxD43sCvSfEeaKiNZg3FCizGxeMcf7CPiWRP3jKXjEma3vxyyuDtPOam6nWbVxl9TNM3hlE/i87ZlqcQ==", + "dependencies": { + "regexparam": "2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ItalyPaleAle" + } + }, "node_modules/svg.draggable.js": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/svg.draggable.js/-/svg.draggable.js-2.2.2.tgz", diff --git a/frontend/package.json b/frontend/package.json index b0dee6c..86acc00 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -35,6 +35,7 @@ "@microsoft/fetch-event-source": "^2.0.1", "filesize": "^10.1.0", "qrcode-svg": "^1.1.0", + "svelte-spa-router": "^3.3.0", "tailwind-merge": "^1.14.0" } } diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index e3dc2df..2e1d75b 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -1,37 +1,24 @@
@@ -49,43 +36,22 @@ Working {/if} - + MFileserver + {#if $token != null} -
+
{#if $s?.sudo} Leave sudo {/if} - {#if $s?.admin} Admin {/if} - Files - Profile + {#if $s?.admin} Admin {/if} + Files + Profile Logout
{/if} - {#if $state.s === StateE.LOGIN } - {:else if $state.s === StateE.SIGNUP} - {:else if $state.s === StateE.RESET_PASSWORD} - {:else if $state.s === StateE.PROFILE} - {:else if $state.s === StateE.TFA_SETUP} - {:else if $state.s === StateE.ADMIN} - {:else if $state.s === StateE.VIEW} - {:else} You are in state {$state.s}, which should not be possible, please report this. - {/if} +
- - diff --git a/frontend/src/components/A.svelte b/frontend/src/components/A.svelte new file mode 100644 index 0000000..7be8861 --- /dev/null +++ b/frontend/src/components/A.svelte @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/DeleteModal.svelte b/frontend/src/components/DeleteModal.svelte index 4f4c4e2..a7b7bd3 100644 --- a/frontend/src/components/DeleteModal.svelte +++ b/frontend/src/components/DeleteModal.svelte @@ -1,7 +1,7 @@