mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Tree view supports max-depth support, persisted in the browser.
This commit is contained in:
parent
453f004ea4
commit
e62e0acdc9
@ -4,6 +4,8 @@ import {subscribeWS} from "./pubsub/ws";
|
|||||||
|
|
||||||
var tree = null;
|
var tree = null;
|
||||||
var parent = 0;
|
var parent = 0;
|
||||||
|
var maxDepth = 1;
|
||||||
|
var subscribed = false;
|
||||||
|
|
||||||
// This runs first and builds the initial structure on the page
|
// This runs first and builds the initial structure on the page
|
||||||
function getInitialTree() {
|
function getInitialTree() {
|
||||||
@ -40,7 +42,9 @@ function getInitialTree() {
|
|||||||
if (node.immediate_parent !== null && node.immediate_parent === parent) {
|
if (node.immediate_parent !== null && node.immediate_parent === parent) {
|
||||||
let row = buildRow(i);
|
let row = buildRow(i);
|
||||||
tbody.appendChild(row);
|
tbody.appendChild(row);
|
||||||
iterateChildren(i, tbody, 1);
|
if (maxDepth > 1) {
|
||||||
|
iterateChildren(i, tbody, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
treeTable.appendChild(tbody);
|
treeTable.appendChild(tbody);
|
||||||
@ -50,7 +54,10 @@ function getInitialTree() {
|
|||||||
clearDiv(target)
|
clearDiv(target)
|
||||||
target.appendChild(treeTable);
|
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]) {
|
if (node.immediate_parent !== null && node.immediate_parent === tree[idx][0]) {
|
||||||
let row = buildRow(i, depth);
|
let row = buildRow(i, depth);
|
||||||
tBody.appendChild(row);
|
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;
|
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();
|
getInitialTree();
|
||||||
|
@ -19,6 +19,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-2">
|
||||||
|
<label for="maxDepth">Max Depth:</label>
|
||||||
|
<input type="number" id="maxDepth" class="form-control" value="2" min="1" max="10">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12" id="tree">
|
<div class="col-12" id="tree">
|
||||||
|
Loading…
Reference in New Issue
Block a user