diff --git a/front/network.php b/front/network.php index ee850b85..00b132b9 100755 --- a/front/network.php +++ b/front/network.php @@ -502,7 +502,8 @@ // --------------------------------------------------------------------------- var leafNodesCount = 0; - var treeLoadedAlready = false; + var visibleNodesCount = 0; + var parentNodesCount = 0; var hiddenMacs = []; // hidden children var hiddenChildren = []; @@ -519,17 +520,24 @@ { //... of the current node if(list[i].parentMac == node.mac && !hiddenMacs.includes(list[i].parentMac)) - { + { + visibleNodesCount++ + // and process them children.push(getChildren(list[i], list, path + ((path == "") ? "" : '|') + list[i].parentMac, hiddenMacs)) + } } // note the total number of leaf nodes to calculate the font scaling - if(!treeLoadedAlready && children.length == 0) + if(children.length == 0) { leafNodesCount++ - } + } else + { + parentNodesCount++ + } + return { name: node.name, @@ -602,10 +610,17 @@ // --------------------------------------------------------------------------- var myTree; var treeAreaHeight = 600; + var emSize; + var nodeHeight; + function initTree(myHierarchy) { - // to prevent font scaling everytime we collapse/expand a subtree - treeLoadedAlready = true; + // calculate the font size of the leaf nodes to fit everything into the tree area + leafNodesCount == 0 ? 1 : leafNodesCount; + emSize = ((600/(20*leafNodesCount)).toFixed(2)); + emSize = emSize > 1 ? 1 : emSize; + + nodeHeight = ((emSize*100*0.30).toFixed(0)) $("#networkTree").attr('style', "height:"+treeAreaHeight+"px; width:1070px") @@ -613,17 +628,11 @@ htmlId: "networkTree", renderNode: nodeData => { + var fontSize = "font-size:"+emSize+"em;"; - // calculate the font size of the leaf nodes to fit everything into the tree area - leafNodesCount == 0 ? 1 : leafNodesCount; - emSize = ((600/(20*leafNodesCount)).toFixed(2)); - emSize = emSize > 1 ? 1 : emSize; - - var fontSize = (nodeData.data.hasChildren) ? "" : "font-size:"+emSize+"em;"; - - deviceIcon = (!emptyArr.includes(nodeData.data.icon )) ? "
" : ""; + deviceIcon = (!emptyArr.includes(nodeData.data.icon )) ? "
" : ""; collapseExpandIcon = nodeData.data.hiddenChildren ? "square-plus" :"square-minus"; - collapseExpandHtml = (nodeData.data.hasChildren) ? "
" : ""; + collapseExpandHtml = (nodeData.data.hasChildren) ? "
" : ""; statusCss = " netStatus-" + nodeData.data.status; selectedNodeMac = $(".nav-tabs-custom .active a").attr('data-mytabmac') @@ -638,7 +647,6 @@ justify-content:center;\ " + fontSize + "\ align-items:center;\ - background-color:" +nodeData.data.color+";\ border-radius:5px;'\ >\
\ @@ -655,7 +663,7 @@ mainAxisNodeSpacing: 'auto', // mainAxisNodeSpacing: 3, secondaryAxisNodeSpacing: 0.3, - nodeHeight: '25', + nodeHeight: nodeHeight.toString(), marginTop: '5', hasZoom: false, hasPan: false, @@ -665,7 +673,7 @@ linkWidth: (nodeData) => 3, relationnalField: "children", }); - + myTree.refresh(myHierarchy); } diff --git a/front/php/templates/language/en_us.php b/front/php/templates/language/en_us.php index 9aa0e13d..69880763 100755 --- a/front/php/templates/language/en_us.php +++ b/front/php/templates/language/en_us.php @@ -649,7 +649,7 @@ the arp-scan will take hours to complete instead of seconds. // Nmap 'API_settings_group' => ' API', 'ENABLE_API_name' => 'Enable API', -'ENABLE_API_description' => 'If enabled the app will start publishing and updating simple API endpoints under the /home/pi/pialert/front/api/ folder and thus on the pialert_url/api/File_name` url.', +'ENABLE_API_description' => 'If enabled the app will start publishing and updating simple API endpoints under the /home/pi/pialert/front/api/ folder and thus on the pialert_url/api/File_name url.', 'API_RUN_name' => 'Scheduling updates', 'API_RUN_description' => 'Scheduling settings to specify when the API endpoints should be updated. If set to schedule then endpoints will be updated on a specified cron-like schedule specified by the API_RUN_SCHD setting. Otherwise if set to interval endpoints will be updated every N seconds specified by the API_RUN_INTERVAL setting.', 'API_RUN_SCHD_name' => 'Schedule',