KI-AGENT: Matrix-Mandanten-Space provisionieren

This commit is contained in:
2026-05-18 17:11:52 +02:00
parent c893574cb1
commit d0de3cb92e
5 changed files with 418 additions and 87 deletions

View File

@@ -4,9 +4,12 @@ const { $api } = useNuxtApp()
const status = ref(null)
const identity = ref(null)
const tenantSpace = ref(null)
const provisionResult = ref(null)
const tenantSpaceProvisionResult = ref(null)
const loading = ref(false)
const provisioning = ref(false)
const tenantSpaceProvisioning = ref(false)
const lastUpdated = ref(null)
const statusItems = computed(() => [
@@ -45,13 +48,15 @@ const statusItems = computed(() => [
const loadMatrixInfo = async () => {
loading.value = true
try {
const [statusRes, identityRes] = await Promise.all([
const [statusRes, identityRes, tenantSpaceRes] = await Promise.all([
$api("/api/communication/matrix/status"),
$api("/api/communication/matrix/me")
$api("/api/communication/matrix/me"),
$api("/api/communication/matrix/tenant-space")
])
status.value = statusRes
identity.value = identityRes
tenantSpace.value = tenantSpaceRes
lastUpdated.value = new Date()
} catch (error) {
toast.add({
@@ -91,6 +96,37 @@ const provisionMatrixAccount = async () => {
}
}
const provisionTenantSpace = async () => {
tenantSpaceProvisioning.value = true
try {
const res = await $api("/api/communication/matrix/tenant-space/provision", {
method: "POST"
})
tenantSpaceProvisionResult.value = res
tenantSpace.value = {
tenantId: res.tenantId,
tenantName: res.tenantName,
alias: res.alias,
exists: true,
roomId: res.roomId,
servers: res.servers || []
}
toast.add({
title: res.alreadyExisted ? "Mandanten-Space ist bereits vorhanden" : "Mandanten-Space erstellt",
color: "success"
})
} catch (error) {
toast.add({
title: "Mandanten-Space konnte nicht erstellt werden",
color: "error"
})
} finally {
tenantSpaceProvisioning.value = false
}
}
const formatDateTime = (value) => {
if (!value) return "-"
@@ -156,80 +192,149 @@ onMounted(loadMatrixInfo)
</div>
<div class="grid gap-4 lg:grid-cols-[minmax(0,1fr)_360px]">
<UCard :ui="{ root: 'rounded-lg' }">
<template #header>
<div class="flex items-center gap-2">
<UIcon name="i-heroicons-user-circle" class="size-5 text-primary" />
<h2 class="text-base font-semibold text-highlighted">
Eigene Matrix-Identität
</h2>
</div>
</template>
<div class="space-y-4">
<UCard :ui="{ root: 'rounded-lg' }">
<template #header>
<div class="flex items-center gap-2">
<UIcon name="i-heroicons-user-circle" class="size-5 text-primary" />
<h2 class="text-base font-semibold text-highlighted">
Eigene Matrix-Identität
</h2>
</div>
</template>
<div class="space-y-4">
<div class="grid gap-3 sm:grid-cols-2">
<div>
<p class="text-xs font-medium uppercase text-muted">
Matrix-ID
</p>
<p class="mt-1 break-all font-mono text-sm text-highlighted">
{{ identity?.matrixUserId || "-" }}
</p>
</div>
<div>
<p class="text-xs font-medium uppercase text-muted">
Anzeigename
</p>
<p class="mt-1 text-sm text-highlighted">
{{ identity?.displayName || "-" }}
</p>
</div>
</div>
<UAlert
v-if="provisionResult"
icon="i-heroicons-check-circle"
color="success"
variant="soft"
:title="provisionResult.alreadyExisted ? 'Matrix-Konto vorhanden' : 'Matrix-Konto erstellt'"
:description="provisionResult.matrixUserId"
/>
<UAlert
v-if="status && !status.reachable"
icon="i-heroicons-exclamation-triangle"
color="error"
variant="soft"
title="Matrix-Homeserver nicht erreichbar"
:description="status.error || 'Bitte prüfe den lokalen Matrix-Stack und die Backend-Konfiguration.'"
/>
<UAlert
v-else-if="status && !status.provisioningConfigured"
icon="i-heroicons-key"
color="warning"
variant="soft"
title="Matrix-Provisionierung nicht eingerichtet"
description="Bitte setze MATRIX_REGISTRATION_SHARED_SECRET in der Backend-Umgebung."
/>
</div>
<template #footer>
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<p class="text-xs text-muted">
Aktualisiert: {{ formatDateTime(lastUpdated) }}
</p>
<UButton
icon="i-heroicons-user-plus"
:loading="provisioning"
:disabled="!status?.reachable || !status?.provisioningConfigured"
@click="provisionMatrixAccount"
>
Matrix-Konto erstellen
</UButton>
</div>
</template>
</UCard>
<UCard :ui="{ root: 'rounded-lg' }">
<template #header>
<div class="flex items-center gap-2">
<UIcon name="i-heroicons-building-office-2" class="size-5 text-primary" />
<h2 class="text-base font-semibold text-highlighted">
Mandanten-Space
</h2>
</div>
</template>
<div class="space-y-4">
<div class="grid gap-3 sm:grid-cols-2">
<div>
<p class="text-xs font-medium uppercase text-muted">
Alias
</p>
<p class="mt-1 break-all font-mono text-sm text-highlighted">
{{ tenantSpace?.alias || "-" }}
</p>
</div>
<div>
<p class="text-xs font-medium uppercase text-muted">
Status
</p>
<UBadge
class="mt-1"
:color="tenantSpace?.exists ? 'success' : 'neutral'"
variant="soft"
>
{{ tenantSpace?.exists ? "Vorhanden" : "Noch nicht erstellt" }}
</UBadge>
</div>
</div>
<div class="space-y-4">
<div class="grid gap-3 sm:grid-cols-2">
<div>
<p class="text-xs font-medium uppercase text-muted">
Matrix-ID
Raum-ID
</p>
<p class="mt-1 break-all font-mono text-sm text-highlighted">
{{ identity?.matrixUserId || "-" }}
{{ tenantSpace?.roomId || "-" }}
</p>
</div>
<div>
<p class="text-xs font-medium uppercase text-muted">
Anzeigename
</p>
<p class="mt-1 text-sm text-highlighted">
{{ identity?.displayName || "-" }}
</p>
<UAlert
v-if="tenantSpaceProvisionResult"
icon="i-heroicons-check-circle"
color="success"
variant="soft"
:title="tenantSpaceProvisionResult.alreadyExisted ? 'Mandanten-Space vorhanden' : 'Mandanten-Space erstellt'"
:description="tenantSpaceProvisionResult.alias"
/>
</div>
<template #footer>
<div class="flex justify-end">
<UButton
icon="i-heroicons-plus"
:loading="tenantSpaceProvisioning"
:disabled="!status?.reachable || !status?.provisioningConfigured"
@click="provisionTenantSpace"
>
Mandanten-Space erstellen
</UButton>
</div>
</div>
<UAlert
v-if="provisionResult"
icon="i-heroicons-check-circle"
color="success"
variant="soft"
:title="provisionResult.alreadyExisted ? 'Matrix-Konto vorhanden' : 'Matrix-Konto erstellt'"
:description="provisionResult.matrixUserId"
/>
<UAlert
v-if="status && !status.reachable"
icon="i-heroicons-exclamation-triangle"
color="error"
variant="soft"
title="Matrix-Homeserver nicht erreichbar"
:description="status.error || 'Bitte prüfe den lokalen Matrix-Stack und die Backend-Konfiguration.'"
/>
<UAlert
v-else-if="status && !status.provisioningConfigured"
icon="i-heroicons-key"
color="warning"
variant="soft"
title="Matrix-Provisionierung nicht eingerichtet"
description="Bitte setze MATRIX_REGISTRATION_SHARED_SECRET in der Backend-Umgebung."
/>
</div>
<template #footer>
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<p class="text-xs text-muted">
Aktualisiert: {{ formatDateTime(lastUpdated) }}
</p>
<UButton
icon="i-heroicons-user-plus"
:loading="provisioning"
:disabled="!status?.reachable || !status?.provisioningConfigured"
@click="provisionMatrixAccount"
>
Matrix-Konto erstellen
</UButton>
</div>
</template>
</UCard>
</template>
</UCard>
</div>
<UCard :ui="{ root: 'rounded-lg' }">
<template #header>
@@ -244,7 +349,7 @@ onMounted(loadMatrixInfo)
<div class="space-y-3 text-sm text-muted">
<div class="flex gap-2">
<UIcon name="i-heroicons-building-office-2" class="mt-0.5 size-4 shrink-0" />
<span>Mandanten-Space automatisch anlegen.</span>
<span>Team- und Projekt-Räume im Mandanten-Space anlegen.</span>
</div>
<div class="flex gap-2">
<UIcon name="i-heroicons-users" class="mt-0.5 size-4 shrink-0" />