From 2a0f464c63895cdae5d8dd0c5464c79e1a6344b2 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sun, 1 Oct 2023 16:09:17 +1100 Subject: [PATCH] docs + #457 work --- docs/DEVICES_BULK_EDITING.md | 2 +- docs/NETWORK_TREE.md | 4 ++++ docs/README.md | 1 + front/network.php | 16 ++++++++++++---- front/php/server/devices.php | 4 ++-- front/php/templates/language/en_us.json | 1 + 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/DEVICES_BULK_EDITING.md b/docs/DEVICES_BULK_EDITING.md index 73e7ab73..c3823c17 100644 --- a/docs/DEVICES_BULK_EDITING.md +++ b/docs/DEVICES_BULK_EDITING.md @@ -1,4 +1,4 @@ -# Bulk-edit devices by using via CSV Export/Import +# 📝Bulk-edit devices via CSV Export/Import > [!NOTE] > As always, backup everything, just in case. diff --git a/docs/NETWORK_TREE.md b/docs/NETWORK_TREE.md index 261f170f..64b0c803 100755 --- a/docs/NETWORK_TREE.md +++ b/docs/NETWORK_TREE.md @@ -16,6 +16,10 @@ Make sure you have a root device with the MAC `Internet` (No other MAC addresses * If port is empty or 0 a wifi icon is rendered, otherwise a ethernet port icon +> [!NOTE] +> +> [Bulk-edit devices](/docs/DEVICES_BULK_EDITING.md) by using the `CSV Export` functionality in the `Maintenance` section. You can use this to fix `Internet` node assignment issues. + ## 🔍Detailed example: In this example you will setup a device named `rapberrypi` as a `Switch` in our network. diff --git a/docs/README.md b/docs/README.md index 212ac134..8c1d5215 100755 --- a/docs/README.md +++ b/docs/README.md @@ -25,6 +25,7 @@ There is also an in-app Help / FAQ section that should be answering frequently a - [SMTP server config](/docs/SMTP.md) - [Subnets and VLANs configuration for arp-scan](/docs/SUBNETS.md) - [Home Assistant](/docs/HOME_ASSISTANT.md) +- [Bulk edit devices](/docs/DEVICES_BULK_EDITING.md) #### ⚙ System Management diff --git a/front/network.php b/front/network.php index b28b0b80..9dc6dc16 100755 --- a/front/network.php +++ b/front/network.php @@ -767,10 +767,18 @@ // --------------------------------------------------------------------------- function updateLeaf(leafMac,nodeMac) { - console.log(leafMac) - console.log(nodeMac) - saveData('updateNetworkLeaf', leafMac, nodeMac); - setTimeout("location.reload();", 1000); // refresh page after 1s + console.log(leafMac) // child + console.log(nodeMac) // parent + + // prevent the assignment of the Internet root node avoiding recursion when generating the network tree topology + if(leafMac.toLowerCase().includes('internet')) + { + showMessage(getString('Network_Cant_Assign')) + } + else{ + saveData('updateNetworkLeaf', leafMac, nodeMac); + setTimeout("location.reload();", 500); // refresh page + } } diff --git a/front/php/server/devices.php b/front/php/server/devices.php index fcebb78c..f1d70029 100755 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -1006,8 +1006,8 @@ function getLocations() { // ---------------------------------------------------------------------------------------- function updateNetworkLeaf() { - $nodeMac = $_REQUEST['value']; - $leafMac = $_REQUEST['id']; + $nodeMac = $_REQUEST['value']; // parent + $leafMac = $_REQUEST['id']; // child if ((false === filter_var($nodeMac , FILTER_VALIDATE_MAC) && $nodeMac != "Internet" && $nodeMac != "") || false === filter_var($leafMac , FILTER_VALIDATE_MAC) ) { throw new Exception('Invalid mac address'); diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index fd5bc4e2..e04ae4ab 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -408,6 +408,7 @@ "Network_Node" : "Network node", "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_NoAssignedDevices" : "This network node does not have any assigned devices (leaf nodes). Assign one from bellow or go to the Details tab of any device in Devices, and assign it to a network Node (MAC) and Port there.", "HelpFAQ_Title" : "Help / FAQ", "HelpFAQ_Cat_General" : "General",