From 729c24029fe5775157b60e04cff1be1be07d3651 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Thu, 2 Jan 2025 10:15:58 +1100 Subject: [PATCH] docs + fixes to CustomProps --- README.md | 4 +- dockerfiles/README.md | 8 +- docs/HW_INSTALL.md | 5 +- front/deviceDetailsEdit.php | 82 +++++++++---------- front/devices.php | 2 +- front/php/server/query_replace_config.php | 55 +++++++++++++ front/php/templates/language/en_us.json | 4 +- front/plugins/newdev_template/config.json | 4 +- server/graphql_server/graphql_server_start.py | 5 +- server/helper.py | 2 +- 10 files changed, 113 insertions(+), 58 deletions(-) create mode 100755 front/php/server/query_replace_config.php diff --git a/README.md b/README.md index 417d5735..4a0adeae 100755 --- a/README.md +++ b/README.md @@ -19,8 +19,8 @@ Head to [https://netalertx.com/](https://netalertx.com/) for more gifs and scree ๐Ÿ“ท Click for more screenshots | ![Main screen][main] | ![device_details 1][device_details] | ![Screen network][network] | - | ![presence][presence] | ![maintenance][maintenance] | ![settings][settings] | |----------------------|----------------------|----------------------| + | ![presence][presence] | ![maintenance][maintenance] | ![settings][settings] | | ![sync_hub][sync_hub] | ![report1][report1] | ![device_nmap][device_nmap] | @@ -93,8 +93,6 @@ Thank you to all the wonderful people who are sponsoring this project. - -
Click for more ways to donate diff --git a/dockerfiles/README.md b/dockerfiles/README.md index fdaa7f79..13873b1e 100755 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -1,4 +1,3 @@ -[![GitHub Committed](https://img.shields.io/github/last-commit/jokob-sk/NetAlertX?color=40ba12&label=Committed&logo=GitHub&logoColor=fff&style=for-the-badge)](https://github.com/jokob-sk/NetAlertX) [![Docker Size](https://img.shields.io/docker/image-size/jokobsk/netalertx?label=Size&logo=Docker&color=0aa8d2&logoColor=fff&style=for-the-badge)](https://hub.docker.com/r/jokobsk/netalertx) [![Docker Pulls](https://img.shields.io/docker/pulls/jokobsk/netalertx?label=Pulls&logo=docker&color=0aa8d2&logoColor=fff&style=for-the-badge)](https://hub.docker.com/r/jokobsk/netalertx) [![GitHub Release](https://img.shields.io/github/v/release/jokob-sk/NetAlertX?color=0aa8d2&logoColor=fff&logo=GitHub&style=for-the-badge)](https://github.com/jokob-sk/NetAlertX/releases) @@ -67,12 +66,11 @@ See alternative [docked-compose examples](https://github.com/jokob-sk/NetAlertX/ ### Initial setup - If unavailable, the app generates a default `app.conf` and `app.db` file on the first run. -- The preferred way is to manage the configuration via the Settings section in the UI. -- You can modify [app.conf](https://github.com/jokob-sk/NetAlertX/tree/main/config) directly, if needed. +- The preferred way is to manage the configuration via the Settings section in the UI, if UI is inaccessible you can modify [app.conf](https://github.com/jokob-sk/NetAlertX/tree/main/back) in the `/app/config/` folder directly -### Setting up scanning +### Setting up scanners -You have to specify which network(s) should be scanned. This is done by entering subnets that are accessible from the host. Please specify at least one valid subnet and interface in the `SCAN_SUBNETS` setting and see the documentation on [How to set up multiple SUBNETS, VLANs and what are limitations](https://github.com/jokob-sk/NetAlertX/blob/main/docs/SUBNETS.md) for troubleshooting and more advanced scenarios. +You have to specify which network(s) should be scanned. This is done by entering subnets that are accessible from the host. If you use the default `ARPSCAN` plugin, you have to specify at least one valid subnet and interface in the `SCAN_SUBNETS` setting. See the documentation on [How to set up multiple SUBNETS, VLANs and what are limitations](https://github.com/jokob-sk/NetAlertX/blob/main/docs/SUBNETS.md) for troubleshooting and more advanced scenarios. If you are running PiHole you can synchronize devices directly. Check the [PiHole configuration guide](https://github.com/jokob-sk/NetAlertX/blob/main/docs/PIHOLE_GUIDE.md) for details. diff --git a/docs/HW_INSTALL.md b/docs/HW_INSTALL.md index d00982b4..758a88ec 100755 --- a/docs/HW_INSTALL.md +++ b/docs/HW_INSTALL.md @@ -5,7 +5,7 @@ To download and install NetAlertX on the hardware/server directly use the `curl` > [!NOTE] > This is an Experimental feature ๐Ÿงช and it relies on community support. > -> Looking for maintainers for this installation method ๐Ÿ™‚ +> ๐Ÿ™ Looking for maintainers for this installation method ๐Ÿ™‚ > > There is no guarantee that the install script or any other script will gracefully handle other installed software. > Data loss is a possibility, **it is recommended to install NetAlertX using the supplied Docker image**. @@ -36,6 +36,9 @@ Some facts about what and where something will be changed/installed by the HW in ## ๐Ÿ“ฅ Installation via CURL +> [!TIP] +> If the below fails try grabbing and installing one of the [previous releases](https://github.com/jokob-sk/NetAlertX/releases) and run the installation from the zip package. + ```bash curl -o install.debian.sh https://raw.githubusercontent.com/jokob-sk/NetAlertX/main/install/install.debian.sh && sudo chmod +x install.debian.sh && sudo ./install.debian.sh ``` diff --git a/front/deviceDetailsEdit.php b/front/deviceDetailsEdit.php index f4b1ad88..f353321a 100755 --- a/front/deviceDetailsEdit.php +++ b/front/deviceDetailsEdit.php @@ -358,51 +358,51 @@ showSpinner(); // Update data to server using POST -$.post('php/server/devices.php?action=setDeviceData', { - mac: $('#NEWDEV_devMac').val(), - name: encodeURIComponent($('#NEWDEV_devName').val().replace(/'/g, "")), - owner: encodeURIComponent($('#NEWDEV_devOwner').val().replace(/'/g, "")), - type: $('#NEWDEV_devType').val().replace(/'/g, ""), - vendor: encodeURIComponent($('#NEWDEV_devVendor').val().replace(/'/g, "")), - icon: encodeURIComponent($('#NEWDEV_devIcon').val()), - favorite: ($('#NEWDEV_devFavorite')[0].checked * 1), - group: encodeURIComponent($('#NEWDEV_devGroup').val().replace(/'/g, "")), - location: encodeURIComponent($('#NEWDEV_devLocation').val().replace(/'/g, "")), - comments: encodeURIComponent(encodeSpecialChars($('#NEWDEV_devComments').val())), - networknode: $('#NEWDEV_devParentMAC').val(), - networknodeport: $('#NEWDEV_devParentPort').val(), - ssid: $('#NEWDEV_devSSID').val(), - networksite: $('#NEWDEV_devSite').val(), - staticIP: ($('#NEWDEV_devStaticIP')[0].checked * 1), - scancycle: "1", - alertevents: ($('#NEWDEV_devAlertEvents')[0].checked * 1), - alertdown: ($('#NEWDEV_devAlertDown')[0].checked * 1), - skiprepeated: $('#NEWDEV_devSkipRepeated').val().split(' ')[0], - newdevice: ($('#NEWDEV_devIsNew')[0].checked * 1), - archived: ($('#NEWDEV_devIsArchived')[0].checked * 1), - devFirstConnection: ($('#NEWDEV_devFirstConnection').val()), - devLastConnection: ($('#NEWDEV_devLastConnection').val()), - devCustomProps: btoa(JSON.stringify(collectTableData("#NEWDEV_devCustomProps_table"))), - ip: ($('#NEWDEV_devLastIP').val()), - createNew: createNew -}, function(msg) { - showMessage(msg); + $.post('php/server/devices.php?action=setDeviceData', { + mac: $('#NEWDEV_devMac').val(), + name: encodeURIComponent($('#NEWDEV_devName').val().replace(/'/g, "")), + owner: encodeURIComponent($('#NEWDEV_devOwner').val().replace(/'/g, "")), + type: $('#NEWDEV_devType').val().replace(/'/g, ""), + vendor: encodeURIComponent($('#NEWDEV_devVendor').val().replace(/'/g, "")), + icon: encodeURIComponent($('#NEWDEV_devIcon').val()), + favorite: ($('#NEWDEV_devFavorite')[0].checked * 1), + group: encodeURIComponent($('#NEWDEV_devGroup').val().replace(/'/g, "")), + location: encodeURIComponent($('#NEWDEV_devLocation').val().replace(/'/g, "")), + comments: encodeURIComponent(encodeSpecialChars($('#NEWDEV_devComments').val())), + networknode: $('#NEWDEV_devParentMAC').val(), + networknodeport: $('#NEWDEV_devParentPort').val(), + ssid: $('#NEWDEV_devSSID').val(), + networksite: $('#NEWDEV_devSite').val(), + staticIP: ($('#NEWDEV_devStaticIP')[0].checked * 1), + scancycle: "1", + alertevents: ($('#NEWDEV_devAlertEvents')[0].checked * 1), + alertdown: ($('#NEWDEV_devAlertDown')[0].checked * 1), + skiprepeated: $('#NEWDEV_devSkipRepeated').val().split(' ')[0], + newdevice: ($('#NEWDEV_devIsNew')[0].checked * 1), + archived: ($('#NEWDEV_devIsArchived')[0].checked * 1), + devFirstConnection: ($('#NEWDEV_devFirstConnection').val()), + devLastConnection: ($('#NEWDEV_devLastConnection').val()), + devCustomProps: btoa(JSON.stringify(collectTableData("#NEWDEV_devCustomProps_table"))), + ip: ($('#NEWDEV_devLastIP').val()), + createNew: createNew + }, function(msg) { + showMessage(msg); - // Remove navigation prompt "Are you sure you want to leave..." - window.onbeforeunload = null; - somethingChanged = false; + // Remove navigation prompt "Are you sure you want to leave..." + window.onbeforeunload = null; + somethingChanged = false; - // refresh API - updateApi("devices,appevents"); + // refresh API + updateApi("devices,appevents"); - // Callback function - if (typeof refreshCallback == 'function') { - refreshCallback(direction); - } + // Callback function + if (typeof refreshCallback == 'function') { + refreshCallback(direction); + } - // Everything loaded - hideSpinner(); -}); + // Everything loaded + hideSpinner(); + }); } diff --git a/front/devices.php b/front/devices.php index eef26129..2c7143e8 100755 --- a/front/devices.php +++ b/front/devices.php @@ -897,7 +897,7 @@ function getMacsOfShownDevices() { function renderCustomProps(custProps, mac) { // Decode and parse the custom properties - // console.log(custProps); + console.log(custProps); const props = JSON.parse(atob(custProps)); let html = ""; diff --git a/front/php/server/query_replace_config.php b/front/php/server/query_replace_config.php new file mode 100755 index 00000000..03898d7e --- /dev/null +++ b/front/php/server/query_replace_config.php @@ -0,0 +1,55 @@ + diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index bfe0daf4..f87095d0 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -285,7 +285,7 @@ "Events_Tablelenght": "Show _MENU_ entries", "Events_Tablelenght_all": "All", "Events_Title": "Events", - "GRAPHQL_PORT_description": "The port number of the GraphQL server.", + "GRAPHQL_PORT_description": "The port number of the GraphQL server. Make sure the port is unique across all your applications on this host and NetAlertX instances.", "GRAPHQL_PORT_name": "GraphQL port", "Gen_Action": "Action", "Gen_Add": "Add", @@ -489,7 +489,7 @@ "Maintenance_themeselector_lable": "Select Skin", "Maintenance_themeselector_text": "The change takes place on the server side, so it affects all devices in use.", "Maintenance_version": "App updates", - "NETWORK_DEVICE_TYPES_description": "Which device types are allowed to be used as network devices in the Network view. The device type has to match exactly the Type setting on a specific device in Device details. Do not remove existing types, only add new ones.", + "NETWORK_DEVICE_TYPES_description": "Which device types are allowed to be used as network devices in the Network view. The device type has to match exactly the Type setting on a specific device in Device details. Add it on teh Device via the + button. Do not remove existing types, only add new ones.", "NETWORK_DEVICE_TYPES_name": "Network device types", "Navigation_About": "About", "Navigation_Devices": "Devices", diff --git a/front/plugins/newdev_template/config.json b/front/plugins/newdev_template/config.json index d93e847d..49f1f2b0 100755 --- a/front/plugins/newdev_template/config.json +++ b/front/plugins/newdev_template/config.json @@ -716,7 +716,7 @@ "description": [ { "language_code": "en_us", - "string": "The type of the device." + "string": "The type of the device. Custom Network device types from the NETWORK_DEVICE_TYPES setting are not automatically added, you need to add it via the + button onthe device itself." } ] }, @@ -1330,7 +1330,7 @@ "description": [ { "language_code": "en_us", - "string": "Indicates whether the device is archived. The default value of the Archived checkbox." + "string": "Indicates whether the device is archived. If you archive a device and the device is offline it will be hidden from My Devices." } ] }, diff --git a/server/graphql_server/graphql_server_start.py b/server/graphql_server/graphql_server_start.py index 5a9b1c2b..7b92a2a4 100755 --- a/server/graphql_server/graphql_server_start.py +++ b/server/graphql_server/graphql_server_start.py @@ -32,8 +32,9 @@ def graphql_endpoint(): api_token_value = get_setting_value("API_TOKEN") if incoming_header_token != f"Bearer {api_token_value}": - mylog('verbose', [f'[graphql_server] Unauthorized access attempt']) - return jsonify({"error": "Unauthorized"}), 401 + msg = '[graphql_server] Unauthorized access attempt - make sure your GRAPHQL_PORT and API_TOKEN settings are correct.' + mylog('verbose', [msg]) + return jsonify({"error": msg}), 401 # Retrieve and log request data data = request.get_json() diff --git a/server/helper.py b/server/helper.py index 1be9d9ab..b4352c44 100755 --- a/server/helper.py +++ b/server/helper.py @@ -365,7 +365,7 @@ def setting_value_to_python_type(set_type, set_value): transformers = element_with_input_value.get('transformers', []) # Convert value based on dataType and elementType - if dataType == 'string' and elementType in ['input', 'select', 'textarea']: + if dataType == 'string' and elementType in ['input', 'select', 'textarea', 'datatable']: value = reverseTransformers(str(set_value), transformers) elif dataType == 'integer' and (elementType == 'input' or elementType == 'select'):