From ced66c5807575cd29f6aa5632e8ad02b38c8448a Mon Sep 17 00:00:00 2001 From: ivar Date: Sun, 28 Apr 2024 22:37:30 +0200 Subject: WIP new frontend --- .../src/routes/(main)/(public)/+layout.svelte | 18 +++ .../src/routes/(main)/(public)/portal/+page.svelte | 26 ++++ .../src/routes/(main)/(public)/portal/+page.ts | 9 ++ .../(main)/(public)/reset-password/+page.svelte | 81 +++++++++++ .../routes/(main)/(public)/reset-password/+page.ts | 11 ++ .../(public)/reset-password/[id]/+page.server.ts | 11 ++ .../(public)/reset-password/[id]/+page.svelte | 82 +++++++++++ .../(main)/(public)/reset-password/[id]/+page.ts | 11 ++ .../routes/(main)/(public)/sign-in/+page.svelte | 155 +++++++++++++++++++++ .../src/routes/(main)/(public)/sign-in/+page.ts | 11 ++ .../routes/(main)/(public)/sign-in/index.spec.js | 12 ++ .../src/routes/(main)/(public)/sign-in/index.ts | 20 +++ .../routes/(main)/(public)/sign-up/+page.svelte | 106 ++++++++++++++ .../src/routes/(main)/(public)/sign-up/+page.ts | 11 ++ 14 files changed, 564 insertions(+) create mode 100644 code/frontend/src/routes/(main)/(public)/+layout.svelte create mode 100644 code/frontend/src/routes/(main)/(public)/portal/+page.svelte create mode 100644 code/frontend/src/routes/(main)/(public)/portal/+page.ts create mode 100644 code/frontend/src/routes/(main)/(public)/reset-password/+page.svelte create mode 100644 code/frontend/src/routes/(main)/(public)/reset-password/+page.ts create mode 100644 code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts create mode 100644 code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.svelte create mode 100644 code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.ts create mode 100644 code/frontend/src/routes/(main)/(public)/sign-in/+page.svelte create mode 100644 code/frontend/src/routes/(main)/(public)/sign-in/+page.ts create mode 100644 code/frontend/src/routes/(main)/(public)/sign-in/index.spec.js create mode 100644 code/frontend/src/routes/(main)/(public)/sign-in/index.ts create mode 100644 code/frontend/src/routes/(main)/(public)/sign-up/+page.svelte create mode 100644 code/frontend/src/routes/(main)/(public)/sign-up/+page.ts (limited to 'code/frontend/src/routes/(main)/(public)') diff --git a/code/frontend/src/routes/(main)/(public)/+layout.svelte b/code/frontend/src/routes/(main)/(public)/+layout.svelte new file mode 100644 index 0000000..6da653c --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/+layout.svelte @@ -0,0 +1,18 @@ + + + + + diff --git a/code/frontend/src/routes/(main)/(public)/portal/+page.svelte b/code/frontend/src/routes/(main)/(public)/portal/+page.svelte new file mode 100644 index 0000000..cc16681 --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/portal/+page.svelte @@ -0,0 +1,26 @@ + + +
+

Warping...

+
diff --git a/code/frontend/src/routes/(main)/(public)/portal/+page.ts b/code/frontend/src/routes/(main)/(public)/portal/+page.ts new file mode 100644 index 0000000..72338cb --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/portal/+page.ts @@ -0,0 +1,9 @@ +import type { PortalMessage } from '$configuration'; +import { redirect } from '@sveltejs/kit'; +import type { PageLoad } from './$types'; + +export const load: PageLoad = async ({ url }) => { + const message = url.searchParams.get("msg") as PortalMessage; + if (!message) throw redirect(302, "/"); + return { message }; +}; \ No newline at end of file diff --git a/code/frontend/src/routes/(main)/(public)/reset-password/+page.svelte b/code/frontend/src/routes/(main)/(public)/reset-password/+page.svelte new file mode 100644 index 0000000..a45ccdd --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/reset-password/+page.svelte @@ -0,0 +1,81 @@ + + +
+
+

+ {$LL.resetPasswordPage.requestAPasswordReset()} +

+

+ {$LL.or().toLowerCase()} + + {$LL.signIntoYourAccount().toLowerCase()} + +

+
+ +
+
+
+ {#if showErrorAlert} + + {:else if showSuccessAlert} + + {/if} + +
+
+
diff --git a/code/frontend/src/routes/(main)/(public)/reset-password/+page.ts b/code/frontend/src/routes/(main)/(public)/reset-password/+page.ts new file mode 100644 index 0000000..c0859e0 --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/reset-password/+page.ts @@ -0,0 +1,11 @@ +import LL from '$i18n/i18n-svelte'; +import { get } from 'svelte/store'; +import type { PageLoad } from './$types'; + +const l = get(LL); + +export const load: PageLoad = async () => { + return { + title: l.resetPasswordPage.title(), + }; +}; \ No newline at end of file diff --git a/code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts b/code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts new file mode 100644 index 0000000..9e24736 --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.server.ts @@ -0,0 +1,11 @@ +import { is_guid } from "$utils/validators"; +import { redirect } from "@sveltejs/kit"; +import type { PageServerLoad } from "./$types"; + +export const load: PageServerLoad = async ({ params }) => { + const resetRequestId = params.id ?? ""; + if (!is_guid(resetRequestId)) throw redirect(302, "/reset-password"); + return { + resetRequestId, + }; +}; \ No newline at end of file diff --git a/code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.svelte b/code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.svelte new file mode 100644 index 0000000..27a1af5 --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.svelte @@ -0,0 +1,82 @@ + + +
+ {#if finishedPreliminaryLoading} +
+

+ {$LL.resetPasswordPage.setANewPassword()} +

+

+ {$LL.or().toLowerCase()} + + {$LL.signIntoYourAccount().toLowerCase()} + +

+
+ +
+
+
+ {#if requestIsInvalid} + + {/if} + +
+
+ {:else} +

Checking your request...

+ {/if} +
diff --git a/code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.ts b/code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.ts new file mode 100644 index 0000000..3252b7a --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/reset-password/[id]/+page.ts @@ -0,0 +1,11 @@ +import LL from '$i18n/i18n-svelte'; +import { get } from 'svelte/store'; +import type { PageLoad } from './$types'; + +const l = get(LL); + +export const load: PageLoad = async () => { + return { + title: l.resetPasswordPage.fulfillTitle(), + }; +}; \ No newline at end of file diff --git a/code/frontend/src/routes/(main)/(public)/sign-in/+page.svelte b/code/frontend/src/routes/(main)/(public)/sign-in/+page.svelte new file mode 100644 index 0000000..66d4575 --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/sign-in/+page.svelte @@ -0,0 +1,155 @@ + + +
+ {#if messageType} +
+ {#if messageType === "after-password-reset"} + + {:else if messageType === "user-disabled"} + + {:else if messageType === "user-inactivity"} + + {/if} +
+ {/if} +
+

+ {$LL.signInPage.signIn()} +

+

+ {$LL.or().toLowerCase()} + + {$LL.createANewAccount().toLowerCase()} + +

+
+
+
+ {#if form.showError} + + {/if} +
form.submit_async()}> + + + + + + +
+
+
diff --git a/code/frontend/src/routes/(main)/(public)/sign-in/+page.ts b/code/frontend/src/routes/(main)/(public)/sign-in/+page.ts new file mode 100644 index 0000000..bebc459 --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/sign-in/+page.ts @@ -0,0 +1,11 @@ +import LL from '$i18n/i18n-svelte'; +import { get } from 'svelte/store'; +import type { PageLoad } from './$types'; + +const l = get(LL); + +export const load: PageLoad = async () => { + return { + title: l.signInPage.title(), + }; +}; \ No newline at end of file diff --git a/code/frontend/src/routes/(main)/(public)/sign-in/index.spec.js b/code/frontend/src/routes/(main)/(public)/sign-in/index.spec.js new file mode 100644 index 0000000..3bccf72 --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/sign-in/index.spec.js @@ -0,0 +1,12 @@ +import { test, expect } from "@playwright/test"; +import { signInPageTestKeys } from "./index.js"; +import { get_test_context } from "$configuration/test"; +import { get_pw_key_selector } from "$utils/testing-helpers"; + +const context = get_test_context(); + +test("form loads", async ({ page }) => { + page.goto("/sign-in"); + const form = page.locator(get_pw_key_selector(signInPageTestKeys.signInForm)); + expect(form.isVisible()).toBeTruthy(); +}); diff --git a/code/frontend/src/routes/(main)/(public)/sign-in/index.ts b/code/frontend/src/routes/(main)/(public)/sign-in/index.ts new file mode 100644 index 0000000..c1a1929 --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/sign-in/index.ts @@ -0,0 +1,20 @@ +export enum SignInPageMessage { + AFTER_PASSWORD_RESET = "after-password-reset", + USER_INACTIVITY = "user-inactivity", + USER_DISABLED = "user-disabled", + LOGGED_OUT = "logged-out" +} + +export const signInPageMessageQueryKey = "m"; +export const signInPageTestKeys = { + passwordInput: "password-input", + usernameInput: "username-input", + rememberMeCheckbox: "remember-me-checkbox", + signInForm: "sign-in-form", + userInactivityAlert: SignInPageMessage.USER_INACTIVITY + "-alert", + userDisabledAlert: SignInPageMessage.USER_DISABLED + "-alert", + afterPasswordResetAlert: SignInPageMessage.AFTER_PASSWORD_RESET + "-alert", + formErrorAlert: "form-error-alert", + resetPasswordAnchor: "reset-password-anchor", + signUpAnchor: "sign-up-anchor", +}; \ No newline at end of file diff --git a/code/frontend/src/routes/(main)/(public)/sign-up/+page.svelte b/code/frontend/src/routes/(main)/(public)/sign-up/+page.svelte new file mode 100644 index 0000000..470ac5d --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/sign-up/+page.svelte @@ -0,0 +1,106 @@ + + +
+
+

+ {$LL.signUpPage.createYourNewAccount()} +

+

+ {$LL.or().toLowerCase()} + + {$LL.signIntoYourAccount().toLowerCase()} + +

+
+ +
+
+ {#if showErrorAlert} + + {/if} +
+ + + +
+
+
diff --git a/code/frontend/src/routes/(main)/(public)/sign-up/+page.ts b/code/frontend/src/routes/(main)/(public)/sign-up/+page.ts new file mode 100644 index 0000000..8c86f55 --- /dev/null +++ b/code/frontend/src/routes/(main)/(public)/sign-up/+page.ts @@ -0,0 +1,11 @@ +import LL from '$i18n/i18n-svelte'; +import { get } from 'svelte/store'; +import type { PageLoad } from './$types'; + +const l = get(LL); + +export const load: PageLoad = async () => { + return { + title: l.signUpPage.title(), + }; +}; \ No newline at end of file -- cgit v1.3