Compare commits

..

2 Commits

Author SHA1 Message Date
a7eed530a3 cleanup 2023-10-17 09:42:20 +02:00
af15eb1d0b Fixing a Paperless bug 2023-10-17 09:42:09 +02:00
6 changed files with 9015 additions and 13754 deletions

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

8978
yarn.lock Normal file

File diff suppressed because it is too large Load Diff