Fix alerts and audit log data normalization (#1010)

This commit is contained in:
ZacharyZcR
2026-07-10 08:02:47 +08:00
committed by GitHub
parent 38c5932aa9
commit 1b5baf2351
6 changed files with 188 additions and 6 deletions
+6 -3
View File
@@ -101,7 +101,7 @@ export function AdminAuditLogSection({
.catch(() => {});
fetchLogs(buildFilters(), 1);
setPage(1);
}, [open]);
}, [open, buildFilters, fetchLogs]);
useEffect(() => {
if (!open) return;
@@ -114,6 +114,9 @@ export function AdminAuditLogSection({
if (debounceRef.current) clearTimeout(debounceRef.current);
};
}, [
open,
buildFilters,
fetchLogs,
filterUserId,
filterAction,
filterResourceType,
@@ -179,7 +182,7 @@ export function AdminAuditLogSection({
onChange={(e) => setFilterUserId(e.target.value)}
>
<option value="">{t("admin.auditLogFilterAll")}</option>
{users.map((u) => (
{(Array.isArray(users) ? users : []).map((u) => (
<option key={u.id} value={u.id}>
{u.username}
</option>
@@ -318,7 +321,7 @@ export function AdminAuditLogSection({
<div className="flex flex-col gap-0.5 min-w-0 flex-1">
<div className="flex items-center gap-1.5 flex-wrap">
<span className="text-[10px] font-semibold text-foreground">
{log.action.replace(/_/g, " ")}
{(log.action || "unknown").replace(/_/g, " ")}
</span>
<span className="text-[9px] px-1 py-px border border-border text-muted-foreground">
{log.resourceType}
+2 -1
View File
@@ -37,6 +37,7 @@ const SEVERITY_CLASS: Record<string, string> = {
function timeAgo(isoStr: string): string {
const ms = Date.now() - new Date(isoStr).getTime();
if (!Number.isFinite(ms)) return "";
const sec = Math.floor(ms / 1000);
if (sec < 60) return `${sec}s ago`;
const min = Math.floor(sec / 60);
@@ -321,7 +322,7 @@ export function AlertsPanel() {
{rule.name}
</div>
<div className="text-[10px] text-muted-foreground">
{rule.triggerType.replace(/_/g, " ")}
{(rule.triggerType || "").replace(/_/g, " ")}
</div>
</div>
<div