diff --git a/src/m365-security-dashboard-client/src/main.tsx b/src/m365-security-dashboard-client/src/main.tsx index cfc34b0..700bf82 100644 --- a/src/m365-security-dashboard-client/src/main.tsx +++ b/src/m365-security-dashboard-client/src/main.tsx @@ -153,9 +153,13 @@ interface TriggeredAlert { metricValue: number; threshold: number; triggeredAt: string; - status: "new" | "acknowledged" | "resolved"; + status: "new" | "acknowledged" | "snoozed" | "auto_resolved" | "resolved"; acknowledgedAt?: string; acknowledgedBy?: string; + snoozedUntil?: string; + snoozedBy?: string; + belowThresholdStreakCount?: number; + lastEvaluatedAt?: string; } interface NotificationSettings { @@ -212,6 +216,12 @@ const acApi = { async getLog(): Promise { try { const r = await fetch(`${apiBase}/api/notification-log`); return r.ok ? await r.json() : []; } catch { return []; } }, + async snooze(id: string, durationHours: 4 | 24 | 168): Promise { + try { const r = await fetch(`${apiBase}/api/triggered-alerts/${id}/snooze`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ durationHours }) }); return r.ok; } catch { return false; } + }, + async unsnooze(id: string): Promise { + try { const r = await fetch(`${apiBase}/api/triggered-alerts/${id}/unsnooze`, { method: "POST" }); return r.ok; } catch { return false; } + }, }; const SEVERITIES: AlertSeverity[] = ["Critical", "High", "Medium", "Low", "Informational"]; @@ -3508,7 +3518,11 @@ function sevToneAC(s: string): Tone { return s === "critical" ? "error" : s === "high" ? "error" : s === "medium" ? "warning" : "info"; } function statusTone(s: string): Tone { - return s === "new" ? "error" : s === "acknowledged" ? "warning" : "good"; + return s === "new" ? "error" + : s === "acknowledged" ? "warning" + : s === "snoozed" ? "neutral" + : s === "auto_resolved" ? "info" + : "good"; // resolved } function PolicyModal({ policy, onSave, onClose }: { @@ -3784,6 +3798,14 @@ function AlertCenterPage({ policies, triggeredAlerts, onChanged }: { if (await acApi.resolve(id)) { showToast("Alert resolved"); await onChanged(); } }; + const snooze = async (id: string, durationHours: 4 | 24 | 168) => { + if (await acApi.snooze(id, durationHours)) { showToast(`Snoozed for ${durationHours}h`); await onChanged(); } + }; + + const unsnooze = async (id: string) => { + if (await acApi.unsnooze(id)) { showToast("Snooze cleared"); await onChanged(); } + }; + const handleSavePolicy = async (p: AlertPolicy) => { const exists = policies.some(x => x.id === p.id); const ok = exists ? await acApi.updatePolicy(p) : !!(await acApi.createPolicy(p)); @@ -3845,6 +3867,8 @@ function AlertCenterPage({ policies, triggeredAlerts, onChanged }: { {selectedTriggered.acknowledgedAt && } + {selectedTriggered.snoozedUntil && } + {selectedTriggered.lastEvaluatedAt && }
@@ -3946,6 +3970,9 @@ function AlertCenterPage({ policies, triggeredAlerts, onChanged }: { {a.policyName} + {a.snoozedUntil && new Date(a.snoozedUntil) > new Date() && ( + Z until {relTime(a.snoozedUntil)} + )} {relTime(a.triggeredAt)} {a.status === "new" && ( @@ -3980,6 +4007,8 @@ function AlertCenterPage({ policies, triggeredAlerts, onChanged }: { + + ({ Policy:a.policyName, Severity:a.severity, Category:a.category, Condition:a.condition, MetricValue:a.metricValue, Threshold:a.threshold, Triggered:a.triggeredAt, Status:a.status }))} filename="triggered-alerts.csv"/> @@ -4007,10 +4036,29 @@ function AlertCenterPage({ policies, triggeredAlerts, onChanged }: { {a.metricValue} {a.threshold} {relTime(a.triggeredAt)} - - e.stopPropagation()} style={{ display:"flex", gap:4, alignItems:"center" }}> + + {a.snoozedUntil && new Date(a.snoozedUntil) > new Date() && ( +
snoozed until {relTime(a.snoozedUntil)}
+ )} + + e.stopPropagation()} style={{ display:"flex", gap:4, alignItems:"center", flexWrap:"wrap" }}> {a.status === "new" && } - {a.status !== "resolved" && } + {a.status !== "resolved" && a.status !== "auto_resolved" && ( + + )} + {a.snoozedUntil && new Date(a.snoozedUntil) > new Date() && ( + + )} + {a.status !== "resolved" && a.status !== "auto_resolved" && } ))}