-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.html
More file actions
117 lines (95 loc) · 2.85 KB
/
Copy pathdashboard.html
File metadata and controls
117 lines (95 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html>
<head>
<title>SentinelIQ SOC Dashboard</title>
<script src="https://d3js.org/d3.v7.min.js"></script>
<style>
body {
background: #0b0f14;
color: #00ff88;
font-family: Arial;
}
#graph {
width: 100%;
height: 500px;
border: 1px solid #222;
}
#ai-panel {
margin-top: 20px;
padding: 10px;
background: #111;
color: #00ff88;
border: 1px solid #333;
}
</style>
</head>
<body>
<h2>🔥 Live SOC Stream</h2>
<div id="graph"></div>
<div id="ai-panel">
🧠 AI SOC ANALYST: Waiting for events...
</div>
<script>
const width = 900;
const height = 500;
const svg = d3.select("#graph")
.append("svg")
.attr("width", width)
.attr("height", height);
async function loadGraph() {
try {
const res = await fetch("http://127.0.0.1:8000/graph");
const data = await res.json();
svg.selectAll("*").remove();
const nodes = data.nodes;
const links = data.edges;
const simulation = d3.forceSimulation(nodes)
.force("link", d3.forceLink(links).id(d => d.id).distance(120))
.force("charge", d3.forceManyBody().strength(-300))
.force("center", d3.forceCenter(width / 2, height / 2));
const link = svg.append("g")
.selectAll("line")
.data(links)
.enter()
.append("line")
.attr("stroke", "#555");
const node = svg.append("g")
.selectAll("circle")
.data(nodes)
.enter()
.append("circle")
.attr("r", d => 8 + d.event_count)
.attr("fill", d => {
if (d.risk_accumulator > 70) return "red";
if (d.risk_accumulator > 40) return "orange";
return "green";
});
simulation.on("tick", () => {
link
.attr("x1", d => d.source.x)
.attr("y1", d => d.source.y)
.attr("x2", d => d.target.x)
.attr("y2", d => d.target.y);
node
.attr("cx", d => d.x)
.attr("cy", d => d.y);
});
// AI Narrative
if (nodes.length > 0) {
const last = nodes[nodes.length - 1];
document.getElementById("ai-panel").innerHTML =
`⚠️ Activity detected on <b>${last.id}</b><br>
Risk: <b>${last.risk_accumulator}</b><br>
Events: <b>${last.event_count}</b>`;
}
} catch (err) {
console.error(err);
document.getElementById("ai-panel").innerHTML =
"❌ Failed to load graph (backend not reachable)";
}
}
setInterval(loadGraph, 2000);
loadGraph();
</script>
</body>
</html>