Prep work for flat tree

This commit is contained in:
Jokob-sk
2023-01-25 23:50:02 +11:00
parent 2d92e93b7b
commit 8624851cf5
2 changed files with 68 additions and 4 deletions

View File

@@ -7,9 +7,9 @@ services:
network_mode: "host" network_mode: "host"
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ${APP_DATA_LOCATION}/pialert/config2:/home/pi/pialert/config - ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
# - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db # - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
- ${APP_DATA_LOCATION}/pialert/db2:/home/pi/pialert/db - ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db
# (optional) useful for debugging if you have issues setting up the container # (optional) useful for debugging if you have issues setting up the container
- ${LOGS_LOCATION}:/home/pi/pialert/front/log - ${LOGS_LOCATION}:/home/pi/pialert/front/log
# DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes # DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes

View File

@@ -504,6 +504,45 @@
var treeLoadedAlready = false; var treeLoadedAlready = false;
var hiddenMacs = []; var hiddenMacs = [];
// ---------------------------------------------------------------------------
function formatFlatDevicesList()
{
devList = getDevicesList()
result = []
for(i=0;i<devList.length;i++)
{
node = devList[i]
if(!hiddenMacs.includes(node.parentMac))
{
result.push(
{
name: node.name,
path: '',
mac: node.mac,
id: node.mac,
parentMac: node.parentMac,
icon: node.icon,
type: node.type,
status: node.status,
hasChildren: true,
hiddenChildren: true,
qty: 5,
// children: children
})
}
}
console.log(result)
return result;
}
// ---------------------------------------------------------------------------
function getChildren(node, list, path) function getChildren(node, list, path)
{ {
var children = []; var children = [];
@@ -529,6 +568,7 @@
name: node.name, name: node.name,
path: path, path: path,
mac: node.mac, mac: node.mac,
id: node.mac,
parentMac: node.parentMac, parentMac: node.parentMac,
icon: node.icon, icon: node.icon,
type: node.type, type: node.type,
@@ -582,6 +622,27 @@
// re-attach any onclick events // re-attach any onclick events
attachTreeEvents(); attachTreeEvents();
} }
// ---------------------------------------------------------------------------
function toggleFlatSubTree(parentMac, treePath)
{
// treePath = treePath.split('|')
if(!hiddenMacs.includes(parentMac))
{
hiddenMacs.push(parentMac)
}
else
{
removeItemFromArray(hiddenMacs, parentMac)
}
list = formatFlatDevicesList();
myTree.refresh(list);
// re-attach any onclick events
attachTreeEvents();
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function attachTreeEvents() function attachTreeEvents()
@@ -646,20 +707,23 @@
// console.log(this) // console.log(this)
}, },
mainAxisNodeSpacing: 'auto', mainAxisNodeSpacing: 'auto',
// mainAxisNodeSpacing: 3,
secondaryAxisNodeSpacing: 0.3, secondaryAxisNodeSpacing: 0.3,
nodeHeight: '25', nodeHeight: '25',
marginTop: '5', marginTop: '5',
hasZoom: false, hasZoom: false,
hasPan: false, hasPan: false,
// marginLeft: '15', // marginLeft: '15',
idKey: "name", idKey: "id",
hasFlatData: false, hasFlatData: false,
// hasFlatData: true,
linkWidth: (nodeData) => 3, linkWidth: (nodeData) => 3,
relationnalField: "children", relationnalField: "children",
// relationnalField: "parentMac",
}); });
myTree.refresh(myHierarchy); myTree.refresh(myHierarchy);
// myTree.refresh(formatFlatDevicesList()); //hasFlatData
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------