Network tre refresh on device (un-)assign

This commit is contained in:
Jokob-sk
2023-01-23 22:12:48 +11:00
parent 35d9c0e548
commit f151b1268d

View File

@@ -453,6 +453,32 @@
<script src="lib/treeviz/require.js"></script> <script src="lib/treeviz/require.js"></script>
<script src="js/pialert_common.js"></script> <script src="js/pialert_common.js"></script>
<script>
$.get('php/server/devices.php?action=getDevicesList&status=all', function(data) {
rawData = JSON.parse (data)
// console.log(rawData)
devicesListnew = rawData["data"].map(item => { return {
"name":item[0],
"type":item[2],
"icon":item[3],
"mac":item[11],
"parentMac":item[14],
"rowid":item[13],
"status":item[10]
}})
setCache('devicesList', JSON.stringify(devicesListnew))
// create tree
initTree(getHierarchy());
// attach on-click events
attachTreeEvents();
});
</script>
<script defer> <script defer>
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -485,7 +511,7 @@
// loop thru all items and find childern... // loop thru all items and find childern...
for(var i in list) for(var i in list)
{ {
//... of teh current node //... of the current node
if(list[i].parentMac == node.mac && !hiddenMacs.includes(list[i].parentMac)) if(list[i].parentMac == node.mac && !hiddenMacs.includes(list[i].parentMac))
{ {
// and process them // and process them
@@ -516,9 +542,11 @@
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
list = getDevicesList();
function getHierarchy() function getHierarchy()
{ {
list = getDevicesList();
for(i in list) for(i in list)
{ {
if(list[i].mac == 'Internet') if(list[i].mac == 'Internet')
@@ -623,7 +651,7 @@
marginTop: '5', marginTop: '5',
hasZoom: false, hasZoom: false,
hasPan: false, hasPan: false,
marginLeft: '15', // marginLeft: '15',
idKey: "name", idKey: "name",
hasFlatData: false, hasFlatData: false,
linkWidth: (nodeData) => 3, linkWidth: (nodeData) => 3,
@@ -677,8 +705,6 @@
setCache(key, $(e.target).attr('id')) setCache(key, $(e.target).attr('id'))
}); });
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -726,12 +752,6 @@
// init selected (first) tab // init selected (first) tab
initTab(); initTab();
// create tree
initTree(getHierarchy());
// attach on-click events
attachTreeEvents();
// init Assign/Unassign buttons // init Assign/Unassign buttons
initButtons() initButtons()