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 ce3de0ba..5a73b976 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 @@ -4,6 +4,8 @@ import {subscribeWS} from "./pubsub/ws"; var tree = null; var parent = 0; +var maxDepth = 1; +var subscribed = false; // This runs first and builds the initial structure on the page function getInitialTree() { @@ -40,7 +42,9 @@ function getInitialTree() { if (node.immediate_parent !== null && node.immediate_parent === parent) { let row = buildRow(i); tbody.appendChild(row); - iterateChildren(i, tbody, 1); + if (maxDepth > 1) { + iterateChildren(i, tbody, 1); + } } } treeTable.appendChild(tbody); @@ -50,7 +54,10 @@ function getInitialTree() { clearDiv(target) target.appendChild(treeTable); - subscribeWS(["NetworkTree"], onMessage); + if (!subscribed) { + subscribeWS(["NetworkTree"], onMessage); + subscribed = true; + } }); } @@ -83,7 +90,9 @@ function iterateChildren(idx, tBody, depth) { if (node.immediate_parent !== null && node.immediate_parent === tree[idx][0]) { let row = buildRow(i, depth); tBody.appendChild(row); - iterateChildren(i, tBody, depth+1); + if (depth < maxDepth-1) { + iterateChildren(i, tBody, depth + 1); + } } } } @@ -298,4 +307,15 @@ if (params.parent !== null) { parent = 0; } +if (localStorage.getItem("treeMaxDepth") !== null) { + maxDepth = parseInt(localStorage.getItem("treeMaxDepth")); + $("#maxDepth").val(maxDepth); +} + +$("#maxDepth").on("change", function() { + maxDepth = parseInt($(this).val()); + localStorage.setItem("treeMaxDepth", maxDepth); + getInitialTree(); +}); + getInitialTree(); diff --git a/src/rust/lqosd/src/node_manager/static2/tree.html b/src/rust/lqosd/src/node_manager/static2/tree.html index 16f44997..bf27aab8 100644 --- a/src/rust/lqosd/src/node_manager/static2/tree.html +++ b/src/rust/lqosd/src/node_manager/static2/tree.html @@ -19,6 +19,10 @@ +
+ + +