Update client for node ID references in links and dante peers
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1119,26 +1119,28 @@
|
|||||||
return 'speed-slow';
|
return 'speed-slow';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInterfaceSpeed(node) {
|
function findInterface(node, ifaceName) {
|
||||||
if (!node.interfaces || node.interfaces.length === 0) return 0;
|
if (!node || !node.interfaces) return null;
|
||||||
const iface = node.interfaces[0];
|
return node.interfaces.find(i => i.name === ifaceName) || null;
|
||||||
return iface.stats?.speed || 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInterfaceErrors(node) {
|
function getInterfaceSpeed(node, ifaceName) {
|
||||||
if (!node.interfaces || node.interfaces.length === 0) return null;
|
const iface = findInterface(node, ifaceName);
|
||||||
const iface = node.interfaces[0];
|
return iface?.stats?.speed || 0;
|
||||||
if (!iface.stats) return null;
|
}
|
||||||
|
|
||||||
|
function getInterfaceErrors(node, ifaceName) {
|
||||||
|
const iface = findInterface(node, ifaceName);
|
||||||
|
if (!iface?.stats) return null;
|
||||||
const inErr = iface.stats.in_errors || 0;
|
const inErr = iface.stats.in_errors || 0;
|
||||||
const outErr = iface.stats.out_errors || 0;
|
const outErr = iface.stats.out_errors || 0;
|
||||||
if (inErr === 0 && outErr === 0) return null;
|
if (inErr === 0 && outErr === 0) return null;
|
||||||
return { in: inErr, out: outErr };
|
return { in: inErr, out: outErr };
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInterfaceRates(node) {
|
function getInterfaceRates(node, ifaceName) {
|
||||||
if (!node.interfaces || node.interfaces.length === 0) return null;
|
const iface = findInterface(node, ifaceName);
|
||||||
const iface = node.interfaces[0];
|
if (!iface?.stats) return null;
|
||||||
if (!iface.stats) return null;
|
|
||||||
return {
|
return {
|
||||||
inPkts: iface.stats.in_pkts_rate || 0,
|
inPkts: iface.stats.in_pkts_rate || 0,
|
||||||
outPkts: iface.stats.out_pkts_rate || 0,
|
outPkts: iface.stats.out_pkts_rate || 0,
|
||||||
@@ -2014,8 +2016,8 @@
|
|||||||
const allSwitches = nodes.filter(n => isSwitch(n));
|
const allSwitches = nodes.filter(n => isSwitch(n));
|
||||||
|
|
||||||
links.forEach(link => {
|
links.forEach(link => {
|
||||||
const nodeA = nodesByTypeId.get(link.node_a?.id);
|
const nodeA = nodesByTypeId.get(link.node_a_id);
|
||||||
const nodeB = nodesByTypeId.get(link.node_b?.id);
|
const nodeB = nodesByTypeId.get(link.node_b_id);
|
||||||
if (!nodeA || !nodeB) return;
|
if (!nodeA || !nodeB) return;
|
||||||
|
|
||||||
const aIsSwitch = isSwitch(nodeA);
|
const aIsSwitch = isSwitch(nodeA);
|
||||||
@@ -2027,12 +2029,12 @@
|
|||||||
switchB: nodeB,
|
switchB: nodeB,
|
||||||
portA: link.interface_a || '?',
|
portA: link.interface_a || '?',
|
||||||
portB: link.interface_b || '?',
|
portB: link.interface_b || '?',
|
||||||
speedA: getInterfaceSpeed(link.node_a),
|
speedA: getInterfaceSpeed(nodeA, link.interface_a),
|
||||||
speedB: getInterfaceSpeed(link.node_b),
|
speedB: getInterfaceSpeed(nodeB, link.interface_b),
|
||||||
errorsA: getInterfaceErrors(link.node_a),
|
errorsA: getInterfaceErrors(nodeA, link.interface_a),
|
||||||
errorsB: getInterfaceErrors(link.node_b),
|
errorsB: getInterfaceErrors(nodeB, link.interface_b),
|
||||||
ratesA: getInterfaceRates(link.node_a),
|
ratesA: getInterfaceRates(nodeA, link.interface_a),
|
||||||
ratesB: getInterfaceRates(link.node_b)
|
ratesB: getInterfaceRates(nodeB, link.interface_b)
|
||||||
});
|
});
|
||||||
} else if (aIsSwitch && !bIsSwitch) {
|
} else if (aIsSwitch && !bIsSwitch) {
|
||||||
const nodeLoc = nodeLocations.get(nodeB.id);
|
const nodeLoc = nodeLocations.get(nodeB.id);
|
||||||
@@ -2043,9 +2045,9 @@
|
|||||||
switchName: getLabel(nodeA),
|
switchName: getLabel(nodeA),
|
||||||
showSwitchName: !isLocalSwitch,
|
showSwitchName: !isLocalSwitch,
|
||||||
external: effectiveSwitch && !isLocalSwitch,
|
external: effectiveSwitch && !isLocalSwitch,
|
||||||
speed: getInterfaceSpeed(link.node_a),
|
speed: getInterfaceSpeed(nodeA, link.interface_a),
|
||||||
errors: getInterfaceErrors(link.node_a),
|
errors: getInterfaceErrors(nodeA, link.interface_a),
|
||||||
rates: getInterfaceRates(link.node_a)
|
rates: getInterfaceRates(nodeA, link.interface_a)
|
||||||
});
|
});
|
||||||
} else if (bIsSwitch && !aIsSwitch) {
|
} else if (bIsSwitch && !aIsSwitch) {
|
||||||
const nodeLoc = nodeLocations.get(nodeA.id);
|
const nodeLoc = nodeLocations.get(nodeA.id);
|
||||||
@@ -2056,9 +2058,9 @@
|
|||||||
switchName: getLabel(nodeB),
|
switchName: getLabel(nodeB),
|
||||||
showSwitchName: !isLocalSwitch,
|
showSwitchName: !isLocalSwitch,
|
||||||
external: effectiveSwitch && !isLocalSwitch,
|
external: effectiveSwitch && !isLocalSwitch,
|
||||||
speed: getInterfaceSpeed(link.node_b),
|
speed: getInterfaceSpeed(nodeB, link.interface_b),
|
||||||
errors: getInterfaceErrors(link.node_b),
|
errors: getInterfaceErrors(nodeB, link.interface_b),
|
||||||
rates: getInterfaceRates(link.node_b)
|
rates: getInterfaceRates(nodeB, link.interface_b)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -2080,14 +2082,16 @@
|
|||||||
if (danteTx.length === 0 && danteRx.length === 0) return;
|
if (danteTx.length === 0 && danteRx.length === 0) return;
|
||||||
|
|
||||||
const txTo = danteTx.map(peer => {
|
const txTo = danteTx.map(peer => {
|
||||||
const peerName = getShortLabel(peer.node);
|
const peerNode = nodesByTypeId.get(peer.node_id);
|
||||||
|
const peerName = peerNode ? getShortLabel(peerNode) : '??';
|
||||||
const channels = (peer.channels || []).map(formatDanteChannel);
|
const channels = (peer.channels || []).map(formatDanteChannel);
|
||||||
const channelSummary = channels.length > 0 ? '\n ' + channels.join('\n ') : '';
|
const channelSummary = channels.length > 0 ? '\n ' + channels.join('\n ') : '';
|
||||||
return peerName + channelSummary;
|
return peerName + channelSummary;
|
||||||
});
|
});
|
||||||
|
|
||||||
const rxFrom = danteRx.map(peer => {
|
const rxFrom = danteRx.map(peer => {
|
||||||
const peerName = getShortLabel(peer.node);
|
const peerNode = nodesByTypeId.get(peer.node_id);
|
||||||
|
const peerName = peerNode ? getShortLabel(peerNode) : '??';
|
||||||
const channels = (peer.channels || []).map(formatDanteChannel);
|
const channels = (peer.channels || []).map(formatDanteChannel);
|
||||||
const channelSummary = channels.length > 0 ? '\n ' + channels.join('\n ') : '';
|
const channelSummary = channels.length > 0 ? '\n ' + channels.join('\n ') : '';
|
||||||
return peerName + channelSummary;
|
return peerName + channelSummary;
|
||||||
@@ -2467,8 +2471,8 @@
|
|||||||
const switchLinks = [];
|
const switchLinks = [];
|
||||||
|
|
||||||
links.forEach(link => {
|
links.forEach(link => {
|
||||||
const nodeA = nodesByTypeId.get(link.node_a?.id);
|
const nodeA = nodesByTypeId.get(link.node_a_id);
|
||||||
const nodeB = nodesByTypeId.get(link.node_b?.id);
|
const nodeB = nodesByTypeId.get(link.node_b_id);
|
||||||
if (!nodeA || !nodeB) return;
|
if (!nodeA || !nodeB) return;
|
||||||
|
|
||||||
const aIsSwitch = isSwitch(nodeA);
|
const aIsSwitch = isSwitch(nodeA);
|
||||||
@@ -2478,18 +2482,18 @@
|
|||||||
upstreamConnections.set(nodeB.id, {
|
upstreamConnections.set(nodeB.id, {
|
||||||
switchName: getLabel(nodeA),
|
switchName: getLabel(nodeA),
|
||||||
port: link.interface_a || '?',
|
port: link.interface_a || '?',
|
||||||
speed: getInterfaceSpeed(link.node_a),
|
speed: getInterfaceSpeed(nodeA, link.interface_a),
|
||||||
errors: getInterfaceErrors(link.node_a),
|
errors: getInterfaceErrors(nodeA, link.interface_a),
|
||||||
rates: getInterfaceRates(link.node_a),
|
rates: getInterfaceRates(nodeA, link.interface_a),
|
||||||
isLocalPort: false
|
isLocalPort: false
|
||||||
});
|
});
|
||||||
} else if (bIsSwitch && !aIsSwitch) {
|
} else if (bIsSwitch && !aIsSwitch) {
|
||||||
upstreamConnections.set(nodeA.id, {
|
upstreamConnections.set(nodeA.id, {
|
||||||
switchName: getLabel(nodeB),
|
switchName: getLabel(nodeB),
|
||||||
port: link.interface_b || '?',
|
port: link.interface_b || '?',
|
||||||
speed: getInterfaceSpeed(link.node_b),
|
speed: getInterfaceSpeed(nodeB, link.interface_b),
|
||||||
errors: getInterfaceErrors(link.node_b),
|
errors: getInterfaceErrors(nodeB, link.interface_b),
|
||||||
rates: getInterfaceRates(link.node_b),
|
rates: getInterfaceRates(nodeB, link.interface_b),
|
||||||
isLocalPort: false
|
isLocalPort: false
|
||||||
});
|
});
|
||||||
} else if (aIsSwitch && bIsSwitch) {
|
} else if (aIsSwitch && bIsSwitch) {
|
||||||
@@ -2498,12 +2502,12 @@
|
|||||||
switchB: nodeB,
|
switchB: nodeB,
|
||||||
portA: link.interface_a || '?',
|
portA: link.interface_a || '?',
|
||||||
portB: link.interface_b || '?',
|
portB: link.interface_b || '?',
|
||||||
speedA: getInterfaceSpeed(link.node_a),
|
speedA: getInterfaceSpeed(nodeA, link.interface_a),
|
||||||
speedB: getInterfaceSpeed(link.node_b),
|
speedB: getInterfaceSpeed(nodeB, link.interface_b),
|
||||||
errorsA: getInterfaceErrors(link.node_a),
|
errorsA: getInterfaceErrors(nodeA, link.interface_a),
|
||||||
errorsB: getInterfaceErrors(link.node_b),
|
errorsB: getInterfaceErrors(nodeB, link.interface_b),
|
||||||
ratesA: getInterfaceRates(link.node_a),
|
ratesA: getInterfaceRates(nodeA, link.interface_a),
|
||||||
ratesB: getInterfaceRates(link.node_b)
|
ratesB: getInterfaceRates(nodeB, link.interface_b)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -2596,13 +2600,16 @@
|
|||||||
|
|
||||||
function renderDanteTable() {
|
function renderDanteTable() {
|
||||||
const nodes = tableData.nodes || [];
|
const nodes = tableData.nodes || [];
|
||||||
|
const nodesByTypeId = new Map();
|
||||||
|
nodes.forEach(node => nodesByTypeId.set(node.id, node));
|
||||||
let rows = [];
|
let rows = [];
|
||||||
nodes.forEach(node => {
|
nodes.forEach(node => {
|
||||||
const name = getLabel(node);
|
const name = getLabel(node);
|
||||||
const tx = node.dante_flows?.tx || [];
|
const tx = node.dante_flows?.tx || [];
|
||||||
const rx = node.dante_flows?.rx || [];
|
const rx = node.dante_flows?.rx || [];
|
||||||
tx.forEach(peer => {
|
tx.forEach(peer => {
|
||||||
const peerName = getLabel(peer.node);
|
const peerNode = nodesByTypeId.get(peer.node_id);
|
||||||
|
const peerName = peerNode ? getLabel(peerNode) : '??';
|
||||||
(peer.channels || []).forEach(ch => {
|
(peer.channels || []).forEach(ch => {
|
||||||
rows.push({
|
rows.push({
|
||||||
source: name,
|
source: name,
|
||||||
|
|||||||
Reference in New Issue
Block a user