Added Dokubox Sync Service and Button Fix #12
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 30s
Build and Push Docker Images / build-frontend (push) Successful in 1m10s

This commit is contained in:
2026-01-22 17:05:22 +01:00
parent 1a065b649c
commit d2b70e5883
4 changed files with 260 additions and 199 deletions

View File

@@ -27,7 +27,16 @@ let client: ImapFlow | null = null
// ------------------------------------------------------------- // -------------------------------------------------------------
// IMAP CLIENT INITIALIZEN // IMAP CLIENT INITIALIZEN
// ------------------------------------------------------------- // -------------------------------------------------------------
export async function initDokuboxClient() {
// -------------------------------------------------------------
// MAIN SYNC FUNCTION (DRIZZLE VERSION)
// -------------------------------------------------------------
export function syncDokuboxService (server: FastifyInstance) {
async function initDokuboxClient() {
client = new ImapFlow({ client = new ImapFlow({
host: secrets.DOKUBOX_IMAP_HOST, host: secrets.DOKUBOX_IMAP_HOST,
port: secrets.DOKUBOX_IMAP_PORT, port: secrets.DOKUBOX_IMAP_PORT,
@@ -42,15 +51,9 @@ export async function initDokuboxClient() {
console.log("Dokubox E-Mail Client Initialized") console.log("Dokubox E-Mail Client Initialized")
await client.connect() await client.connect()
} }
const syncDokubox = async () => {
// -------------------------------------------------------------
// MAIN SYNC FUNCTION (DRIZZLE VERSION)
// -------------------------------------------------------------
export const syncDokubox = (server: FastifyInstance) =>
async () => {
console.log("Perform Dokubox Sync") console.log("Perform Dokubox Sync")
@@ -130,16 +133,11 @@ export const syncDokubox = (server: FastifyInstance) =>
} }
} }
const getMessageConfigDrizzle = async (
// -------------------------------------------------------------
// TENANT ERKENNEN + FOLDER/FILETYPES (DRIZZLE VERSION)
// -------------------------------------------------------------
const getMessageConfigDrizzle = async (
server: FastifyInstance, server: FastifyInstance,
message, message,
tenantsList: any[] tenantsList: any[]
) => { ) => {
let possibleKeys: string[] = [] let possibleKeys: string[] = []
@@ -256,4 +254,22 @@ const getMessageConfigDrizzle = async (
folder: folderId, folder: folderId,
filetype: filetypeId filetype: filetypeId
} }
}
return {
run: async () => {
await initDokuboxClient()
await syncDokubox()
console.log("Service: Dokubox sync finished")
}
}
} }
// -------------------------------------------------------------
// TENANT ERKENNEN + FOLDER/FILETYPES (DRIZZLE VERSION)
// -------------------------------------------------------------

View File

@@ -1,7 +1,7 @@
// /plugins/services.ts // /plugins/services.ts
import fp from "fastify-plugin"; import fp from "fastify-plugin";
import { bankStatementService } from "../modules/cron/bankstatementsync.service"; import { bankStatementService } from "../modules/cron/bankstatementsync.service";
//import {initDokuboxClient, syncDokubox} from "../modules/cron/dokuboximport.service"; import {syncDokuboxService} from "../modules/cron/dokuboximport.service";
import { FastifyInstance } from "fastify"; import { FastifyInstance } from "fastify";
import {prepareIncomingInvoices} from "../modules/cron/prepareIncomingInvoices"; import {prepareIncomingInvoices} from "../modules/cron/prepareIncomingInvoices";
@@ -9,7 +9,7 @@ declare module "fastify" {
interface FastifyInstance { interface FastifyInstance {
services: { services: {
bankStatements: ReturnType<typeof bankStatementService>; bankStatements: ReturnType<typeof bankStatementService>;
//dokuboxSync: ReturnType<typeof syncDokubox>; dokuboxSync: ReturnType<typeof syncDokuboxService>;
prepareIncomingInvoices: ReturnType<typeof prepareIncomingInvoices>; prepareIncomingInvoices: ReturnType<typeof prepareIncomingInvoices>;
}; };
} }
@@ -18,7 +18,7 @@ declare module "fastify" {
export default fp(async function servicePlugin(server: FastifyInstance) { export default fp(async function servicePlugin(server: FastifyInstance) {
server.decorate("services", { server.decorate("services", {
bankStatements: bankStatementService(server), bankStatements: bankStatementService(server),
//dokuboxSync: syncDokubox(server), dokuboxSync: syncDokuboxService(server),
prepareIncomingInvoices: prepareIncomingInvoices(server), prepareIncomingInvoices: prepareIncomingInvoices(server),
}); });
}); });

View File

@@ -179,6 +179,11 @@ export default async function functionRoutes(server: FastifyInstance) {
await server.services.prepareIncomingInvoices.run(req.user.tenant_id) await server.services.prepareIncomingInvoices.run(req.user.tenant_id)
}) })
server.post('/functions/services/syncdokubox', async (req, reply) => {
await server.services.dokuboxSync.run()
})
/*server.post('/print/zpl/preview', async (req, reply) => { /*server.post('/print/zpl/preview', async (req, reply) => {
const { zpl, widthMm = 50, heightMm = 30, dpmm = 8, asBase64 = false } = req.body as {zpl:string,widthMm:number,heightMm:number,dpmm:number,asBase64:string} const { zpl, widthMm = 50, heightMm = 30, dpmm = 8, asBase64 = false } = req.body as {zpl:string,widthMm:number,heightMm:number,dpmm:number,asBase64:string}

View File

@@ -11,6 +11,7 @@ const router = useRouter()
const route = useRoute() const route = useRoute()
const modal = useModal() const modal = useModal()
const toast = useToast() const toast = useToast()
const { $api } = useNuxtApp()
const files = useFiles() const files = useFiles()
// --- State --- // --- State ---
@@ -222,11 +223,50 @@ defineShortcuts({
'arrowdown': () => { if (selectedFileIndex.value < renderedFileList.value.length - 1) selectedFileIndex.value++ }, 'arrowdown': () => { if (selectedFileIndex.value < renderedFileList.value.length - 1) selectedFileIndex.value++ },
'arrowup': () => { if (selectedFileIndex.value > 0) selectedFileIndex.value-- } 'arrowup': () => { if (selectedFileIndex.value > 0) selectedFileIndex.value-- }
}) })
const isSyncing = ref(false)
const syncdokubox = async () => {
isSyncing.value = true
try {
await $api('/api/functions/services/syncdokubox', { method: 'POST' })
toast.add({
title: 'Erfolg',
description: 'Dokubox wurde synchronisiert.',
icon: 'i-heroicons-check-circle',
color: 'green'
})
// Liste neu laden
await setupPage()
} catch (error) {
console.error(error)
toast.add({
title: 'Fehler',
description: 'Beim Synchronisieren der Dokubox ist ein Fehler aufgetreten.',
icon: 'i-heroicons-exclamation-circle',
color: 'red'
})
} finally {
isSyncing.value = false
}
}
</script> </script>
<template> <template>
<UDashboardNavbar title="Dateien"> <UDashboardNavbar title="Dateien">
<template #right> <template #right>
<UButton
label="Dokubox Sync"
icon="i-heroicons-sparkles"
color="primary"
variant="solid"
:loading="isSyncing"
@click="syncdokubox"
class="mr-2"
/>
<UInput id="searchinput" v-model="searchString" icon="i-heroicons-magnifying-glass" placeholder="Suche..." class="w-64" /> <UInput id="searchinput" v-model="searchString" icon="i-heroicons-magnifying-glass" placeholder="Suche..." class="w-64" />
</template> </template>
</UDashboardNavbar> </UDashboardNavbar>