{#if dragged}
Drop any files here to add to my documents
{/if} {#key selectedDoc}
{/key}
{$i18n.t('Documents')}
{ showAddDocModal = true; }} >
{#if tags.length > 0}
doc?.selected === 'checked').length === filteredDocs.length ? 'checked' : 'unchecked'} indeterminate={filteredDocs.filter((doc) => doc?.selected === 'checked').length > 0 && filteredDocs.filter((doc) => doc?.selected === 'checked').length !== filteredDocs.length} on:change={(e) => { if (e.detail === 'checked') { filteredDocs = filteredDocs.map((doc) => ({ ...doc, selected: 'checked' })); } else if (e.detail === 'unchecked') { filteredDocs = filteredDocs.map((doc) => ({ ...doc, selected: 'unchecked' })); } }} />
{#if filteredDocs.filter((doc) => doc?.selected === 'checked').length === 0}
{ selectedTag = ''; // await chats.set(await getChatListByTagName(localStorage.token, tag.name)); }} >
{$i18n.t('all')}
{#each tags as tag}
{ selectedTag = tag; // await chats.set(await getChatListByTagName(localStorage.token, tag.name)); }} >
#{tag}
{/each} {:else}
{filteredDocs.filter((doc) => doc?.selected === 'checked').length} Selected
{ deleteDocs(filteredDocs.filter((doc) => doc.selected === 'checked')); // await chats.set(await getChatListByTagName(localStorage.token, tag.name)); }} >
{$i18n.t('delete')}
{/if}
{/if}
{#each filteredDocs as doc}
{ if (doc?.selected === 'checked') { doc.selected = 'unchecked'; } else { doc.selected = 'checked'; } }} >
{#if doc}
{:else}
{/if}
#{doc.name} ({doc.filename})
{doc.title}
{ e.stopPropagation(); showEditDocModal = !showEditDocModal; selectedDoc = doc; }} >
{ e.stopPropagation(); deleteDoc(doc.name); }} >
{/each}
ⓘ {$i18n.t("Use '#' in the prompt input to load and select your documents.")}
{ console.log(importFiles); const reader = new FileReader(); reader.onload = async (event) => { const savedDocs = JSON.parse(event.target.result); console.log(savedDocs); for (const doc of savedDocs) { await createNewDoc( localStorage.token, doc.collection_name, doc.filename, doc.name, doc.title ).catch((error) => { toast.error(error); return null; }); } await documents.set(await getDocs(localStorage.token)); }; reader.readAsText(importFiles[0]); }} />
{ documentsImportInputElement.click(); }} >
{$i18n.t('Import Documents Mapping')}
{ let blob = new Blob([JSON.stringify($documents)], { type: 'application/json' }); saveAs(blob, `documents-mapping-export-${Date.now()}.json`); }} >
{$i18n.t('Export Documents Mapping')}