From f19dc44b9f38cd2d2a96c53dadb75013a800149d Mon Sep 17 00:00:00 2001 From: Robert Chacon Date: Sat, 21 Mar 2026 03:30:32 -0600 Subject: [PATCH] changes --- docs-es/v2.0/node-manager-ui-es.md | 10 +- docs/v2.0/node-manager-ui.md | 10 +- .../src/node_manager/js_build/src/tree.js | 570 +++++++++++++++--- .../src/node_manager/static2/node_manager.css | 269 ++++++++- .../lqosd/src/node_manager/static2/tree.html | 210 ++++--- 5 files changed, 867 insertions(+), 202 deletions(-) diff --git a/docs-es/v2.0/node-manager-ui-es.md b/docs-es/v2.0/node-manager-ui-es.md index 49742a8b..687995c3 100644 --- a/docs-es/v2.0/node-manager-ui-es.md +++ b/docs-es/v2.0/node-manager-ui-es.md @@ -14,12 +14,16 @@ Esta página documenta las vistas clave de la WebUI (Node Manager) y su comporta - Las páginas de detalle del árbol ahora muestran una ruta tipo breadcrumb hasta el nodo seleccionado, para navegar hacia abajo sin depender de volver siempre a la raíz. - Las filas del árbol ahora incluyen resúmenes del subárbol para `Sites` descendientes y `Circuits` adjuntos/descendientes, lo que ayuda a estimar el tamaño de cada rama antes de expandirla. - Las filas del árbol y el encabezado del nodo seleccionado pueden mostrar pequeños íconos de estado para manejo especial, incluyendo nodos virtuales y nodos administrados actualmente por StormGuard. -- Las páginas de detalle del árbol incluyen un inspector de `Node Settings` que muestra: +- Las páginas de detalle del árbol incluyen una tarjeta de `Node Details` que muestra: + - el tipo de nodo y el tamaño de la rama del nodo seleccionado - la velocidad configurada base desde el `network.json` generado - cualquier override de velocidad del operador almacenado en `lqos_overrides.json` - la velocidad configurada efectiva actual -- Los administradores pueden guardar o limpiar overrides de velocidad del nodo desde ese inspector. Los usuarios de solo lectura siguen pudiendo inspeccionar los valores, pero los controles permanecen deshabilitados. -- Los overrides de velocidad desde el árbol requieren un ID estable del nodo y rechazan intencionalmente nodos generados. Cuando un override ya fue guardado pero todavía no fue materializado en el `network.json` generado, el inspector muestra un indicador `⟳ Pending` explicando que el cambio se aplicará en la siguiente ejecución del scheduler. +- Las páginas de detalle del árbol también incluyen una barra de contexto compacta, un panel de medidores `Node Snapshot` y un indicador de advertencia de compatibilidad junto a `Operator Override` cuando existen avisos de compatibilidad relacionados con overrides de integraciones. +- Las páginas de detalle del árbol ahora incluyen un localizador estable del nodo en la URL cuando está disponible y vuelven a resolver el nodo seleccionado ante reindexaciones en vivo del árbol, para que permanecer en una página siga el mismo nodo lógico después de regenerar `network.json`. +- Los administradores pueden guardar o limpiar overrides de velocidad del nodo desde el editor `Operator Override` cuando el nodo seleccionado es editable. Los usuarios de solo lectura y los nodos no editables siguen viendo los valores actuales en la tarjeta de detalles. +- El nodo sintético `Root` se muestra como un agregado de solo lectura y no expone el editor `Operator Override`. +- Los overrides de velocidad desde el árbol requieren un ID estable del nodo y rechazan intencionalmente nodos generados. Cuando un override ya fue guardado pero todavía no fue materializado en el `network.json` generado, la tarjeta de detalles muestra un indicador `⟳ Pending` explicando que el cambio se aplicará en la siguiente ejecución del scheduler. - El control de pausa del Sankey de árbol completo ahora solo detiene el polling; el drill-down local, el reset y los cambios de profundidad máxima siguen renderizando desde el snapshot en caché mientras está en pausa. ### Site Map diff --git a/docs/v2.0/node-manager-ui.md b/docs/v2.0/node-manager-ui.md index eb731832..102cf010 100644 --- a/docs/v2.0/node-manager-ui.md +++ b/docs/v2.0/node-manager-ui.md @@ -14,12 +14,16 @@ This page documents key WebUI (Node Manager) views and operational behavior in t - Tree detail pages now show a breadcrumb path to the selected node, so drilling down does not require repeated resets back to root. - Tree rows include subtree summaries for descendant `Sites` plus attached/descendant `Circuits`, which helps estimate branch size before expanding further. - Tree rows and the selected-node header can show small status icons for special handling, including virtual nodes and nodes currently managed by StormGuard. -- Tree detail pages include a `Node Settings` inspector that shows: +- Tree detail pages include a `Node Details` card that shows: + - node type and branch size for the selected tree node - base configured rate from generated `network.json` - any operator-owned rate override from `lqos_overrides.json` - current effective configured rate -- Administrators can save or clear node rate overrides from that inspector. Read-only users can still inspect the values, but the controls remain disabled. -- Tree node rate overrides require a stable node ID and intentionally refuse generated nodes. When an override has been saved but not yet materialized into generated `network.json`, the inspector shows a `⟳ Pending` indicator explaining that the change will apply on the next scheduler run. +- Tree detail pages also include a compact context bar, a `Node Snapshot` gauge panel, and a compatibility warning indicator beside `Operator Override` when integration-related override compatibility notices are present. +- Tree detail pages now carry a stable node locator in the URL when available and re-resolve the selected node across live tree reindexing, so staying on a node page continues to follow the same logical node after `network.json` regenerates. +- Administrators can save or clear node rate overrides from the `Operator Override` editor when the selected node is editable. Read-only users and non-editable nodes still see the current values in the details card. +- The synthetic `Root` node is shown as a read-only aggregate and does not expose the `Operator Override` editor. +- Tree node rate overrides require a stable node ID and intentionally refuse generated nodes. When an override has been saved but not yet materialized into generated `network.json`, the details card shows a `⟳ Pending` indicator explaining that the change will apply on the next scheduler run. - The full-tree Sankey pause control now freezes polling only; local drill-down, reset, and max-depth changes continue to rerender from the cached snapshot while paused. ### Site Map diff --git a/src/rust/lqosd/src/node_manager/js_build/src/tree.js b/src/rust/lqosd/src/node_manager/js_build/src/tree.js index 5bd3cb57..068126fe 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/tree.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/tree.js @@ -6,6 +6,8 @@ import { formatThroughput, } from "./helpers/scaling"; import {colorByQoqScore} from "./helpers/color_scales"; +import {BitsPerSecondGauge} from "./graphs/bits_gauge"; +import {QooScoreGauge} from "./graphs/qoo_score_gauge"; import {enableTooltipsWithin} from "./lq_js_common/helpers/tooltips"; import {scaleNumber, toNumber} from "./lq_js_common/helpers/scaling"; import {get_ws_client, subscribeWS} from "./pubsub/ws"; @@ -17,6 +19,15 @@ var subscribed = false; var expandedNodes = new Set(); var childrenByParentId = new Map(); var stormguardNodes = new Set(); +var treeBitsGauge = null; +var treeQooGauge = null; +var lastClientsMessage = null; +var currentSelectionIdentity = null; +var selectionLocator = { + nodeId: null, + nodePath: null, + lastKnownIndex: 0, +}; var nodeRateOverrideState = { loading: false, saving: false, @@ -114,6 +125,28 @@ function formatIpBytes(bytes) { return list.join("."); } +function abbreviateIpForTable(ipText) { + if (typeof ipText !== "string") { + return String(ipText ?? ""); + } + if (!ipText.includes(":")) { + return ipText; + } + const groups = ipText.split(":").filter((group) => group.length > 0); + if (groups.length <= 3) { + return ipText; + } + return `${groups.slice(0, 3).join(":")}:...`; +} + +function summarizeIpListForTable(ipList) { + const displayList = ipList.map((entry) => abbreviateIpForTable(entry)); + if (displayList.length > 2) { + return `${displayList[0]}, ${displayList[1]} +${displayList.length - 2}`; + } + return displayList.join(", "); +} + function configuredMax(node) { return node.configured_max_throughput || node.max_throughput || [0, 0]; } @@ -153,6 +186,13 @@ function formatRatePair(downMbps, upMbps) { return `${formatLimitValue(downMbps)} / ${formatLimitValue(upMbps)}`; } +function isSyntheticRootNode(node) { + return !!node + && (node.id === null || node.id === undefined) + && node.immediate_parent === null + && node.name === "Root"; +} + function currentNode() { return tree && tree[parent] ? tree[parent][1] : null; } @@ -204,31 +244,25 @@ function subtreeCircuitCount(node) { return toNumber(node.subtree_circuit_count, 0); } -function nodeDetailParts(node) { +function branchSizeParts(node) { const parts = []; - if (node.type !== null && node.type !== undefined && node.type !== "") { - parts.push(node.type); - } const circuitCount = subtreeCircuitCount(node); if (circuitCount > 0) { - parts.push(`Circuits ${circuitCount}`); + parts.push(`${circuitCount} ${circuitCount === 1 ? "circuit" : "circuits"}`); } const siteCount = subtreeSiteCount(node); if (siteCount > 0) { - parts.push(`Sites ${siteCount}`); + parts.push(`${siteCount} ${siteCount === 1 ? "site" : "sites"}`); } return parts; } -function appendNodeDetailText(target, node) { - const parts = nodeDetailParts(node); +function formatBranchSize(node) { + const parts = branchSizeParts(node); if (parts.length === 0) { - return; + return "No descendant sites or circuits"; } - const detail = document.createElement("span"); - detail.classList.add("text-body-secondary"); - detail.textContent = ` (${parts.join(", ")})`; - target.appendChild(detail); + return parts.join(" / "); } function buildStatusIcon(iconName, textClass, title) { @@ -245,7 +279,7 @@ function isStormguardNode(node) { } function renderHeaderStatusIcons(node) { - const target = document.getElementById("nodeNameIcons"); + const target = document.getElementById("nodeStateBadges"); if (!target) { return; } @@ -282,8 +316,206 @@ function sameStringSet(a, b) { return true; } -function treeHref(nodeId) { - return `/tree.html?parent=${nodeId}`; +function normalizeNodePath(path) { + if (!Array.isArray(path)) { + return null; + } + const normalized = path + .map((entry) => typeof entry === "string" ? entry : String(entry ?? "")) + .filter((entry) => entry.length > 0); + return normalized.length > 0 ? normalized : null; +} + +function parseNodePathParam(rawPath) { + if (typeof rawPath !== "string" || rawPath.length === 0) { + return null; + } + try { + return normalizeNodePath(JSON.parse(rawPath)); + } catch (_error) { + return null; + } +} + +function pathEquals(left, right) { + if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) { + return false; + } + for (let i = 0; i < left.length; i++) { + if (left[i] !== right[i]) { + return false; + } + } + return true; +} + +function getNodePathNames(nodeId, node = tree?.[nodeId]?.[1]) { + if (!node) { + return null; + } + if (isSyntheticRootNode(node)) { + return ["Root"]; + } + const parentIndexes = Array.isArray(node.parents) && node.parents.length > 0 + ? node.parents + : [nodeId]; + const names = []; + for (const idx of parentIndexes) { + const entry = tree?.[idx]; + if (!entry || !entry[1] || typeof entry[1].name !== "string" || entry[1].name.length === 0) { + return normalizeNodePath([node.name]); + } + names.push(entry[1].name); + } + if (names.length === 0 || names[names.length - 1] !== node.name) { + names.push(node.name); + } + return normalizeNodePath(names); +} + +function selectionIdentityForNode(nodeId, node = tree?.[nodeId]?.[1]) { + if (!node) { + return null; + } + if (typeof node.id === "string" && node.id.length > 0) { + return `id:${node.id}`; + } + const nodePath = getNodePathNames(nodeId, node); + if (nodePath) { + return `path:${JSON.stringify(nodePath)}`; + } + return `index:${nodeId}`; +} + +function syncBrowserUrlToSelection() { + if (typeof window === "undefined" || typeof history === "undefined") { + return; + } + const url = new URL(window.location.href); + url.searchParams.set("parent", String(parent)); + if (selectionLocator.nodeId) { + url.searchParams.set("nodeId", selectionLocator.nodeId); + } else { + url.searchParams.delete("nodeId"); + } + if (selectionLocator.nodePath) { + url.searchParams.set("nodePath", JSON.stringify(selectionLocator.nodePath)); + } else { + url.searchParams.delete("nodePath"); + } + const nextUrl = `${url.pathname}?${url.searchParams.toString()}${url.hash}`; + const currentUrl = `${window.location.pathname}${window.location.search}${window.location.hash}`; + if (nextUrl !== currentUrl) { + history.replaceState(null, "", nextUrl); + } +} + +function rememberSelection(nodeId, node = tree?.[nodeId]?.[1]) { + if (!node) { + return false; + } + const nextIdentity = selectionIdentityForNode(nodeId, node); + const identityChanged = currentSelectionIdentity !== nextIdentity; + currentSelectionIdentity = nextIdentity; + selectionLocator.nodeId = typeof node.id === "string" && node.id.length > 0 ? node.id : null; + selectionLocator.nodePath = getNodePathNames(nodeId, node); + selectionLocator.lastKnownIndex = nodeId; + syncBrowserUrlToSelection(); + return identityChanged; +} + +function findNodeIndexByStableId(nodeId) { + if (!tree || typeof nodeId !== "string" || nodeId.length === 0) { + return null; + } + for (let i = 0; i < tree.length; i++) { + const node = tree[i]?.[1]; + if (node?.id === nodeId) { + return i; + } + } + return null; +} + +function findNodeIndexByPath(nodePath) { + if (!tree || !Array.isArray(nodePath) || nodePath.length === 0) { + return null; + } + for (let i = 0; i < tree.length; i++) { + const node = tree[i]?.[1]; + if (!node) { + continue; + } + if (pathEquals(getNodePathNames(i, node), nodePath)) { + return i; + } + } + return null; +} + +function resolveSelectedParentIndex() { + const byStableId = findNodeIndexByStableId(selectionLocator.nodeId); + if (byStableId !== null) { + return byStableId; + } + const byPath = findNodeIndexByPath(selectionLocator.nodePath); + if (byPath !== null) { + return byPath; + } + if (Number.isInteger(selectionLocator.lastKnownIndex) && tree?.[selectionLocator.lastKnownIndex] !== undefined) { + return selectionLocator.lastKnownIndex; + } + if (tree?.[parent] !== undefined) { + return parent; + } + if (tree?.[0] !== undefined) { + return 0; + } + return null; +} + +function reconcileSelection() { + const resolvedParent = resolveSelectedParentIndex(); + if (resolvedParent === null) { + return {parentChanged: false, identityChanged: false}; + } + const previousParent = parent; + parent = resolvedParent; + const identityChanged = rememberSelection(parent); + return { + parentChanged: previousParent !== parent, + identityChanged, + }; +} + +function treeHref(nodeId, node = tree?.[nodeId]?.[1]) { + const params = new URLSearchParams(); + params.set("parent", String(nodeId)); + if (node?.id) { + params.set("nodeId", node.id); + } + const nodePath = getNodePathNames(nodeId, node); + if (nodePath) { + params.set("nodePath", JSON.stringify(nodePath)); + } + return `/tree.html?${params.toString()}`; +} + +function formatTreeCount(value) { + const numeric = toNumber(value, 0); + return numeric > 0 ? String(numeric) : "-"; +} + +function buildTreeRowStatusIcon(iconName, isActive, activeTitle, inactiveTitle) { + const icon = document.createElement("i"); + icon.classList.add("fa", "fa-fw", iconName, "lqos-tree-row-status-icon"); + if (!isActive) { + icon.classList.add("is-inactive"); + } + icon.setAttribute("data-bs-toggle", "tooltip"); + icon.setAttribute("data-bs-placement", "top"); + icon.setAttribute("title", isActive ? activeTitle : inactiveTitle); + return icon; } function renderBreadcrumb() { @@ -300,12 +532,13 @@ function renderBreadcrumb() { const path = Array.isArray(current.parents) && current.parents.length > 0 ? current.parents : [parent]; + const ancestors = path.slice(0, -1); const navWrap = document.createElement("div"); navWrap.classList.add("lqos-tree-nav"); const trail = document.createElement("div"); trail.classList.add("lqos-tree-breadcrumb"); - path.forEach((nodeId, index) => { + ancestors.forEach((nodeId, index) => { const entry = tree[nodeId]; if (!entry || !entry[1]) { return; @@ -316,25 +549,57 @@ function renderBreadcrumb() { separator.innerHTML = ""; trail.appendChild(separator); } - - if (index === path.length - 1) { - const currentNode = document.createElement("span"); - currentNode.classList.add("lqos-tree-breadcrumb-current", "redactable"); - currentNode.textContent = entry[1].name; - trail.appendChild(currentNode); - } else { - const link = document.createElement("a"); - link.href = treeHref(nodeId); - link.classList.add("lqos-tree-breadcrumb-link", "redactable"); - link.textContent = entry[1].name; - trail.appendChild(link); - } + const link = document.createElement("a"); + link.href = treeHref(nodeId, entry[1]); + link.classList.add("lqos-tree-breadcrumb-link", "redactable"); + link.textContent = entry[1].name; + trail.appendChild(link); }); + if (ancestors.length > 0) { + const separator = document.createElement("span"); + separator.classList.add("lqos-tree-breadcrumb-separator"); + separator.innerHTML = ""; + trail.appendChild(separator); + } + + const currentNode = document.createElement("span"); + currentNode.classList.add("lqos-tree-breadcrumb-current", "redactable"); + currentNode.textContent = current.name; + trail.appendChild(currentNode); + navWrap.appendChild(trail); target.appendChild(navWrap); } +function renderContextMeta(node) { + const target = document.getElementById("treeContextMeta"); + if (!target) { + return; + } + clearDiv(target); + if (!node) { + return; + } + + const metaItems = []; + if (node.type) { + metaItems.push(node.type); + } + const branchSize = formatBranchSize(node); + if (branchSize) { + metaItems.push(branchSize); + } + metaItems.push(`Max ${formatRatePair(...effectiveMax(node))}`); + + metaItems.forEach((text) => { + const pill = document.createElement("span"); + pill.classList.add("lqos-tree-context-pill"); + pill.textContent = text; + target.appendChild(pill); + }); +} + function setNodeOverrideFlash(message, variant = "success") { nodeRateOverrideState.flash = message ? {message, variant} : null; renderNodeSettings(); @@ -357,6 +622,44 @@ function renderAlertMessages(targetId, messages, variant) { }); } +function escapeHtml(text) { + return String(text) + .replaceAll("&", "&") + .replaceAll("<", "<") + .replaceAll(">", ">") + .replaceAll('"', """) + .replaceAll("'", "'"); +} + +function renderCompatibilityWarningsIndicator(messages) { + const target = document.getElementById("nodeOverrideCompatibilityIndicator"); + if (!target) { + return; + } + const visibleMessages = Array.isArray(messages) ? messages.filter(Boolean) : []; + const nextSignature = JSON.stringify(visibleMessages); + if (target.dataset.warningSignature === nextSignature) { + return; + } + target.dataset.warningSignature = nextSignature; + clearDiv(target); + if (visibleMessages.length === 0) { + return; + } + const tooltipHtml = visibleMessages + .map((message) => `
${escapeHtml(message)}
`) + .join(""); + const icon = document.createElement("span"); + icon.classList.add("lqos-tree-compat-indicator"); + icon.setAttribute("data-bs-toggle", "tooltip"); + icon.setAttribute("data-bs-placement", "top"); + icon.setAttribute("data-bs-html", "true"); + icon.setAttribute("title", tooltipHtml); + icon.setAttribute("aria-label", `Compatibility warnings: ${visibleMessages.length}`); + icon.innerHTML = `${visibleMessages.length}`; + target.appendChild(icon); +} + function currentOverridePair(node, overrideData) { const base = configuredMax(node); return [ @@ -428,13 +731,14 @@ function renderOverrideValue(node, overrideData) { if (!target) { return; } + target.textContent = ""; clearDiv(target); const wrap = document.createElement("span"); - wrap.classList.add("lqos-tree-settings-value"); + wrap.classList.add("lqos-tree-detail-value"); const value = document.createElement("span"); if (!overrideData || !overrideData.has_override) { - value.textContent = "None"; + value.textContent = "- / -"; wrap.appendChild(value); target.appendChild(wrap); return; @@ -470,6 +774,7 @@ function renderNodeSettings() { if (!node) { return; } + const syntheticRoot = isSyntheticRootNode(node); const statusTarget = document.getElementById("nodeOverrideStatus"); if (statusTarget) { @@ -488,9 +793,9 @@ function renderNodeSettings() { if (typeTarget) { typeTarget.textContent = node.type ?? "-"; } - const nodeIdTarget = document.getElementById("nodeSettingsNodeId"); - if (nodeIdTarget) { - nodeIdTarget.textContent = node.id ?? "Unavailable"; + const branchSizeTarget = document.getElementById("nodeSettingsBranchSize"); + if (branchSizeTarget) { + branchSizeTarget.textContent = formatBranchSize(node); } const baseConfiguredTarget = document.getElementById("nodeSettingsBaseConfigured"); if (baseConfiguredTarget) { @@ -510,14 +815,11 @@ function renderNodeSettings() { nodeRateOverrideState.flash ? [nodeRateOverrideState.flash.message] : [], nodeRateOverrideState.flash ? nodeRateOverrideState.flash.variant : "success", ); - renderAlertMessages( - "nodeOverrideLegacyWarnings", - nodeRateOverrideState.data?.legacy_warnings || [], - "warning", - ); + renderCompatibilityWarningsIndicator(nodeRateOverrideState.data?.legacy_warnings || []); + const disabledReason = syntheticRoot ? null : nodeRateOverrideState.data?.disabled_reason; renderAlertMessages( "nodeOverrideDisabledReason", - nodeRateOverrideState.data?.disabled_reason ? [nodeRateOverrideState.data.disabled_reason] : [], + disabledReason ? [disabledReason] : [], "secondary", ); @@ -525,14 +827,18 @@ function renderNodeSettings() { const canEdit = !!nodeRateOverrideState.data?.can_edit && !nodeRateOverrideState.loading && !nodeRateOverrideState.saving; setNodeOverrideInputsDisabled(!canEdit); + const editorSection = document.getElementById("nodeOverrideEditorSection"); + if (editorSection) { + editorSection.hidden = !canEdit; + } const clearButton = document.getElementById("nodeOverrideClear"); if (clearButton) { clearButton.disabled = !canEdit || !nodeRateOverrideState.data?.has_override; } - const settingsCard = document.querySelector(".lqos-tree-settings-card"); - if (settingsCard) { - enableTooltipsWithin(settingsCard); + const detailsPanel = document.querySelector(".lqos-tree-details-panel"); + if (detailsPanel) { + enableTooltipsWithin(detailsPanel); } } @@ -658,9 +964,49 @@ function formatQooScore(score0to100, fallback = "-") { return "■" + clamped; } +function representativeNodeQoo(node) { + if (!node || !node.qoo) { + return null; + } + const values = [node.qoo[0], node.qoo[1]] + .map((entry) => Number(entry)) + .filter((entry) => Number.isFinite(entry) && entry !== 255); + if (values.length === 0) { + return null; + } + return values.reduce((sum, entry) => sum + entry, 0) / values.length; +} + +function ensureTreeGauges() { + if (!treeBitsGauge) { + treeBitsGauge = new BitsPerSecondGauge("treeBitsGauge", "Max"); + } + if (!treeQooGauge) { + treeQooGauge = new QooScoreGauge("treeQooGauge"); + } +} + +function updateTreeGauges(node) { + if (!node) { + return; + } + ensureTreeGauges(); + const effective = effectiveMax(node); + treeBitsGauge.update( + toNumber(node.current_throughput?.[0], 0) * 8, + toNumber(node.current_throughput?.[1], 0) * 8, + effective[0], + effective[1], + ); + treeQooGauge.update(representativeNodeQoo(node)); +} + function buildChildrenMap() { childrenByParentId = new Map(); for (let i=0; i 0) { - col.style.paddingLeft = (depth * 1.25) + "rem"; + nameWrap.style.paddingLeft = (depth * 1.25) + "rem"; } - let nameWrap = document.createElement("div"); - nameWrap.classList.add("d-flex", "align-items-center", "gap-1"); + const lead = document.createElement("div"); + lead.classList.add("lqos-tree-node-lead"); + const toggleSlot = document.createElement("div"); + toggleSlot.classList.add("lqos-tree-toggle-slot"); if (hasChildren(nodeId)) { let toggle = document.createElement("button"); toggle.type = "button"; - toggle.classList.add("btn", "btn-link", "btn-sm", "p-0", "text-decoration-none"); - toggle.style.lineHeight = "1"; + toggle.classList.add("btn", "btn-link", "btn-sm", "p-0", "text-decoration-none", "lqos-tree-toggle"); let icon = document.createElement("i"); icon.classList.add("fa", "fa-fw", expandedNodes.has(nodeId) ? "fa-minus" : "fa-plus"); toggle.appendChild(icon); @@ -837,36 +1188,43 @@ function buildRow(i, depth=0) { event.stopPropagation(); toggleNode(nodeId); }); - nameWrap.appendChild(toggle); - } else { - let spacer = document.createElement("i"); - spacer.classList.add("fa", "fa-fw", "fa-plus"); - spacer.style.visibility = "hidden"; - nameWrap.appendChild(spacer); - } - if (node.virtual === true) { - nameWrap.appendChild(buildStatusIcon( - "fa-ghost", - "text-secondary", - "Virtual node (logical only; not shaped in HTB)." - )); - } - if (isStormguardNode(node)) { - nameWrap.appendChild(buildStatusIcon( - "fa-cloud-bolt", - "text-primary", - "StormGuard-managed node (dynamic queue limits active)." - )); + toggleSlot.appendChild(toggle); } + lead.appendChild(toggleSlot); let link = document.createElement("a"); - link.href = treeHref(nodeId); - link.classList.add("redactable"); + link.href = treeHref(nodeId, node); + link.classList.add("redactable", "lqos-tree-node-link"); link.textContent = node.name; - nameWrap.appendChild(link); - appendNodeDetailText(nameWrap, node); + lead.appendChild(link); + nameWrap.appendChild(lead); + const statusWrap = document.createElement("div"); + statusWrap.classList.add("lqos-tree-row-statuses"); + statusWrap.appendChild(buildTreeRowStatusIcon( + "fa-ghost", + node.virtual === true, + "Virtual node: Active", + "Virtual node: Inactive", + )); + statusWrap.appendChild(buildTreeRowStatusIcon( + "fa-cloud-bolt", + isStormguardNode(node), + "StormGuard: Active", + "StormGuard: Inactive", + )); + nameWrap.appendChild(statusWrap); col.appendChild(nameWrap); row.appendChild(col); + col = document.createElement("td"); + col.classList.add("small"); + col.textContent = formatTreeCount(subtreeCircuitCount(node)); + row.appendChild(col); + + col = document.createElement("td"); + col.classList.add("small"); + col.textContent = formatTreeCount(subtreeSiteCount(node)); + row.appendChild(col); + col = document.createElement("td"); col.id = "limit-" + nodeId; col.classList.add("small"); @@ -985,9 +1343,11 @@ function buildRow(i, depth=0) { function treeUpdate(msg) { //console.log(msg); let needsRebuild = false; + const seenNodeIds = new Set(); msg.data.forEach((n) => { let nodeId = n[0]; let node = n[1]; + seenNodeIds.add(nodeId); if (tree[nodeId] === undefined) { tree[nodeId] = [nodeId, node]; @@ -1004,10 +1364,6 @@ function treeUpdate(msg) { tree[nodeId][1] = node; } - if (nodeId === parent) { - fillHeader(node); - } - let col = document.getElementById("limit-" + nodeId); if (col !== null) { col.innerHTML = buildEffectiveLimitCellHtml(node); @@ -1100,13 +1456,36 @@ function treeUpdate(msg) { } } }); + for (let i = 0; i < tree.length; i++) { + if (tree[i] === undefined || seenNodeIds.has(i)) { + continue; + } + delete tree[i]; + needsRebuild = true; + } if (needsRebuild) { buildChildrenMap(); + } + const selectionState = reconcileSelection(); + if (selectionState.identityChanged) { + loadNodeRateOverrideState(); + } + if (tree[parent] !== undefined) { + fillHeader(tree[parent][1]); + } + if (needsRebuild || selectionState.parentChanged) { renderTree(); } + if (selectionState.parentChanged && lastClientsMessage) { + clientsUpdate(lastClientsMessage); + } } function clientsUpdate(msg) { + lastClientsMessage = msg; + if (!tree || tree[parent] === undefined) { + return; + } let myName = tree[parent][1].name; let target = document.getElementById("clients"); @@ -1180,6 +1559,8 @@ function clientsUpdate(msg) { circuitLink.href = "/circuit.html?id=" + circuit.circuit_id; circuitLink.innerText = circuit.circuit_name; circuitLink.classList.add("redactable"); + circuitLink.classList.add("lqos-tree-circuit-name"); + circuitLink.title = circuit.circuit_name; linkTd.appendChild(circuitLink); tr.appendChild(linkTd); @@ -1197,10 +1578,7 @@ function clientsUpdate(msg) { tr.appendChild(simpleRow(circuit.parent_node, true)); const ipList = Array.from(circuit.ips); - const ipCell = simpleRow( - ipList.length > 2 ? `${ipList[0]}, ${ipList[1]} +${ipList.length - 2}` : ipList.join(", "), - true - ); + const ipCell = simpleRow(summarizeIpListForTable(ipList), true); if (ipList.length > 0) { ipCell.title = ipList.join(", "); } @@ -1258,6 +1636,10 @@ function stormguardUpdate(msg) { return; } stormguardNodes = nextNodes; + const selectionState = reconcileSelection(); + if ((selectionState.parentChanged || selectionState.identityChanged) && lastClientsMessage) { + clientsUpdate(lastClientsMessage); + } if (tree && tree[parent] !== undefined) { fillHeader(tree[parent][1]); renderTree(); @@ -1279,15 +1661,21 @@ const params = new Proxy(new URLSearchParams(window.location.search), { }); if (params.parent !== null) { - parent = parseInt(params.parent); + const parsedParent = parseInt(params.parent, 10); + parent = Number.isFinite(parsedParent) ? parsedParent : 0; } else { parent = 0; } if (params.upParent !== null) { - upParent = parseInt(params.upParent); + const parsedUpParent = parseInt(params.upParent, 10); + upParent = Number.isFinite(parsedUpParent) ? parsedUpParent : 0; } +selectionLocator.nodeId = typeof params.nodeId === "string" && params.nodeId.length > 0 ? params.nodeId : null; +selectionLocator.nodePath = parseNodePathParam(params.nodePath); +selectionLocator.lastKnownIndex = parent; + document.getElementById("nodeOverrideDownload")?.addEventListener("input", () => { nodeOverrideInputsDirty = true; }); diff --git a/src/rust/lqosd/src/node_manager/static2/node_manager.css b/src/rust/lqosd/src/node_manager/static2/node_manager.css index a8573013..8b8c2280 100644 --- a/src/rust/lqosd/src/node_manager/static2/node_manager.css +++ b/src/rust/lqosd/src/node_manager/static2/node_manager.css @@ -864,30 +864,248 @@ h5 { gap: 0.8rem; margin-top: 0.8rem; } -.lqos-tree-settings-card { - padding: 1rem 1.15rem; - border-radius: var(--lqos-radius-md); +.lqos-tree-node-cell { + min-width: 17rem; +} +.lqos-tree-node-wrap { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.75rem; + min-width: 0; +} +.lqos-tree-node-lead { + display: flex; + align-items: center; + gap: 0.35rem; + min-width: 0; + flex: 1 1 auto; +} +.lqos-tree-toggle-slot { + width: 1.2rem; + flex: 0 0 1.2rem; + display: flex; + align-items: center; + justify-content: center; +} +.lqos-tree-toggle { + line-height: 1; +} +.lqos-tree-node-link { + min-width: 0; +} +.lqos-tree-circuit-name { + display: block; + max-width: 14rem; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.lqos-tree-row-statuses { + display: inline-flex; + align-items: center; + gap: 0.2rem; + flex: 0 0 auto; +} +.lqos-tree-row-status-icon { + color: var(--bs-secondary-color); + opacity: 0.95; + transition: opacity 120ms ease, color 120ms ease; +} +.lqos-tree-row-status-icon.is-inactive { + opacity: 0.35; +} +.lqos-tree-hero { + padding: 0.75rem 1rem; border: 1px solid var(--lqos-border); - background: color-mix(in srgb, var(--lqos-surface-2) 92%, transparent); + border-radius: var(--lqos-radius-md); + background: linear-gradient( + 180deg, + color-mix(in srgb, var(--lqos-surface-2) 82%, transparent) 0%, + color-mix(in srgb, var(--lqos-surface-solid) 98%, transparent) 100% + ); box-shadow: var(--lqos-shadow-sm); } -.lqos-tree-settings-grid dt { +.lqos-tree-kicker { + display: inline-flex; + align-items: center; + gap: 0.45rem; + color: var(--bs-secondary-text-emphasis); + font-size: 1.55rem; + font-weight: 700; + letter-spacing: 0; + line-height: 1.2; + text-transform: none; +} +.lqos-tree-hero-bar { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.85rem; + margin-top: 0.65rem; +} +.lqos-tree-hero-breadcrumb { + min-width: 0; +} +.lqos-tree-hero-status { + display: flex; + align-items: center; + justify-content: flex-end; +} +.lqos-tree-context-meta { + display: inline-flex; + align-items: center; + justify-content: flex-end; + flex-wrap: wrap; + gap: 0.45rem; +} +.lqos-tree-context-pill { + display: inline-flex; + align-items: center; + padding: 0.32rem 0.68rem; + border-radius: 999px; + border: 1px solid color-mix(in srgb, var(--lqos-border) 82%, transparent); + background: color-mix(in srgb, var(--lqos-surface-2) 90%, transparent); color: var(--bs-secondary-color); - font-size: 0.78rem; + font-size: 0.8rem; + font-weight: 600; + white-space: nowrap; +} +.lqos-tree-compat-indicator { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 0.35rem; + min-width: 1.75rem; + height: 1.75rem; + padding: 0 0.5rem; + border-radius: 999px; + border: 1px solid color-mix(in srgb, var(--bs-warning) 48%, var(--lqos-border)); + background: color-mix(in srgb, var(--bs-warning-bg-subtle, #3a2d00) 72%, transparent); + color: var(--bs-warning-text-emphasis, var(--bs-warning)); + font-size: 0.82rem; font-weight: 700; - letter-spacing: 0.08em; - text-transform: uppercase; + cursor: help; } -.lqos-tree-settings-grid dd { - margin-bottom: 0.85rem; - font-size: 0.95rem; +.lqos-tree-compat-count { + font-size: 0.76rem; + line-height: 1; } -.lqos-tree-settings-value { +.lqos-tree-panel { + height: 100%; + display: flex; + flex-direction: column; + gap: 0.85rem; + min-height: 230px; + border: 1px solid var(--lqos-border); + border-radius: var(--lqos-radius-md); + background: linear-gradient( + 180deg, + color-mix(in srgb, var(--lqos-surface-2) 88%, transparent) 0%, + var(--lqos-surface-solid) 100% + ); + box-shadow: var(--lqos-shadow-sm); + padding: 0.85rem; +} +.lqos-tree-panel-heading { + min-height: 1.75rem; +} +.lqos-tree-panel h5, +.lqos-tree-snapshot-panel h5 { + font-size: 1.15rem; + font-weight: 650; +} +.lqos-tree-snapshot-panel { + display: flex; + flex-direction: column; + align-items: stretch; + justify-content: flex-start; + gap: 0.85rem; + padding: 0.85rem 0.85rem 0.6rem; +} +.lqos-tree-snapshot-panel .lqos-tree-panel-heading { + margin-bottom: 0; +} +.lqos-tree-snapshot-panel .lqos-circuit-gauge-grid { + flex: 1 1 auto; + align-content: center; +} +.lqos-tree-state-panel .lqos-table-wrap, +.lqos-tree-details-panel .lqos-table-wrap { + height: 100%; +} +.lqos-tree-detail-value { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 0.4rem; } +.lqos-tree-editor { + display: flex; + flex-direction: column; + gap: 0.85rem; + padding-top: 0.85rem; + border-top: 1px solid color-mix(in srgb, var(--lqos-border) 72%, transparent); +} +.lqos-tree-editor-heading-end { + display: inline-flex; + align-items: center; + justify-content: flex-end; + margin-left: auto; + min-height: 1.75rem; +} +.lqos-tree-editor[hidden] { + display: none !important; +} +.lqos-tree-editor #nodeOverrideFlash .alert:last-child, +.lqos-tree-details-panel #nodeOverrideDisabledReason .alert:last-child { + margin-bottom: 0; +} +.lqos-tree-editor-row { + display: flex; + align-items: center; + gap: 0.75rem; + flex-wrap: nowrap; + padding: 0.65rem 0.75rem; + border: 1px solid color-mix(in srgb, var(--lqos-border) 78%, transparent); + border-radius: var(--lqos-radius-md); + background: color-mix(in srgb, var(--lqos-surface-2) 76%, transparent); +} +.lqos-tree-editor-field { + flex: 1 1 0; + min-width: 0; +} +.lqos-tree-editor-field .input-group-text { + min-width: 5.9rem; + justify-content: center; + background: color-mix(in srgb, var(--lqos-surface-2) 88%, transparent); + border-color: color-mix(in srgb, var(--lqos-border) 78%, transparent); + color: var(--bs-secondary-color); + font-size: 0.82rem; + font-weight: 600; +} +.lqos-tree-editor-actions { + justify-content: flex-start; + flex: 0 0 auto; + white-space: nowrap; +} +.lqos-tree-state-badges { + display: inline-flex; + align-items: center; + flex-wrap: wrap; + gap: 0.35rem; +} +.lqos-tree-state-badges .fa { + display: inline-flex; + align-items: center; + justify-content: center; + width: 1.9rem; + height: 1.9rem; + border-radius: 999px; + border: 1px solid color-mix(in srgb, var(--lqos-border) 82%, transparent); + background: color-mix(in srgb, var(--lqos-surface-2) 88%, transparent); + box-shadow: var(--lqos-shadow-sm); +} .lqos-tree-pending { display: inline-flex; align-items: center; @@ -900,19 +1118,15 @@ h5 { font-size: 1rem; line-height: 1; } -.lqos-tree-settings-card .alert { - margin-bottom: 0.75rem; -} .lqos-tree-nav { display: flex; align-items: center; - margin-top: 0.15rem; } .lqos-tree-nav a { display: inline-flex; align-items: center; gap: 0.55rem; - padding: 0.55rem 0.85rem; + padding: 0.4rem 0.7rem; border-radius: 999px; border: 1px solid var(--lqos-border); background: color-mix(in srgb, var(--lqos-surface-2) 90%, transparent); @@ -961,6 +1175,27 @@ h5 { letter-spacing: 0.08em; text-transform: uppercase; } +@media (max-width: 991.98px) { + .lqos-tree-hero-status { + justify-content: flex-start; + } + .lqos-tree-hero-bar { + flex-direction: column; + align-items: flex-start; + } + .lqos-tree-context-meta { + justify-content: flex-start; + } +} +@media (max-width: 767.98px) { + .lqos-tree-editor-row { + flex-wrap: wrap; + } + .lqos-tree-editor-field, + .lqos-tree-editor-actions { + width: 100%; + } +} /* Funky tricks for the tree view */ .overlayThroughputWrapper { diff --git a/src/rust/lqosd/src/node_manager/static2/tree.html b/src/rust/lqosd/src/node_manager/static2/tree.html index fcc0fd08..6ef593ee 100644 --- a/src/rust/lqosd/src/node_manager/static2/tree.html +++ b/src/rust/lqosd/src/node_manager/static2/tree.html @@ -1,99 +1,133 @@ -
+
+
+
+
+
Network Tree
+
+
+
+
+
+
+
+
-
Network Tree ()
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DownloadUpload
Effective Limit
Configured Limit
Throughput
RTT
QoO
TCP Retransmits
+
+
+
Live Queue State
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DownloadUpload
Effective Limit
Configured Limit
Throughput
RTT
QoO
TCP Retransmits
+
+
+
+
+
+
+
Node Snapshot
+
+
+
+
+
-
-
-
-
Node Settings
-
+
+
+
+
Node Details
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Node Type-
Branch Size-
Base Configured Rate-
Operator OverrideNone
Effective Now-
-
-
-
-
Node Type
-
-
- -
Stable Node ID
-
-
- -
Base Source
-
Integration/network.json
- -
Override Source
-
Operator
- -
Base Configured Rate
-
-
- -
Operator Override
-
None
- -
Effective Now
-
-
-
-
-
- - +
+
+
Operator Override
+
-
- - +
+
+
+ Download + +
+
+ Upload + +
+
+ + +
-
- - -
-- knotmirror 0.0.1