From 8676b7ccde12323ce3e77ed49ea089695a04ef2f Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Wed, 6 Sep 2023 22:03:28 +1000 Subject: [PATCH] Add cur_ScanMethod & fix Plugins display name in lists --- front/deviceDetails.php | 23 +-------------- front/js/pialert_common.js | 27 +++++++++++++++++ front/plugins/arp_scan/config.json | 35 ++++++++++++----------- front/plugins/dhcp_leases/script.py | 1 + front/plugins/dhcp_servers/script.py | 6 ++++ front/plugins/pihole_scan/config.json | 5 +++- front/plugins/snmp_discovery/config.json | 23 ++++++++++++++- front/plugins/snmp_discovery/script.py | 2 +- front/plugins/undiscoverables/config.json | 21 ++++++++++++++ front/plugins/unifi_import/config.json | 21 ++++++++++++++ 10 files changed, 123 insertions(+), 41 deletions(-) diff --git a/front/deviceDetails.php b/front/deviceDetails.php index 2c23c741..b32062f4 100755 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -795,27 +795,7 @@ if ($ENABLED_DARKMODE === True) { var devicesList = []; // this will contain a list the database row IDs of the devices ordered by the position displayed in the UI var devicesListAll = []; // this will contain a list off all devices - - $.get('php/server/devices.php?action=getDevicesList&status=all&forceDefaultOrder', function(data) { - - rawData = JSON.parse (data) - - devicesListAll = 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] - }}) - - setCache('devicesListAll', JSON.stringify(devicesListAll)) - - // Read parameters & Initialize components - main(); - }); - + main(); var pos = -1; var parPeriod = 'Front_Details_Period'; @@ -834,7 +814,6 @@ if ($ENABLED_DARKMODE === True) { - // ----------------------------------------------------------------------------- function main () { // Initialize MAC diff --git a/front/js/pialert_common.js b/front/js/pialert_common.js index 6efe84ee..e88a319c 100755 --- a/front/js/pialert_common.js +++ b/front/js/pialert_common.js @@ -506,6 +506,32 @@ function getNameByMacAddress(macAddress) { return "Unknown"; // Return a default value if MAC address is not found } +// ----------------------------------------------------------------------------- + +function initDeviceListAll() +{ + + $.get('php/server/devices.php?action=getDevicesList&status=all&forceDefaultOrder', function(data) { + + rawData = JSON.parse (data) + + devicesListAll = 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] + }}) + + setCache('devicesListAll', JSON.stringify(devicesListAll)) + }); + +} + +var devicesListAll = []; // this will contain a list off all devices + // ----------------------------------------------------------------------------- function isEmpty(value) { @@ -515,6 +541,7 @@ function isEmpty(value) // initialize cacheSettings() cacheStrings() +initDeviceListAll() console.log("init pialert_common.js") diff --git a/front/plugins/arp_scan/config.json b/front/plugins/arp_scan/config.json index 7720659a..939dce1c 100755 --- a/front/plugins/arp_scan/config.json +++ b/front/plugins/arp_scan/config.json @@ -267,22 +267,25 @@ }] } , { - "column": "Extra", - "mapped_to_column": "cur_ScanMethod", - "css_classes": "col-sm-2", - "show": true, - "type": "label", - "default_value":"", - "options": [], - "localized": ["name"], - "name":[{ - "language_code":"en_us", - "string" : "Scan method" - }, - { - "language_code":"es_es", - "string" : "Método de escaneado" - }] + "column": "Dummy", + "mapped_to_column": "cur_ScanMethod", + "mapped_to_column_data": { + "value": "arp-scan" + }, + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code":"en_us", + "string" : "Scan method" + }, + { + "language_code":"es_es", + "string" : "Método de escaneo" + }] } , { "column": "DateTimeCreated", diff --git a/front/plugins/dhcp_leases/script.py b/front/plugins/dhcp_leases/script.py index faeff7d4..f5cbe3bc 100755 --- a/front/plugins/dhcp_leases/script.py +++ b/front/plugins/dhcp_leases/script.py @@ -5,6 +5,7 @@ import pathlib import subprocess import argparse import os +import sys sys.path.append("/home/pi/pialert/front/plugins") sys.path.append('/home/pi/pialert/pialert') diff --git a/front/plugins/dhcp_servers/script.py b/front/plugins/dhcp_servers/script.py index 4438c60e..8372637b 100755 --- a/front/plugins/dhcp_servers/script.py +++ b/front/plugins/dhcp_servers/script.py @@ -3,6 +3,12 @@ import subprocess from datetime import datetime + +import sys + +sys.path.append("/home/pi/pialert/front/plugins") +sys.path.append('/home/pi/pialert/pialert') + from plugin_helper import Plugin_Objects, Plugin_Object from logger import mylog diff --git a/front/plugins/pihole_scan/config.json b/front/plugins/pihole_scan/config.json index d5b95f38..5db7497c 100755 --- a/front/plugins/pihole_scan/config.json +++ b/front/plugins/pihole_scan/config.json @@ -266,8 +266,11 @@ }] }, { - "column": "Extra", + "column": "Dummy", "mapped_to_column": "cur_ScanMethod", + "mapped_to_column_data": { + "value": "PIHOLE" + }, "css_classes": "col-sm-2", "show": true, "type": "label", diff --git a/front/plugins/snmp_discovery/config.json b/front/plugins/snmp_discovery/config.json index cbd8239b..19c13a70 100755 --- a/front/plugins/snmp_discovery/config.json +++ b/front/plugins/snmp_discovery/config.json @@ -246,7 +246,28 @@ "language_code":"es_es", "string" : "salida RAW" }] - }, + }, + { + "column": "Dummy", + "mapped_to_column": "cur_ScanMethod", + "mapped_to_column_data": { + "value": "SNMPDSC" + }, + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code":"en_us", + "string" : "Scan method" + }, + { + "language_code":"es_es", + "string" : "Método de escaneo" + }] + } , { "column": "Status", "css_classes": "col-sm-1", diff --git a/front/plugins/snmp_discovery/script.py b/front/plugins/snmp_discovery/script.py index cf31e3d6..6a705319 100755 --- a/front/plugins/snmp_discovery/script.py +++ b/front/plugins/snmp_discovery/script.py @@ -79,7 +79,7 @@ def main(): plugin_objects.add_object( primaryId=macAddress, - secondaryId=ipAddress, + secondaryId=ipAddress.strip(), # Remove leading/trailing spaces from IP watched1='(unknown)', watched2=snmpwalkArgs[6], # router IP extra=line, diff --git a/front/plugins/undiscoverables/config.json b/front/plugins/undiscoverables/config.json index 75514a65..2080c739 100755 --- a/front/plugins/undiscoverables/config.json +++ b/front/plugins/undiscoverables/config.json @@ -292,6 +292,27 @@ "string" : "Cambiado" }] }, + { + "column": "Dummy", + "mapped_to_column": "cur_ScanMethod", + "mapped_to_column_data": { + "value": "UNDIS" + }, + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code":"en_us", + "string" : "Scan method" + }, + { + "language_code":"es_es", + "string" : "Método de escaneo" + }] + } , { "column": "ForeignKey", "css_classes": "col-sm-2", diff --git a/front/plugins/unifi_import/config.json b/front/plugins/unifi_import/config.json index b3d8cac5..d68e5ffd 100755 --- a/front/plugins/unifi_import/config.json +++ b/front/plugins/unifi_import/config.json @@ -319,6 +319,27 @@ "string" : "Kommentar" }] }, + { + "column": "Dummy", + "mapped_to_column": "cur_ScanMethod", + "mapped_to_column_data": { + "value": "UNFIMP" + }, + "css_classes": "col-sm-2", + "show": true, + "type": "label", + "default_value":"", + "options": [], + "localized": ["name"], + "name":[{ + "language_code":"en_us", + "string" : "Scan method" + }, + { + "language_code":"es_es", + "string" : "Método de escaneo" + }] + } , { "column": "Extra", "css_classes": "col-sm-3",