From 83e2d1b1bbd8435090494b8c19eb0fcda988f2ed Mon Sep 17 00:00:00 2001 From: marco370 <48531002-marco370@users.noreply.replit.com> Date: Tue, 25 Nov 2025 09:58:06 +0000 Subject: [PATCH] Add button to whitelist detected IPs and improve detection details Implement a new "Whitelist" button for each detection entry, allowing users to add suspicious IPs to a whitelist, and refactor the UI to better organize action buttons for detection details. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: intermediate_checkpoint Replit-Commit-Event-Id: 2aa19d64-471f-42f8-b39f-c065f4f1fc2f Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/1zhedLT --- client/src/pages/Detections.tsx | 51 +++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/client/src/pages/Detections.tsx b/client/src/pages/Detections.tsx index 3f7bc1d..e945bc5 100644 --- a/client/src/pages/Detections.tsx +++ b/client/src/pages/Detections.tsx @@ -44,6 +44,31 @@ export default function Detections() { d.anomalyType.toLowerCase().includes(searchQuery.toLowerCase()) ); + // Mutation per aggiungere a whitelist + const addToWhitelistMutation = useMutation({ + mutationFn: async (detection: Detection) => { + return await apiRequest("POST", "/api/whitelist", { + ipAddress: detection.sourceIp, + reason: `Auto-added from detection: ${detection.anomalyType} (Risk: ${parseFloat(detection.riskScore).toFixed(1)})` + }); + }, + onSuccess: (_, detection) => { + toast({ + title: "IP aggiunto alla whitelist", + description: `${detection.sourceIp} รจ stato aggiunto alla whitelist con successo.`, + }); + queryClient.invalidateQueries({ queryKey: ["/api/whitelist"] }); + queryClient.invalidateQueries({ queryKey: ["/api/detections"] }); + }, + onError: (error: any, detection) => { + toast({ + title: "Errore", + description: error.message || `Impossibile aggiungere ${detection.sourceIp} alla whitelist.`, + variant: "destructive", + }); + } + }); + const getRiskBadge = (riskScore: string) => { const score = parseFloat(riskScore); if (score >= 85) return CRITICO; @@ -253,12 +278,26 @@ export default function Detections() { )} - +
+ + + +