mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-12 05:01:27 -07:00
FE: more defensive network topology hierarchy check #1308
Signed-off-by: jokob-sk <jokob.sk@gmail.com>
This commit is contained in:
@@ -565,14 +565,27 @@ function getChildren(node, list, path, visited = [])
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
function getHierarchy()
|
function getHierarchy()
|
||||||
{
|
{
|
||||||
|
let internetNode = null;
|
||||||
|
|
||||||
for(i in deviceListGlobal)
|
for(i in deviceListGlobal)
|
||||||
{
|
{
|
||||||
if(deviceListGlobal[i].devMac == 'Internet')
|
if(deviceListGlobal[i].devMac == 'Internet')
|
||||||
{
|
{
|
||||||
return (getChildren(deviceListGlobal[i], deviceListGlobal, ''))
|
internetNode = deviceListGlobal[i];
|
||||||
|
|
||||||
|
return (getChildren(internetNode, deviceListGlobal, ''))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!internetNode) {
|
||||||
|
showModalOk(
|
||||||
|
getString('Network_Configuration_Error'),
|
||||||
|
getString('Network_Root_Not_Configured')
|
||||||
|
);
|
||||||
|
console.error("getHierarchy(): Internet node not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -671,8 +684,6 @@ function handleNodeClick(el)
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
var myTree;
|
var myTree;
|
||||||
|
|
||||||
|
|
||||||
var emSize;
|
var emSize;
|
||||||
var nodeHeight;
|
var nodeHeight;
|
||||||
// var sizeCoefficient = 1.4
|
// var sizeCoefficient = 1.4
|
||||||
@@ -689,10 +700,12 @@ function emToPx(em, element) {
|
|||||||
|
|
||||||
function initTree(myHierarchy)
|
function initTree(myHierarchy)
|
||||||
{
|
{
|
||||||
// calculate the drawing area based on teh tree width and available screen size
|
if(myHierarchy && myHierarchy.type !== "")
|
||||||
|
{
|
||||||
|
// calculate the drawing area based on the tree width and available screen size
|
||||||
let baseFontSize = parseFloat($('html').css('font-size'));
|
let baseFontSize = parseFloat($('html').css('font-size'));
|
||||||
let treeAreaHeight = ($(window).height() - 155); ;
|
let treeAreaHeight = ($(window).height() - 155); ;
|
||||||
|
|
||||||
// calculate the font size of the leaf nodes to fit everything into the tree area
|
// calculate the font size of the leaf nodes to fit everything into the tree area
|
||||||
leafNodesCount == 0 ? 1 : leafNodesCount;
|
leafNodesCount == 0 ? 1 : leafNodesCount;
|
||||||
|
|
||||||
@@ -703,13 +716,6 @@ function initTree(myHierarchy)
|
|||||||
// init the drawing area size
|
// init the drawing area size
|
||||||
$("#networkTree").attr('style', `height:${treeAreaHeight}px; width:${emToPx(screenWidthEm)}px`)
|
$("#networkTree").attr('style', `height:${treeAreaHeight}px; width:${emToPx(screenWidthEm)}px`)
|
||||||
|
|
||||||
if(myHierarchy.type == "")
|
|
||||||
{
|
|
||||||
showModalOk(getString('Network_Configuration_Error'), getString('Network_Root_Not_Configured'))
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle canvas and node size if only a few nodes
|
// handle canvas and node size if only a few nodes
|
||||||
emSize > 1 ? emSize = 1 : emSize = emSize;
|
emSize > 1 ? emSize = 1 : emSize = emSize;
|
||||||
|
|
||||||
@@ -823,6 +829,10 @@ function initTree(myHierarchy)
|
|||||||
|
|
||||||
// hide spinning icon
|
// hide spinning icon
|
||||||
hideSpinner()
|
hideSpinner()
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
console.error("getHierarchy() not returning expected result");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user