From 794bfcc25cce21451aed0682fa12493e20a2b089 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Tue, 12 Sep 2023 21:11:36 +1000 Subject: [PATCH] #424 work - network page --- front/network.php | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/front/network.php b/front/network.php index 7f065de0..8dcd49d6 100755 --- a/front/network.php +++ b/front/network.php @@ -471,6 +471,10 @@ setCache('devicesListNew', JSON.stringify(devicesListnew)) + // init global variable + deviceListGlobal = devicesListnew; + + // create tree initTree(getHierarchy()); @@ -484,20 +488,6 @@ // --------------------------------------------------------------------------- // Tree functionality // --------------------------------------------------------------------------- - // --------------------------------------------------------------------------- - function getDevicesList() - { - // Read cache - devicesList = getCache('devicesListNew'); - - if (devicesList != '') { - devicesList = JSON.parse (devicesList); - } else { - devicesList = []; - } - return devicesList; - } - // --------------------------------------------------------------------------- var leafNodesCount = 0; @@ -505,6 +495,7 @@ var parentNodesCount = 0; var hiddenMacs = []; // hidden children var hiddenChildren = []; + var deviceListGlobal = null; @@ -559,14 +550,12 @@ // --------------------------------------------------------------------------- function getHierarchy() - { - list = getDevicesList(); - - for(i in list) + { + for(i in deviceListGlobal) { - if(list[i].mac == 'Internet') + if(deviceListGlobal[i].mac == 'Internet') { - return (getChildren(list[i], list, '')) + return (getChildren(deviceListGlobal[i], deviceListGlobal, '')) break; } } @@ -587,8 +576,6 @@ removeItemFromArray(hiddenMacs, parentMac) } - list = getDevicesList(); - // updatedTree = myHierarchy; updatedTree = getHierarchy() @@ -638,6 +625,8 @@ $("#networkTree").attr('style', `height:${treeAreaHeight}px; width:${$('.content-header').width()}px`) + console.log('here') + myTree = Treeviz.create({ htmlId: "networkTree", @@ -689,6 +678,10 @@ onNodeClick: (nodeData) => handleNodeClick(nodeData), relationnalField: "children", }); + + console.log('vvvv') + console.log(myHierarchy) + console.log('^^^^^^^') myTree.refresh(myHierarchy); }