From 2c27ce7ff54ad42cdd8bc82650dd7e5d7b80aaae Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 30 Jan 2026 22:19:22 -0800 Subject: [PATCH] Use first name only in protocol hover cards Co-Authored-By: Claude Opus 4.5 --- static/js/nodes.js | 13 +++++++++++++ static/js/render.js | 10 +++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/static/js/nodes.js b/static/js/nodes.js index 86d6964..6ef9ee9 100644 --- a/static/js/nodes.js +++ b/static/js/nodes.js @@ -32,6 +32,19 @@ export function getShortLabel(node) { return '??'; } +export function getFirstName(node) { + if (node.names && node.names.length > 0) return node.names[0]; + if (node.interfaces && node.interfaces.length > 0) { + for (const iface of node.interfaces) { + if (iface.ips && iface.ips.length > 0) return iface.ips[0]; + } + for (const iface of node.interfaces) { + if (iface.mac) return iface.mac; + } + } + return '??'; +} + export function getNodeIdentifiers(node) { const ids = []; if (node.names) { diff --git a/static/js/render.js b/static/js/render.js index 7b74cc3..b6ff871 100644 --- a/static/js/render.js +++ b/static/js/render.js @@ -1,4 +1,4 @@ -import { getLabel, getShortLabel, isSwitch, getInterfaceSpeed, getInterfaceErrors, getInterfaceRates } from './nodes.js'; +import { getLabel, getShortLabel, isSwitch, getInterfaceSpeed, getInterfaceErrors, getInterfaceRates, getFirstName } from './nodes.js'; import { buildSwitchUplinks, buildLocationTree, buildNodeIndex, findLocationForNode, findEffectiveSwitch } from './topology.js'; import { formatUniverse } from './format.js'; import { createNodeElement, renderLocation } from './components.js'; @@ -120,7 +120,7 @@ export function render(data, config) { const txEntries = danteTx.map(peer => { const peerNode = nodesByTypeId.get(peer.node_id); - const peerName = peerNode ? getShortLabel(peerNode) : '??'; + const peerName = peerNode ? getFirstName(peerNode) : '??'; const channels = (peer.channels || []).map(formatDanteChannel); const channelSummary = channels.length > 0 ? '\n ' + channels.join('\n ') : ''; return { text: peerName + channelSummary, peerId: peer.node_id }; @@ -128,7 +128,7 @@ export function render(data, config) { const rxEntries = danteRx.map(peer => { const peerNode = nodesByTypeId.get(peer.node_id); - const peerName = peerNode ? getShortLabel(peerNode) : '??'; + const peerName = peerNode ? getFirstName(peerNode) : '??'; const channels = (peer.channels || []).map(formatDanteChannel); const channelSummary = channels.length > 0 ? '\n ' + channels.join('\n ') : ''; return { text: peerName + channelSummary, peerId: peer.node_id }; @@ -153,7 +153,7 @@ export function render(data, config) { const universeOutputs = new Map(); nodes.forEach(node => { - const name = getShortLabel(node); + const name = getFirstName(node); (node.artnet_inputs || []).forEach(u => { if (!universeInputs.has(u)) universeInputs.set(u, []); universeInputs.get(u).push(name); @@ -225,7 +225,7 @@ export function render(data, config) { } nodes.forEach(node => { - const name = getShortLabel(node); + const name = getFirstName(node); getSacnInputs(node).forEach(u => { if (!sacnUniverseInputs.has(u)) sacnUniverseInputs.set(u, []); sacnUniverseInputs.get(u).push(name);