KI-AGENT: Ergänze Mandantenexport und Import
All checks were successful
Build and Push Docker Images / build-backend (push) Successful in 18s
Build and Push Docker Images / build-frontend (push) Successful in 51s
Build and Push Docker Images / build-docs (push) Successful in 11s

This commit is contained in:
2026-05-18 21:23:18 +02:00
parent 9c6a6a841a
commit bb3b842be1
5 changed files with 571 additions and 0 deletions

View File

@@ -8,7 +8,9 @@ const admin = useAdmin()
const loading = ref(true)
const creatingTenant = ref(false)
const importingTenant = ref(false)
const createTenantModalOpen = ref(false)
const importFileInput = ref<HTMLInputElement | null>(null)
const tenants = ref<AdminTenant[]>([])
const searchString = ref("")
@@ -89,6 +91,46 @@ const createTenant = async () => {
}
}
const openImportFileDialog = () => {
importFileInput.value?.click()
}
const importTenantExport = async (event: Event) => {
const input = event.target as HTMLInputElement
const file = input.files?.[0]
if (!file || importingTenant.value) return
importingTenant.value = true
try {
const exportData = JSON.parse(await file.text())
const result = await admin.importTenant(exportData)
const rowCount = (result.tables || []).reduce((sum, table) => sum + table.rows, 0)
await fetchTenants()
toast.add({
title: "Mandantenimport abgeschlossen",
description: `Tenant ${result.tenantId}: ${rowCount} Datensätze und ${result.files?.restored || 0} Dateien verarbeitet.`,
color: "green",
})
if (result.tenantId) {
await router.push(`/administration/tenants/${result.tenantId}`)
}
} catch (err: any) {
console.error("[administration/tenants/import]", err)
toast.add({
title: "Mandant konnte nicht importiert werden",
description: err?.data?.error || err?.message || "Unbekannter Fehler",
color: "red",
})
} finally {
importingTenant.value = false
input.value = ""
}
}
onMounted(async () => {
if (!auth.user?.is_admin) {
await router.push("/")
@@ -111,6 +153,22 @@ onMounted(async () => {
<UButton icon="i-heroicons-plus" @click="createTenantModalOpen = true">
Tenant
</UButton>
<input
ref="importFileInput"
type="file"
accept="application/json,.json"
class="hidden"
@change="importTenantExport"
>
<UButton
icon="i-heroicons-arrow-up-tray"
color="warning"
variant="soft"
:loading="importingTenant"
@click="openImportFileDialog"
>
Import
</UButton>
</template>
</UDashboardNavbar>