From 92c922b061045167524b6a86f7e73e5734f1a7f7 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Sun, 25 Feb 2024 21:39:10 -0800 Subject: [PATCH] feat: batch doc tagging --- src/lib/apis/documents/index.ts | 6 +- .../components/documents/AddDocModal.svelte | 188 ++++++++++++++++++ src/routes/(app)/documents/+page.svelte | 41 +--- 3 files changed, 199 insertions(+), 36 deletions(-) create mode 100644 src/lib/components/documents/AddDocModal.svelte diff --git a/src/lib/apis/documents/index.ts b/src/lib/apis/documents/index.ts index 2f7fb2b9..21e0a264 100644 --- a/src/lib/apis/documents/index.ts +++ b/src/lib/apis/documents/index.ts @@ -5,7 +5,8 @@ export const createNewDoc = async ( collection_name: string, filename: string, name: string, - title: string + title: string, + content: object | null = null ) => { let error = null; @@ -20,7 +21,8 @@ export const createNewDoc = async ( collection_name: collection_name, filename: filename, name: name, - title: title + title: title, + ...(content ? { content: JSON.stringify(content) } : {}) }) }) .then(async (res) => { diff --git a/src/lib/components/documents/AddDocModal.svelte b/src/lib/components/documents/AddDocModal.svelte new file mode 100644 index 00000000..bf24f9c6 --- /dev/null +++ b/src/lib/components/documents/AddDocModal.svelte @@ -0,0 +1,188 @@ + + + +
+
+
Add Docs
+ +
+
+ +
+
+
{ + submitHandler(); + }} + > +
+ + + +
+ +
+
+
Tags
+ + +
+
+ +
+ +
+
+
+
+
+
+ + diff --git a/src/routes/(app)/documents/+page.svelte b/src/routes/(app)/documents/+page.svelte index f20d4209..79fe691b 100644 --- a/src/routes/(app)/documents/+page.svelte +++ b/src/routes/(app)/documents/+page.svelte @@ -16,6 +16,7 @@ import EditDocModal from '$lib/components/documents/EditDocModal.svelte'; import AddFilesPlaceholder from '$lib/components/AddFilesPlaceholder.svelte'; import SettingsModal from '$lib/components/documents/SettingsModal.svelte'; + import AddDocModal from '$lib/components/documents/AddDocModal.svelte'; let importFiles = ''; let inputFiles = ''; @@ -24,6 +25,7 @@ let tags = []; let showSettingsModal = false; + let showAddDocModal = false; let showEditDocModal = false; let selectedDoc; let selectedTag = ''; @@ -171,36 +173,7 @@ {/key} - { - if (inputFiles && inputFiles.length > 0) { - for (const file of inputFiles) { - console.log(file, file.name.split('.').at(-1)); - 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.`); - } - }} -/> + @@ -268,7 +241,7 @@ +
add tags
+ -->