From 447c13592f21c03f2cb2d0a678618899e5b811cc Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Fri, 17 Apr 2026 19:23:58 -0300 Subject: [PATCH] refactor(audit): align audit dashboard with compliance log entries Switch the audit API and dashboard viewer to consume the compliance audit log shape instead of the older config diff format. This updates summary responses to return entry counts, adds total results for paginated audit queries, and replaces source-based filters with actor and date-based parameters. The dashboard copy and columns now reflect broader administrative and security events rather than only configuration changes. --- .../dashboard/audit/ConfigAuditViewer.tsx | 177 ++++++------------ src/app/(dashboard)/dashboard/audit/page.tsx | 5 +- src/app/api/audit/route.ts | 29 ++- 3 files changed, 70 insertions(+), 141 deletions(-) diff --git a/src/app/(dashboard)/dashboard/audit/ConfigAuditViewer.tsx b/src/app/(dashboard)/dashboard/audit/ConfigAuditViewer.tsx index 728897e1a7..298c09b60a 100644 --- a/src/app/(dashboard)/dashboard/audit/ConfigAuditViewer.tsx +++ b/src/app/(dashboard)/dashboard/audit/ConfigAuditViewer.tsx @@ -3,25 +3,18 @@ import { useState, useEffect } from "react"; import { useTranslations } from "next-intl"; -interface ConfigDiff { - added: string[]; - removed: string[]; - changed: Array<{ key: string; from: any; to: any }>; - isEmpty: boolean; -} - interface AuditEntry { - id: string; + id: number; timestamp: string; action: string; - target: string; - targetId: string; - targetName: string; - source: string; - before: any; - after: any; - diff: ConfigDiff; - note: string | null; + actor: string; + target?: string; + resource_type?: string; + ip_address?: string; + status?: string; + request_id?: string; + details?: any; + metadata?: any; } export default function ConfigAuditViewer() { @@ -48,16 +41,17 @@ export default function ConfigAuditViewer() { }; const getActionColor = (action: string) => { - switch (action) { - case "create": - return "text-green-400 bg-green-400/10 border-green-500/20"; - case "update": - return "text-blue-400 bg-blue-400/10 border-blue-500/20"; - case "delete": - return "text-red-400 bg-red-400/10 border-red-500/20"; - default: - return "text-gray-400 bg-gray-400/10 border-gray-500/20"; + const act = action.toLowerCase(); + if (act.includes("success") || act.includes("create")) { + return "text-green-400 bg-green-400/10 border-green-500/20"; } + if (act.includes("update") || act.includes("modify")) { + return "text-blue-400 bg-blue-400/10 border-blue-500/20"; + } + if (act.includes("failed") || act.includes("delete")) { + return "text-red-400 bg-red-400/10 border-red-500/20"; + } + return "text-gray-400 bg-gray-400/10 border-gray-500/20"; }; if (loading) { @@ -98,8 +92,8 @@ export default function ConfigAuditViewer() { Timestamp Action Target - Resource - Source + Actor + Resource/IP Details @@ -120,20 +114,20 @@ export default function ConfigAuditViewer() { - {entry.target} - - - {entry.targetName} + {entry.target || "-"} - {entry.source} + {entry.actor} + + + {entry.resource_type || entry.ip_address || "-"} @@ -149,10 +143,10 @@ export default function ConfigAuditViewer() {

- {selectedEntry.action} {selectedEntry.target} + {selectedEntry.action}

- ID: {selectedEntry.targetId} • {selectedEntry.targetName} + Actor: {selectedEntry.actor} • Target: {selectedEntry.target || "N/A"}