diff --git a/internal/console/public/app.js b/internal/console/public/app.js index 91864650..b11f55fe 100644 --- a/internal/console/public/app.js +++ b/internal/console/public/app.js @@ -244,6 +244,7 @@ async function loadData() { setTableMessage('table-enrollments', 4, 'Restricted to administrators.'); } renderNodesTable(data.enrolled_nodes || []); + renderServicesTable(data.node_catalog || {}, buildLabelsByPeer(data.enrolled_nodes || [])); renderRoutersTable(data.active_routers || []); renderRouterTopography(data.active_routers || []); renderBootstrapTokensTable(data.bootstrap_tokens || []); @@ -332,16 +333,49 @@ function renderUsersTable(users) { `).join(''); } +// Renders an operator-declared labels map (e.g. {component: "stvv", role: +// "producer"}, from sam-node.yaml's labels: key) as a compact key=value +// list - the closest thing to a node mnemonic that exists today, since SAM +// has no dedicated name/alias field. Returns '' if there are none. +function formatLabels(labels) { + const entries = Object.entries(labels || {}); + if (entries.length === 0) { + return ''; + } + return entries.map(([k, v]) => `${k}=${v}`).join(', '); +} + +// A peer ID cell: the raw ID (still the real, authoritative identifier) +// with its operator-declared labels shown underneath when present. +function peerCell(peerID, labels) { + const labelText = formatLabels(labels); + const sub = labelText + ? `
${escapeHTML(peerID)}${sub}`;
+}
+
+// Builds a peer ID -> labels lookup from the enrolled_nodes list, so other
+// tables (e.g. Services) can show the same labels next to a bare peer ID
+// without a second fetch.
+function buildLabelsByPeer(nodes) {
+ const byPeer = {};
+ for (const node of nodes || []) {
+ byPeer[node.PeerID] = node.Labels || {};
+ }
+ return byPeer;
+}
+
function renderNodesTable(nodes) {
const tbody = document.getElementById('table-nodes');
if (nodes.length === 0) {
tbody.innerHTML = `${escapeHTML(node.PeerID)}| Service | +Type | +Description | +Node ID | +Reported At | +
|---|---|---|---|---|
| Loading... | ||||