mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
Network fixes 🚑
This commit is contained in:
@@ -206,7 +206,10 @@ function getString (key) {
|
||||
// -----------------------------------------------------------------------------
|
||||
// Modal dialog handling
|
||||
// -----------------------------------------------------------------------------
|
||||
function showModalOk (title, message, callbackFunction = null) {
|
||||
function showModalOK (title, message, callbackFunction) {
|
||||
showModalOk (title, message, callbackFunction)
|
||||
}
|
||||
function showModalOk (title, message, callbackFunction) {
|
||||
// set captions
|
||||
$('#modal-ok-title').html (title);
|
||||
$('#modal-ok-message').html (message);
|
||||
@@ -222,6 +225,8 @@ function showModalOk (title, message, callbackFunction = null) {
|
||||
// Show modal
|
||||
$('#modal-ok').modal('show');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function showModalDefault (title, message, btnCancel, btnOK, callbackFunction) {
|
||||
// set captions
|
||||
$('#modal-default-title').html (title);
|
||||
@@ -253,13 +258,17 @@ function showModalDefaultStrParam (title, message, btnCancel, btnOK, callbackFun
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function showModalWarning (title, message, btnCancel, btnOK, callbackFunction) {
|
||||
function showModalWarning (title, message, btnCancel=getString('Gen_Cancel'), btnOK=getString('Gen_Okay'), callbackFunction=null) {
|
||||
// set captions
|
||||
$('#modal-warning-title').html (title);
|
||||
$('#modal-warning-message').html (message);
|
||||
$('#modal-warning-cancel').html (btnCancel);
|
||||
$('#modal-warning-OK').html (btnOK);
|
||||
modalCallbackFunction = callbackFunction;
|
||||
|
||||
if ( callbackFunction != null)
|
||||
{
|
||||
modalCallbackFunction = callbackFunction;
|
||||
}
|
||||
|
||||
// Show modal
|
||||
$('#modal-warning').modal('show');
|
||||
|
||||
@@ -456,32 +456,39 @@
|
||||
<script>
|
||||
$.get('php/server/devices.php?action=getDevicesList&status=all&forceDefaultOrder', function(data) {
|
||||
|
||||
rawData = JSON.parse (data)
|
||||
|
||||
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],
|
||||
"childrenQty":item[15],
|
||||
"port":item[18]
|
||||
}})
|
||||
|
||||
setCache('devicesListNew', JSON.stringify(devicesListnew))
|
||||
|
||||
// init global variable
|
||||
deviceListGlobal = devicesListnew;
|
||||
rawData = JSON.parse (data)
|
||||
|
||||
if(rawData["data"] == "")
|
||||
{
|
||||
showModalOK (getString('Gen_Warning'), getString('Network_NoDevices'))
|
||||
|
||||
// create tree
|
||||
initTree(getHierarchy());
|
||||
return;
|
||||
}
|
||||
|
||||
// attach on-click events
|
||||
attachTreeEvents();
|
||||
});
|
||||
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],
|
||||
"childrenQty":item[15],
|
||||
"port":item[18]
|
||||
}})
|
||||
|
||||
setCache('devicesListNew', JSON.stringify(devicesListnew))
|
||||
|
||||
// init global variable
|
||||
deviceListGlobal = devicesListnew;
|
||||
|
||||
|
||||
// create tree
|
||||
initTree(getHierarchy());
|
||||
|
||||
// attach on-click events
|
||||
attachTreeEvents();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -612,13 +619,25 @@
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
var myTree;
|
||||
var treeAreaHeight = 800;
|
||||
var visibleTreeArea = $(window).height()-135;
|
||||
var treeAreaHeight = visibleTreeArea > 800 ? 800 : visibleTreeArea;
|
||||
var emSize;
|
||||
var nodeHeight;
|
||||
var sizeCoefficient = 1
|
||||
|
||||
function initTree(myHierarchy)
|
||||
{
|
||||
|
||||
console.log(myHierarchy)
|
||||
|
||||
|
||||
if(myHierarchy.type == "")
|
||||
{
|
||||
showModalOk(getString('Network_Configuration_Error'), getString('Network_Root_Not_Configured'))
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// calculate the font size of the leaf nodes to fit everything into the tree area
|
||||
leafNodesCount == 0 ? 1 : leafNodesCount;
|
||||
emSize = ((treeAreaHeight/(25*leafNodesCount)).toFixed(2));
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
"AppEvents_Helper2" : "Helper 2",
|
||||
"AppEvents_Helper3" : "Helper 3",
|
||||
"AppEvents_Extra" : "Extra",
|
||||
"Gen_Error" : "Error",
|
||||
"Gen_Warning" : "Warning",
|
||||
"Gen_Delete" : "Delete",
|
||||
"Gen_DeleteAll" : "Delete all",
|
||||
"Gen_Cancel" : "Cancel",
|
||||
@@ -428,6 +430,9 @@
|
||||
"Network_Node_Name" : "Node name",
|
||||
"Network_Parent" : "Parent network device",
|
||||
"Network_Cant_Assign" : "Can't assign the root Internet node as a child leaf node.",
|
||||
"Network_NoDevices" : "Configuration Error",
|
||||
"Network_Configuration_Error" : "Configuration Error",
|
||||
"Network_Root_Not_Configured" : "Select a network device type, for example a <b>Gateway</b>, in the <b>Type</b> field of the <a href=\"deviceDetails.php?mac=Internet\">the Internet root device</a> to start configuring this screen. <br/><br/> More documentation can be found in the <a href=\"https://github.com/jokob-sk/Pi.Alert/blob/main/docs/NETWORK_TREE.md\" target=\"_blank\">How to setup your Network page</a> guide",
|
||||
"Network_NoAssignedDevices" : "This network node does not have any assigned devices (leaf nodes). Assign one from bellow or go to the <b><i class=\"fa fa-info-circle\"></i> Details</b> tab of any device in <a href=\"devices.php\"><b> <i class=\"fa fa-laptop\"></i> Devices</b></a>, and assign it to a network <b><i class=\"fa fa-server\"></i> Node (MAC)</b> and <b><i class=\"fa fa-ethernet\"></i> Port</b> there.",
|
||||
"Network_Root_Unconfigurable": "Unconfigurable root",
|
||||
"HelpFAQ_Title" : "Help / FAQ",
|
||||
|
||||
Reference in New Issue
Block a user