Display Art-Net universes as x:y:z (n) format consistently

This commit is contained in:
Ian Gulliver
2026-02-04 09:27:46 -08:00
parent 8769afd17d
commit 08e8a523d0
6 changed files with 60 additions and 52 deletions

View File

@@ -1,5 +1,6 @@
import { getShortLabel, getFirstName, isSwitch, findInterface } from './nodes.js';
import { flowViewData, currentMode, currentView } from './state.js';
import { formatUniverse, formatArtmapAddr } from './format.js';
function scrollToNode(typeid) {
const nodeEl = document.querySelector('.node[data-id="' + typeid + '"]');
@@ -124,6 +125,7 @@ export function showFlowView(flowSpec) {
const universe = parseInt(parts[1], 10);
const sourceIdent = parts[2];
const protoName = protocol === 'sacn' ? 'sACN' : 'Art-Net';
const universeDisplay = formatUniverse(universe, protocol);
flowUniverse = universe;
flowProtocol = protocol;
if (isNaN(universe)) { error = 'Invalid universe'; }
@@ -152,7 +154,7 @@ export function showFlowView(flowSpec) {
const isDest = destIds.includes(clickedNodeId);
if (isSource) {
const destNames = destIds.filter(id => id !== clickedNodeId).map(id => getFirstName(nodesByTypeId.get(id))).join(', ');
title = protoName + ' ' + universe + ': ' + getFirstName(clickedNode) + ' → ' + (destNames || '?');
title = protoName + ' ' + universeDisplay + ': ' + getFirstName(clickedNode) + ' → ' + (destNames || '?');
destIds.forEach(destId => {
if (destId !== clickedNodeId) {
const path = findPath(graph, clickedNodeId, destId);
@@ -161,7 +163,7 @@ export function showFlowView(flowSpec) {
});
} else if (isDest) {
const sourceNames = sourceIds.map(id => getFirstName(nodesByTypeId.get(id))).join(', ');
title = protoName + ' ' + universe + ': ' + (sourceNames || '?') + ' → ' + getFirstName(clickedNode);
title = protoName + ' ' + universeDisplay + ': ' + (sourceNames || '?') + ' → ' + getFirstName(clickedNode);
sourceIds.forEach(sourceId => {
const path = findPath(graph, sourceId, clickedNodeId);
if (path) paths.push({ path, sourceId, destId: clickedNodeId });
@@ -171,7 +173,7 @@ export function showFlowView(flowSpec) {
}
}
} else {
title = protoName + ' Universe ' + universe;
title = protoName + ' Universe ' + universeDisplay;
sourceIds.forEach(sourceId => {
destIds.forEach(destId => {
if (sourceId !== destId) {
@@ -344,31 +346,26 @@ export function renderFlowPath(pathInfo, nodesByTypeId, flowUniverse, flowProtoc
mappingsEl = document.createElement('div');
mappingsEl.className = 'flow-artmap-mappings';
if (isSourceNode) mappingsEl.classList.add('before-node');
const currentPrefix = flowProtocol + ':' + flowUniverse;
const nodeName = getFirstName(node);
relevantMappings.forEach(m => {
const mappingEl = document.createElement('div');
mappingEl.className = 'artmap-mapping';
const fromSpan = document.createElement('span');
fromSpan.className = 'from';
fromSpan.textContent = m.from;
fromSpan.textContent = formatArtmapAddr(m.from);
const arrowSpan = document.createElement('span');
arrowSpan.textContent = '→';
const toSpan = document.createElement('span');
toSpan.className = 'to';
toSpan.textContent = m.to;
toSpan.textContent = formatArtmapAddr(m.to);
mappingEl.appendChild(fromSpan);
mappingEl.appendChild(arrowSpan);
mappingEl.appendChild(toSpan);
mappingEl.addEventListener('click', (e) => {
e.stopPropagation();
const fromBase = m.from.split(':').slice(0, 2).join(':');
const target = fromBase === currentPrefix ? m.to : m.from;
const targetProto = target.split(':')[0];
const targetUniverse = parseInt(target.split(':')[1], 10);
if (!isNaN(targetUniverse)) {
openFlowHash(targetProto, targetUniverse, nodeName);
}
const fromMatches = m.from.protocol === flowProtocol && m.from.universe === flowUniverse;
const target = fromMatches ? m.to : m.from;
openFlowHash(target.protocol, target.universe, nodeName);
});
mappingsEl.appendChild(mappingEl);
});
@@ -388,11 +385,10 @@ export function renderFlowPath(pathInfo, nodesByTypeId, flowUniverse, flowProtoc
}
function getRelevantMappings(mappings, protocol, universe) {
const prefix = protocol + ':' + universe;
return mappings.filter(m => {
const fromBase = m.from.split(':').slice(0, 2).join(':');
const toBase = m.to.split(':').slice(0, 2).join(':');
return fromBase === prefix || toBase === prefix;
const fromMatches = m.from.protocol === protocol && m.from.universe === universe;
const toMatches = m.to.protocol === protocol && m.to.universe === universe;
return fromMatches || toMatches;
});
}