From 60a8b1516401bf99091d5a7429ade46430febd39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 4 Apr 2024 20:50:30 +0200 Subject: [PATCH] feat(webui): users can change their passwords --- sdks/js/package.json | 2 +- sdks/js/src/api.ts | 11 ++ webui/src/lib/components/AddModal.svelte | 10 +- webui/src/lib/components/LoginModal.svelte | 67 +++------ webui/src/lib/components/layout/Header.svelte | 34 +---- .../layout/HeaderUserDropdown.svelte | 140 ++++++++++++++++++ webui/src/lib/components/layout/Modal.svelte | 59 ++++++++ 7 files changed, 236 insertions(+), 87 deletions(-) create mode 100644 webui/src/lib/components/layout/HeaderUserDropdown.svelte create mode 100644 webui/src/lib/components/layout/Modal.svelte diff --git a/sdks/js/package.json b/sdks/js/package.json index fd4f560..ed103fe 100644 --- a/sdks/js/package.json +++ b/sdks/js/package.json @@ -1,6 +1,6 @@ { "name": "@upnd/upend", - "version": "0.5.1", + "version": "0.5.2", "description": "Client library to interact with the UpEnd system.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/sdks/js/src/api.ts b/sdks/js/src/api.ts index 83ea2c0..083c355 100644 --- a/sdks/js/src/api.ts +++ b/sdks/js/src/api.ts @@ -434,6 +434,17 @@ export class UpEndApi { } } + public async register(credentials: { + username: string; + password: string; + }): Promise { + await this.fetch(`${this.apiUrl}/auth/register`, undefined, { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(credentials), + }); + } + public async authStatus( options?: ApiFetchOptions, ): Promise<{ user: string } | undefined> { diff --git a/webui/src/lib/components/AddModal.svelte b/webui/src/lib/components/AddModal.svelte index 0469fb6..58754b0 100644 --- a/webui/src/lib/components/AddModal.svelte +++ b/webui/src/lib/components/AddModal.svelte @@ -17,6 +17,7 @@ import { goto } from '$app/navigation'; import { i18n } from '$lib/i18n'; import { selected } from '$lib/components/EntitySelect.svelte'; + import Modal from '$lib/components/layout/Modal.svelte'; let files: File[] = []; let URLs: string[] = []; @@ -114,9 +115,8 @@ - -
-
+{#if visible} +
{#each files as file}
@@ -163,8 +163,8 @@
{/if} -
-
+ +{/if} diff --git a/webui/src/lib/components/layout/Modal.svelte b/webui/src/lib/components/layout/Modal.svelte new file mode 100644 index 0000000..2e05f33 --- /dev/null +++ b/webui/src/lib/components/layout/Modal.svelte @@ -0,0 +1,59 @@ + + + + + + + +