From c957dbf74e6a76415cd4a4e614d81db224362e29 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 30 Jul 2024 17:32:21 +0200 Subject: [PATCH 01/12] Use `nodejs_latest` --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 974d435..5e85a36 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ }; in { devShell = pkgs.mkShell { - nativeBuildInputs = with pkgs; [ nodejs ]; + nativeBuildInputs = with pkgs; [ nodejs_latest ]; }; } ); -- 2.45.2 From 62b1fd98b7d9550640f52068a3495eb6c140b7d7 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 30 Jul 2024 17:32:59 +0200 Subject: [PATCH 02/12] Add `svelte-autocomplete` dependency --- package-lock.json | 7 +++++++ package.json | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index bca1001..4165efa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "prettier": "^3.1.1", "prettier-plugin-svelte": "^3.1.2", "sass": "^1.77.5", + "simple-svelte-autocomplete": "^2.5.2", "svelte": "^4.2.7", "svelte-check": "^3.6.0", "tslib": "^2.4.1", @@ -3945,6 +3946,12 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/simple-svelte-autocomplete": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/simple-svelte-autocomplete/-/simple-svelte-autocomplete-2.5.2.tgz", + "integrity": "sha512-6+kZP3XQGb7zs0djTWoFv8tQorBZdv64YfCKrlsYIYBCFsEeikSiNsBSSYw1Om+LYmFeMEOAYSSKoEw+qpnBXQ==", + "dev": true + }, "node_modules/sirv": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz", diff --git a/package.json b/package.json index 253175b..4749b39 100644 --- a/package.json +++ b/package.json @@ -19,21 +19,22 @@ "@sveltejs/vite-plugin-svelte": "^3.0.0", "@types/eslint": "^9.0.0", "@types/node": "^20.14.11", + "bulma": "^1.0.1", "eslint": "^9.0.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-svelte": "^2.36.0", "globals": "^15.0.0", "prettier": "^3.1.1", "prettier-plugin-svelte": "^3.1.2", + "sass": "^1.77.5", + "simple-svelte-autocomplete": "^2.5.2", "svelte": "^4.2.7", "svelte-check": "^3.6.0", "tslib": "^2.4.1", "typescript": "^5.0.0", "typescript-eslint": "^8.0.0-alpha.20", "vite": "^5.0.3", - "vitest": "^2.0.0", - "bulma": "^1.0.1", - "sass": "^1.77.5" + "vitest": "^2.0.0" }, "type": "module", "engines": { -- 2.45.2 From fc0de8b7e0760e6d4f936dee62f9678608935c6e Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 30 Jul 2024 17:33:21 +0200 Subject: [PATCH 03/12] Sort names before returning --- src/routes/names/+server.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/routes/names/+server.ts b/src/routes/names/+server.ts index c69f717..e77a5f6 100644 --- a/src/routes/names/+server.ts +++ b/src/routes/names/+server.ts @@ -6,6 +6,7 @@ export function GET() { const names = readdirSync(storagePath).filter((f) => statSync(`${storagePath}/${f}`).isDirectory() ); + names.sort() return json(names); } -- 2.45.2 From 4b6f25656b19a665281967419c07c1b0d17a6141 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 30 Jul 2024 17:34:56 +0200 Subject: [PATCH 04/12] Use autocompletion input for names --- src/routes/+page.svelte | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 7e39ba2..a270820 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,8 +1,12 @@
-
{#if form?.field === 'name'} @@ -69,10 +79,10 @@ Fotos auswählen... - {#if files} - {files.length} Bild{#if files.length > 1}er{/if} ausgewählt ({fileSize(files)}) + {#if files && files?.length !== 0} + + {files.length} Bild{#if files.length > 1}er{/if} ausgewählt ({fileSize(files)}) + {:else} Keine Bilder ausgewählt {/if} -- 2.45.2 From 2dbd724622b8480357453c35573101b41877b035 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 30 Jul 2024 17:39:41 +0200 Subject: [PATCH 05/12] Formatting --- src/routes/+page.svelte | 22 +++++++++++----------- src/routes/names/+server.ts | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index a270820..435c22b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -4,7 +4,7 @@ import AutoComplete from 'simple-svelte-autocomplete'; export let form: ActionData; - + let selectedName: String; let toCreate = ''; @@ -25,9 +25,9 @@ .map(([k, v]) => `${(size / k).toFixed(1)} ${v}B`)[0] ?? `${size} bytes` ); }; - + async function loadNames(keyword: String) { - const url = "./names"; + const url = './names'; const response = await fetch(url); return await response.json(); } @@ -54,14 +54,14 @@
-
{#if form?.field === 'name'} diff --git a/src/routes/names/+server.ts b/src/routes/names/+server.ts index e77a5f6..c0adecf 100644 --- a/src/routes/names/+server.ts +++ b/src/routes/names/+server.ts @@ -6,7 +6,7 @@ export function GET() { const names = readdirSync(storagePath).filter((f) => statSync(`${storagePath}/${f}`).isDirectory() ); - names.sort() + names.sort(); return json(names); } -- 2.45.2 From 6061e9bbdfb8ae0fdbf06ea91feae24024c29641 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 30 Jul 2024 17:40:35 +0200 Subject: [PATCH 06/12] Fix lints --- src/routes/+page.svelte | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 435c22b..b4e34a8 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -5,8 +5,7 @@ export let form: ActionData; - let selectedName: String; - let toCreate = ''; + let selectedName: string; let files: FileList; let sending = false; @@ -26,7 +25,7 @@ ); }; - async function loadNames(keyword: String) { + async function loadNames() { const url = './names'; const response = await fetch(url); return await response.json(); -- 2.45.2 From a48f6cc739529bb795e67da0c0ff0516edc3684c Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Tue, 30 Jul 2024 17:45:19 +0200 Subject: [PATCH 07/12] Ignore missing type declaration --- src/routes/+page.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index b4e34a8..7f1d4ef 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,6 +1,7 @@