Use first name only in protocol hover cards

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-01-30 22:19:22 -08:00
parent a0e71d2347
commit 2c27ce7ff5
2 changed files with 18 additions and 5 deletions

View File

@@ -32,6 +32,19 @@ export function getShortLabel(node) {
return '??'; 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) { export function getNodeIdentifiers(node) {
const ids = []; const ids = [];
if (node.names) { if (node.names) {

View File

@@ -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 { buildSwitchUplinks, buildLocationTree, buildNodeIndex, findLocationForNode, findEffectiveSwitch } from './topology.js';
import { formatUniverse } from './format.js'; import { formatUniverse } from './format.js';
import { createNodeElement, renderLocation } from './components.js'; import { createNodeElement, renderLocation } from './components.js';
@@ -120,7 +120,7 @@ export function render(data, config) {
const txEntries = danteTx.map(peer => { const txEntries = danteTx.map(peer => {
const peerNode = nodesByTypeId.get(peer.node_id); const peerNode = nodesByTypeId.get(peer.node_id);
const peerName = peerNode ? getShortLabel(peerNode) : '??'; const peerName = peerNode ? getFirstName(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 { text: peerName + channelSummary, peerId: peer.node_id }; return { text: peerName + channelSummary, peerId: peer.node_id };
@@ -128,7 +128,7 @@ export function render(data, config) {
const rxEntries = danteRx.map(peer => { const rxEntries = danteRx.map(peer => {
const peerNode = nodesByTypeId.get(peer.node_id); const peerNode = nodesByTypeId.get(peer.node_id);
const peerName = peerNode ? getShortLabel(peerNode) : '??'; const peerName = peerNode ? getFirstName(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 { text: peerName + channelSummary, peerId: peer.node_id }; return { text: peerName + channelSummary, peerId: peer.node_id };
@@ -153,7 +153,7 @@ export function render(data, config) {
const universeOutputs = new Map(); const universeOutputs = new Map();
nodes.forEach(node => { nodes.forEach(node => {
const name = getShortLabel(node); const name = getFirstName(node);
(node.artnet_inputs || []).forEach(u => { (node.artnet_inputs || []).forEach(u => {
if (!universeInputs.has(u)) universeInputs.set(u, []); if (!universeInputs.has(u)) universeInputs.set(u, []);
universeInputs.get(u).push(name); universeInputs.get(u).push(name);
@@ -225,7 +225,7 @@ export function render(data, config) {
} }
nodes.forEach(node => { nodes.forEach(node => {
const name = getShortLabel(node); const name = getFirstName(node);
getSacnInputs(node).forEach(u => { getSacnInputs(node).forEach(u => {
if (!sacnUniverseInputs.has(u)) sacnUniverseInputs.set(u, []); if (!sacnUniverseInputs.has(u)) sacnUniverseInputs.set(u, []);
sacnUniverseInputs.get(u).push(name); sacnUniverseInputs.get(u).push(name);