From f538c9a1be0258176b156443c731507e90ed0ee3 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sat, 3 Feb 2024 15:00:16 -0800 Subject: [PATCH] feat: display doc tags --- src/routes/(app)/documents/+page.svelte | 90 +++++++++++++++++-------- 1 file changed, 61 insertions(+), 29 deletions(-) diff --git a/src/routes/(app)/documents/+page.svelte b/src/routes/(app)/documents/+page.svelte index dbba88513..898c5f5f0 100644 --- a/src/routes/(app)/documents/+page.svelte +++ b/src/routes/(app)/documents/+page.svelte @@ -18,6 +18,8 @@ let inputFiles = ''; let query = ''; + let tags = []; + let showEditDocModal = false; let selectedDoc; @@ -50,6 +52,11 @@ }; onMount(() => { + documents.subscribe((docs) => { + tags = docs.reduce((a, e, i, arr) => { + return [...new Set([...a, ...(e?.content?.tags ?? []).map((tag) => tag.name)])]; + }, []); + }); const dropZone = document.querySelector('body'); const onDragOver = (e) => { @@ -141,6 +148,34 @@ {/key} + { + if (inputFiles && inputFiles.length > 0) { + const file = inputFiles[0]; + if ( + SUPPORTED_FILE_TYPE.includes(file['type']) || + SUPPORTED_FILE_EXTENSIONS.includes(file.name.split('.').at(-1)) + ) { + uploadDoc(file); + } else { + toast.error( + `Unknown File Type '${file['type']}', but accepting and treating as plain text` + ); + uploadDoc(file); + } + + inputFiles = null; + e.target.value = ''; + } else { + toast.error(`File not found.`); + } + }} +/> +
@@ -191,34 +226,32 @@
+
- { - if (inputFiles && inputFiles.length > 0) { - const file = inputFiles[0]; - if ( - SUPPORTED_FILE_TYPE.includes(file['type']) || - SUPPORTED_FILE_EXTENSIONS.includes(file.name.split('.').at(-1)) - ) { - uploadDoc(file); - } else { - toast.error( - `Unknown File Type '${file['type']}', but accepting and treating as plain text` - ); - uploadDoc(file); - } - - inputFiles = null; - e.target.value = ''; - } else { - toast.error(`File not found.`); - } - }} - /> + {#if tags.length > 0} +
+ + {#each tags as tag} + + {/each} +
+ {/if} {#each $documents.filter((p) => query === '' || p.name.includes(query)) as doc} -
-
+