diff --git a/web/src/pages/AuditLog.tsx b/web/src/pages/AuditLog.tsx index e51f379..9176350 100644 --- a/web/src/pages/AuditLog.tsx +++ b/web/src/pages/AuditLog.tsx @@ -1,6 +1,22 @@ import { useEffect, useState } from "react"; import { api, type AuditLogEntry } from "../api/client"; +function targetLabel(e: AuditLogEntry): string { + if (!e.targetType) return "—"; + let detail: Record | null = null; + if (e.detail) { + try { + detail = JSON.parse(e.detail); + } catch { + detail = null; + } + } + const name = detail?.name ?? detail?.targetLabel ?? detail?.ipAddress; + const typeLabel = e.targetType.replace(/_/g, " "); + if (typeof name === "string" && name) return `${typeLabel} "${name}"`; + return `${typeLabel}${e.targetId ? ` #${e.targetId}` : ""}`; +} + export default function AuditLog() { const [entries, setEntries] = useState(null); const [error, setError] = useState(null); @@ -37,9 +53,7 @@ export default function AuditLog() { {e.category} {e.action} - - {e.targetType ? `${e.targetType}${e.targetId ? ` #${e.targetId}` : ""}` : "—"} - + {targetLabel(e)} ))} {entries?.length === 0 && (