Update the top of the tree view live

This commit is contained in:
Herbert Wolverson 2024-07-08 16:18:38 -05:00
parent dff5e67261
commit 9d8dea81eb

View File

@ -34,25 +34,7 @@ function getInitialTree() {
let node = tree[i][1]; let node = tree[i][1];
if (nodeId === parent) { if (nodeId === parent) {
$("#nodeName").text(node.name); fillHeader(node)
let limit = "";
if (node.max_throughput[0] === 0) {
limit = "Unlimited";
} else {
limit = scaleNumber(node.max_throughput[0] * 1000 * 1000, 0);
}
limit += " / ";
if (node.max_throughput[1] === 0) {
limit += "Unlimited";
} else {
limit += scaleNumber(node.max_throughput[1] * 1000 * 1000, 0);
}
$("#parentLimits").text(limit);
$("#parentTpD").html(formatThroughput(node.current_throughput[0] * 8, node.max_throughput[0]));
$("#parentTpU").html(formatThroughput(node.current_throughput[1] * 8, node.max_throughput[1]));
console.log(node);
$("#parentRttD").html(formatRtt(node.rtts[0]));
$("#parentRttU").html(formatRtt(node.rtts[1]));
} }
if (node.immediate_parent !== null && node.immediate_parent === parent) { if (node.immediate_parent !== null && node.immediate_parent === parent) {
@ -72,6 +54,28 @@ function getInitialTree() {
}); });
} }
function fillHeader(node) {
$("#nodeName").text(node.name);
let limit = "";
if (node.max_throughput[0] === 0) {
limit = "Unlimited";
} else {
limit = scaleNumber(node.max_throughput[0] * 1000 * 1000, 0);
}
limit += " / ";
if (node.max_throughput[1] === 0) {
limit += "Unlimited";
} else {
limit += scaleNumber(node.max_throughput[1] * 1000 * 1000, 0);
}
$("#parentLimits").text(limit);
$("#parentTpD").html(formatThroughput(node.current_throughput[0] * 8, node.max_throughput[0]));
$("#parentTpU").html(formatThroughput(node.current_throughput[1] * 8, node.max_throughput[1]));
console.log(node);
$("#parentRttD").html(formatRtt(node.rtts[0]));
$("#parentRttU").html(formatRtt(node.rtts[1]));
}
function iterateChildren(idx, tBody, depth) { function iterateChildren(idx, tBody, depth) {
for (let i=0; i<tree.length; i++) { for (let i=0; i<tree.length; i++) {
let node = tree[i][1]; let node = tree[i][1];
@ -211,6 +215,10 @@ function onMessage(msg) {
let nodeId = n[0]; let nodeId = n[0];
let node = n[1]; let node = n[1];
if (nodeId === parent) {
fillHeader(node);
}
let col = document.getElementById("down-" + nodeId); let col = document.getElementById("down-" + nodeId);
if (col !== null) { if (col !== null) {
col.innerHTML = formatThroughput(node.current_throughput[0] * 8, node.max_throughput[0]); col.innerHTML = formatThroughput(node.current_throughput[0] * 8, node.max_throughput[0]);