// 2D topology — logical network map
function Topology({ nodes, onSelect }) {
const [hover, setHover] = React.useState(null);
// layout: columns by group
const layout = React.useMemo(() => {
const W = 1600, H = Math.max(800, Math.ceil(Math.max(...window.GROUPS.map(g => nodes.filter(n => n.group === g).length)) / 2) * 70 + 280);
const positions = {};
window.GROUPS.forEach((group, gi) => {
const list = nodes.filter(n => n.group === group);
const colX = 200 + gi * 280;
list.forEach((n, i) => {
const col = i % 2;
const row = Math.floor(i / 2);
positions[n.id] = {
x: colX + col * 110,
y: 200 + row * 62,
};
});
});
return { positions, W, H };
}, [nodes]);
const statusColor = (s) => s === 'ok' ? 'var(--ok)' : s === 'crit' ? 'var(--crit)' : (s === 'maint' || s === 'warn') ? 'var(--warn)' : 'var(--off)';
return (
Topology · logical
groups{window.GROUPS.length}
endpoints{nodes.length}
probes frommonitoring agent
Legend
up · 200-299
down · 5xx / 4xx
maintenance
timeout
);
}
Object.assign(window, { Topology });