Add audit log viewer to Settings page
This commit is contained in:
@@ -113,6 +113,18 @@
|
||||
}
|
||||
saving = false;
|
||||
}
|
||||
|
||||
let auditLines = $state([]);
|
||||
let auditLoading = $state(false);
|
||||
|
||||
async function loadAuditLog() {
|
||||
auditLoading = true;
|
||||
try {
|
||||
const res = await get("/system/audit-log?lines=100");
|
||||
auditLines = res.lines.reverse();
|
||||
} catch {}
|
||||
auditLoading = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="space-y-6">
|
||||
@@ -189,4 +201,20 @@
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-xl border border-surface-200 p-6 shadow-sm">
|
||||
<div class="flex items-center justify-between mb-4">
|
||||
<h3 class="text-sm font-semibold text-surface-700">Audit Log</h3>
|
||||
<button onclick={loadAuditLog} disabled={auditLoading} class="px-3 py-1.5 text-xs font-medium text-primary-600 bg-primary-50 hover:bg-primary-100 rounded-lg transition-colors disabled:opacity-50">
|
||||
{auditLoading ? "Loading..." : auditLines.length ? "Refresh" : "Load"}
|
||||
</button>
|
||||
</div>
|
||||
{#if auditLines.length > 0}
|
||||
<div class="max-h-80 overflow-auto rounded-lg bg-surface-950 p-3">
|
||||
<pre class="text-xs text-surface-300 font-mono whitespace-pre leading-5">{auditLines.join('\n')}</pre>
|
||||
</div>
|
||||
{:else if !auditLoading}
|
||||
<p class="text-sm text-surface-400">Click Load to view recent audit log entries</p>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user