Files
nexarch/web/lic-admin/app/page.tsx
T
sysopsandClaude Sonnet 5 349104a809 QA-09: barrierefreiheits-audit
Voller Merge von TEN-05/IAM-08/RBAC-05/LIC-04/AUD-04/CFG-04/OPS-02 (SHL-01
bereits Bestandteil) nach feature/qa-09-barrierefreiheits-audit. WCAG-2.1-AA-
Audit ueber alle 7 Core-Frontends (15 Seiten): automatisierte Pruefung
(pa11y/HTML_CodeSniffer WCAG2AA) und automatisiertes Tastatur-Traversal
(Puppeteer) auf 192.168.1.131 durchgefuehrt, Ergebnis nach Fixes 0/15
Verstoesse, 100% Tastaturerreichbarkeit ohne Fallen.

Vier reale WCAG-Verstoesse gefunden und behoben: ungueltiger
autocomplete="username" auf type="email"-Feldern (account, 2 Seiten) sowie
fehlende zugaengliche Namen auf Filter-/Eingabefeldern in audit-log,
lic-admin und tenant-admin (aria-label ergaenzt).

Zusaetzlich ein realer Testinfrastruktur-Fehler in internal/adminapi
gefunden: lichandler_test.go's Cleanup rief `DELETE FROM tenant_licenses
WHERE tenant_id = $1` OHNE das $1-Argument auf (Fehler durch `_, _ =`
verschluckt) - die Tenant-Zeile blieb dadurch ueber eine FK-Constraint
dauerhaft haengen und verfaelschte internal/migrate im vollen Testlauf,
analog zu den in QA-04 gefundenen defer/t.Cleanup-Bugs. Nur Testcode
betroffen.

Ein Restbefund terminiert: echter Bildschirmleser-Durchlauf (NVDA/
VoiceOver) steht mangels grafischer Testumgebung noch aus, Frist vor QA-05
(siehe docs/QA-09-BARRIEREFREIHEITS-AUDIT.md Abschnitt 5).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HhgFcLS8tYMhDJpP74C6AQ
2026-08-29 10:27:15 +02:00

175 lines
5.7 KiB
TypeScript

"use client";
import { useState } from "react";
import { fetchOverview, toggleFlag, type Overview } from "@/lib/api";
const STATUS_LABEL: Record<string, string> = {
ok: "In Ordnung",
warning: "Nahe am Limit",
exceeded: "Limit überschritten",
};
const STATUS_COLOR: Record<string, string> = {
ok: "#2e7d32",
warning: "#ed6c02",
exceeded: "#c62828",
};
export default function Page() {
const [tenantId, setTenantId] = useState("");
const [overview, setOverview] = useState<Overview | null>(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const [toggleError, setToggleError] = useState<string | null>(null);
async function load() {
if (!tenantId.trim()) return;
setLoading(true);
setError(null);
try {
const data = await fetchOverview(tenantId.trim());
setOverview(data);
} catch (e: any) {
setError(e.message ?? "Unbekannter Fehler");
setOverview(null);
} finally {
setLoading(false);
}
}
async function onToggle(key: string, next: boolean) {
setToggleError(null);
try {
await toggleFlag(tenantId.trim(), key, next);
await load();
} catch (e: any) {
setToggleError(e.message ?? "Umschalten fehlgeschlagen");
}
}
return (
<main style={{ maxWidth: 800, margin: "0 auto", padding: "2rem 1rem" }}>
<h1>Lizenz- und Modulverwaltung</h1>
<div style={{ display: "flex", gap: "0.5rem", marginBottom: "1.5rem" }}>
<input
value={tenantId}
onChange={(e) => setTenantId(e.target.value)}
placeholder="Tenant-ID eingeben"
aria-label="Tenant-ID eingeben"
style={{ flex: 1, padding: "0.5rem", fontSize: "1rem" }}
/>
<button onClick={load} disabled={loading} style={{ padding: "0.5rem 1rem" }}>
{loading ? "Lädt…" : "Anzeigen"}
</button>
</div>
{error && (
<p style={{ color: "#c62828" }} role="alert">
Fehler: {error}
</p>
)}
{overview && (
<>
<section style={{ background: "white", padding: "1rem", borderRadius: 8, marginBottom: "1.5rem" }}>
<h2>Lizenzstatus</h2>
<p>
<strong>Plan:</strong> {overview.plan}{" "}
{overview.expired && (
<span style={{ color: "#c62828", fontWeight: "bold" }}>
(abgelaufen)
</span>
)}
</p>
<p>
<strong>Gültig bis:</strong>{" "}
{new Date(overview.valid_until).toLocaleDateString("de-DE")}
</p>
<p>
<strong>Freigeschaltete Module:</strong>{" "}
{overview.modules.length > 0 ? overview.modules.join(", ") : "keine"}
</p>
</section>
<section style={{ background: "white", padding: "1rem", borderRadius: 8, marginBottom: "1.5rem" }}>
<h2>Feature-Flags</h2>
{toggleError && (
<p style={{ color: "#c62828" }} role="alert">
{toggleError}
</p>
)}
{overview.flags.length === 0 && <p>Keine Feature-Flags definiert.</p>}
<ul style={{ listStyle: "none", padding: 0 }}>
{overview.flags.map((f) => (
<li
key={f.key}
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
padding: "0.5rem 0",
borderBottom: "1px solid #eee",
}}
>
<div>
<div>{f.key}</div>
{!f.licensed && f.deny_grund && (
<div style={{ fontSize: "0.85rem", color: "#c62828" }}>
{f.deny_grund}
</div>
)}
</div>
<label>
<input
type="checkbox"
checked={f.enabled}
disabled={!f.licensed && !f.enabled}
onChange={(e) => onToggle(f.key, e.target.checked)}
/>{" "}
aktiv
</label>
</li>
))}
</ul>
</section>
<section style={{ background: "white", padding: "1rem", borderRadius: 8 }}>
<h2>Nutzungsstand</h2>
{overview.usage.map((u) => {
const pct = u.limit > 0 ? Math.min(100, (u.value / u.limit) * 100) : 0;
return (
<div key={u.metric} style={{ marginBottom: "1rem" }}>
<div style={{ display: "flex", justifyContent: "space-between" }}>
<span>{u.metric}</span>
<span style={{ color: STATUS_COLOR[u.status] }}>
{u.value} / {u.limit > 0 ? u.limit : "unbegrenzt"} {" "}
{STATUS_LABEL[u.status]}
</span>
</div>
<div
style={{
background: "#eee",
borderRadius: 4,
height: 8,
overflow: "hidden",
}}
>
<div
style={{
width: `${u.limit > 0 ? pct : 0}%`,
background: STATUS_COLOR[u.status],
height: "100%",
}}
/>
</div>
</div>
);
})}
</section>
</>
)}
</main>
);
}