Compare commits

..

No commits in common. "a7eed530a3ca216d63f66d01497f2acbefc8f061" and "19674310e792abe4a7a0b3f1dc75495b2236a86d" have entirely different histories.

6 changed files with 13754 additions and 9015 deletions

View File

@ -10,8 +10,10 @@ export default createOperation.query({
headers: { headers: {
Authorization: process.env.PAPERLESS_TOKEN, Authorization: process.env.PAPERLESS_TOKEN,
}, },
}); });
// Add download link, thumbnail link, preview link, PDF data, and metadata to each document // Add download link, thumbnail link, preview link, PDF data, and metadata to each document
const documentsWithLinksDataAndMetadata = await Promise.all(data.results.map(async doc => { const documentsWithLinksDataAndMetadata = await Promise.all(data.results.map(async doc => {
const response = await axios.get(`https://paperless.andert.me/api/documents/${doc.id}/preview/`, { const response = await axios.get(`https://paperless.andert.me/api/documents/${doc.id}/preview/`, {
@ -23,35 +25,26 @@ export default createOperation.query({
const pdfData = Buffer.from(response.data, 'binary').toString('base64'); const pdfData = Buffer.from(response.data, 'binary').toString('base64');
let correspondent = null; const correspondentResponse = await axios.get(`https://paperless.andert.me/api/correspondents/${doc.correspondent}/`, {
if (doc.correspondent) { headers: {
const correspondentResponse = await axios.get(`https://paperless.andert.me/api/correspondents/${doc.correspondent}/`, { Authorization: process.env.PAPERLESS_TOKEN,
headers: { },
Authorization: process.env.PAPERLESS_TOKEN, });
}, const correspondent = correspondentResponse.data;
});
correspondent = correspondentResponse.data;
}
let tags = []; const tagsResponse = await Promise.all(doc.tags.map(tag => axios.get(`https://paperless.andert.me/api/tags/${tag}/`, {
if (doc.tags) { headers: {
const tagsResponse = await Promise.all(doc.tags.map(tag => axios.get(`https://paperless.andert.me/api/tags/${tag}/`, { Authorization: process.env.PAPERLESS_TOKEN,
headers: { },
Authorization: process.env.PAPERLESS_TOKEN, })));
}, const tags = tagsResponse.map(response => response.data);
})));
tags = tagsResponse.map(response => response.data);
}
let documentType = null; const documentTypeResponse = await axios.get(`https://paperless.andert.me/api/document_types/${doc.document_type}/`, {
if (doc.document_type) { headers: {
const documentTypeResponse = await axios.get(`https://paperless.andert.me/api/document_types/${doc.document_type}/`, { Authorization: process.env.PAPERLESS_TOKEN,
headers: { },
Authorization: process.env.PAPERLESS_TOKEN, });
}, const documentType = documentTypeResponse.data;
});
documentType = documentTypeResponse.data;
}
return { return {
...doc, ...doc,
@ -61,7 +54,7 @@ export default createOperation.query({
pdfData, pdfData,
correspondent, correspondent,
tags, tags,
documentType, document_type: documentType,
}; };
})); }));

13723
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,7 @@
<script lang="ts"> <script lang="ts">
import HeaderMain from "$lib/layouts/HeaderMain.svelte"; import HeaderMain from "$lib/layouts/HeaderMain.svelte";
import { Avatar } from "@skeletonlabs/skeleton";
import { createQuery } from "../../lib/wundergraph"; import { createQuery } from "../../lib/wundergraph";
import { Avatar } from "@skeletonlabs/skeleton";
const meQuery = createQuery({ const meQuery = createQuery({
operationName: "Me", operationName: "Me",

View File

@ -27,6 +27,10 @@
</script> </script>
<HeaderMain> <HeaderMain>
<!-- <div slot="header">
<h1>Paperless Documents</h1>
</div> -->
<div slot="main" class="h-full w-full overflow-scroll flex"> <div slot="main" class="h-full w-full overflow-scroll flex">
<div class="w-1/4 h-full overflow-scroll"> <div class="w-1/4 h-full overflow-scroll">
{#if $paperlessQuery.isLoading} {#if $paperlessQuery.isLoading}
@ -42,12 +46,9 @@
<h2 class="text-lg font-semibold"> <h2 class="text-lg font-semibold">
{document.archived_file_name} {document.archived_file_name}
</h2> </h2>
<p>Correspondent: {document.correspondent?.name || "N/A"}</p> <p>Correspondent: {document.correspondent.name}</p>
<p> <p>Tags: {document.tags.map((tag) => tag.name).join(", ")}</p>
Tags: {document.tags?.map((tag) => tag.name).join(", ") || <p>{document.document_type.name}</p>
"N/A"}
</p>
<p>{document.documentType?.name || "N/A"}</p>
</div> </div>
</a> </a>
{/each} {/each}

View File

@ -1,6 +1,7 @@
import { sveltekit } from '@sveltejs/kit/vite'; import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import { fetchSchemas } from './.wundergraph/schemas/fetch-schemas'; import { fetchSchemas } from './.wundergraph/schemas/fetch-schemas';
import { vitePreprocess } from '@sveltejs/kit/vite';
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
@ -15,4 +16,4 @@ export default defineConfig({
}, },
}, },
], ],
}); });

8978
yarn.lock

File diff suppressed because it is too large Load Diff