From 0a7ecb5b7c2ff91fd5e3c2900b4e5359d48d26a4 Mon Sep 17 00:00:00 2001 From: "Jokob @NetAlertX" <96159884+jokob-sk@users.noreply.github.com> Date: Tue, 17 Mar 2026 09:22:25 +0000 Subject: [PATCH] Update config.json files to add 'ordeable' option and refactor cacheStrings function for consistency --- front/js/cache.js | 4 ++-- front/plugins/arp_scan/config.json | 4 ++-- front/plugins/ddns_update/config.json | 4 ++-- front/plugins/dhcp_leases/config.json | 4 ++-- front/plugins/dhcp_servers/config.json | 4 ++-- front/plugins/internet_ip/config.json | 4 ++-- front/plugins/internet_speedtest/config.json | 4 ++-- front/plugins/nmap_scan/config.json | 4 ++-- front/plugins/omada_sdn_imp/config.json | 4 ++-- front/plugins/omada_sdn_openapi/config.json | 4 ++-- front/plugins/pihole_scan/config.json | 4 ++-- front/plugins/snmp_discovery/config.json | 4 ++-- front/plugins/unifi_import/config.json | 4 ++-- front/plugins/vendor_update/config.json | 4 ++-- front/plugins/website_monitor/config.json | 4 ++-- front/report.php | 2 +- server/db/db_upgrade.py | 2 +- server/initialise.py | 4 ++++ server/scan/name_resolution.py | 12 ++++++------ test/backend/test_notification_templates.py | 14 +++++++------- 20 files changed, 49 insertions(+), 45 deletions(-) diff --git a/front/js/cache.js b/front/js/cache.js index 12c881d3..575a40d4 100644 --- a/front/js/cache.js +++ b/front/js/cache.js @@ -290,7 +290,7 @@ function getSetting (key) { // ----------------------------------------------------------------------------- function cacheStrings() { return new Promise((resolve, reject) => { - if(getCache(CACHE_KEYS.initFlag('cacheStrings')) === "true") + if(getCache(CACHE_KEYS.initFlag('cacheStrings_v2')) === "true") { // Core strings are cached, but plugin strings may have failed silently on // the first load (non-fatal fetch). Always re-fetch them so that plugin @@ -370,7 +370,7 @@ function cacheStrings() { }) .catch((error) => { // Handle failure in any of the language processing - handleFailure('cacheStrings'); + handleFailure('cacheStrings_v2'); reject(error); }); diff --git a/front/plugins/arp_scan/config.json b/front/plugins/arp_scan/config.json index 973927c4..484144ab 100755 --- a/front/plugins/arp_scan/config.json +++ b/front/plugins/arp_scan/config.json @@ -338,7 +338,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -387,7 +387,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/ddns_update/config.json b/front/plugins/ddns_update/config.json index 2337f809..e0d267ed 100755 --- a/front/plugins/ddns_update/config.json +++ b/front/plugins/ddns_update/config.json @@ -432,7 +432,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -477,7 +477,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/dhcp_leases/config.json b/front/plugins/dhcp_leases/config.json index b760f8d3..5beab1e7 100755 --- a/front/plugins/dhcp_leases/config.json +++ b/front/plugins/dhcp_leases/config.json @@ -753,7 +753,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -802,7 +802,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/dhcp_servers/config.json b/front/plugins/dhcp_servers/config.json index 049ec58d..313aea76 100755 --- a/front/plugins/dhcp_servers/config.json +++ b/front/plugins/dhcp_servers/config.json @@ -478,7 +478,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -519,7 +519,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/internet_ip/config.json b/front/plugins/internet_ip/config.json index 679913d5..65a0c5c2 100755 --- a/front/plugins/internet_ip/config.json +++ b/front/plugins/internet_ip/config.json @@ -324,7 +324,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -369,7 +369,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/internet_speedtest/config.json b/front/plugins/internet_speedtest/config.json index 49df80eb..71a6e77d 100755 --- a/front/plugins/internet_speedtest/config.json +++ b/front/plugins/internet_speedtest/config.json @@ -561,7 +561,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -610,7 +610,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/nmap_scan/config.json b/front/plugins/nmap_scan/config.json index b5326075..301fc4d8 100755 --- a/front/plugins/nmap_scan/config.json +++ b/front/plugins/nmap_scan/config.json @@ -553,7 +553,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -594,7 +594,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/omada_sdn_imp/config.json b/front/plugins/omada_sdn_imp/config.json index e4560f44..a4cbd014 100755 --- a/front/plugins/omada_sdn_imp/config.json +++ b/front/plugins/omada_sdn_imp/config.json @@ -429,7 +429,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -462,7 +462,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/omada_sdn_openapi/config.json b/front/plugins/omada_sdn_openapi/config.json index b3737b78..c56eaded 100755 --- a/front/plugins/omada_sdn_openapi/config.json +++ b/front/plugins/omada_sdn_openapi/config.json @@ -402,7 +402,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -435,7 +435,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/pihole_scan/config.json b/front/plugins/pihole_scan/config.json index c8a371de..722723a0 100755 --- a/front/plugins/pihole_scan/config.json +++ b/front/plugins/pihole_scan/config.json @@ -290,7 +290,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -331,7 +331,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/snmp_discovery/config.json b/front/plugins/snmp_discovery/config.json index 1c2ea990..95240621 100755 --- a/front/plugins/snmp_discovery/config.json +++ b/front/plugins/snmp_discovery/config.json @@ -658,7 +658,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -699,7 +699,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/unifi_import/config.json b/front/plugins/unifi_import/config.json index b5274514..c9cf3c0a 100755 --- a/front/plugins/unifi_import/config.json +++ b/front/plugins/unifi_import/config.json @@ -1026,7 +1026,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -1067,7 +1067,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/vendor_update/config.json b/front/plugins/vendor_update/config.json index 17f1f925..6cba3f85 100755 --- a/front/plugins/vendor_update/config.json +++ b/front/plugins/vendor_update/config.json @@ -299,7 +299,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -344,7 +344,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/plugins/website_monitor/config.json b/front/plugins/website_monitor/config.json index 251605fe..26db306f 100755 --- a/front/plugins/website_monitor/config.json +++ b/front/plugins/website_monitor/config.json @@ -538,7 +538,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] @@ -579,7 +579,7 @@ "elements": [ { "elementType": "select", - "elementOptions": [{ "multiple": "true" }], + "elementOptions": [{ "multiple": "true", "ordeable": "true"}], "transformers": [] } ] diff --git a/front/report.php b/front/report.php index d27efdc8..6f6c5bf6 100755 --- a/front/report.php +++ b/front/report.php @@ -174,7 +174,7 @@ } else { // Initial data load - updateData('HTML', -1); // Default format to HTML and load the latest report + updateData('html', -1); // Default format to HTML and load the latest report } }); diff --git a/server/db/db_upgrade.py b/server/db/db_upgrade.py index 83739315..03ca83a4 100755 --- a/server/db/db_upgrade.py +++ b/server/db/db_upgrade.py @@ -817,7 +817,7 @@ def migrate_to_camelcase(sql) -> bool: for table, column_map in _CAMELCASE_COLUMN_MAP.items(): # Check table exists - sql.execute(f"SELECT name FROM sqlite_master WHERE type='table' AND name=?", (table,)) + sql.execute("SELECT name FROM sqlite_master WHERE type='table' AND name=?", (table,)) if not sql.fetchone(): mylog("verbose", [f"[db_upgrade] Table '{table}' does not exist — skipping"]) continue diff --git a/server/initialise.py b/server/initialise.py index 49e50b05..fcd48152 100755 --- a/server/initialise.py +++ b/server/initialise.py @@ -865,6 +865,10 @@ _column_replacements = { # Session columns r"\bses_MAC\b": "sesMac", r"\bses_IP\b": "sesIp", + r"\bses_DateTimeConnection\b": "sesDateTimeConnection", + r"\bses_DateTimeDisconnection\b": "sesDateTimeDisconnection", + r"\bses_EventTypeConnection\b": "sesEventTypeConnection", + r"\bses_EventTypeDisconnection\b": "sesEventTypeDisconnection", r"\bses_StillConnected\b": "sesStillConnected", r"\bses_AdditionalInfo\b": "sesAdditionalInfo", # Plugin columns (templates + WATCH values) diff --git a/server/scan/name_resolution.py b/server/scan/name_resolution.py index e05b4a15..d3cf654d 100755 --- a/server/scan/name_resolution.py +++ b/server/scan/name_resolution.py @@ -23,10 +23,10 @@ class NameResolver: nameNotFound = ResolvedName() # Check by MAC - sql.execute(f""" + sql.execute(""" SELECT watchedValue2 FROM Plugins_Objects - WHERE plugin = '{plugin}' AND objectPrimaryId = '{pMAC}' - """) + WHERE plugin = ? AND objectPrimaryId = ? + """, (plugin, pMAC)) result = sql.fetchall() # self.db.commitDB() # Issue #1251: Optimize name resolution lookup if result: @@ -36,10 +36,10 @@ class NameResolver: # Check name by IP if enabled if get_setting_value('NEWDEV_IP_MATCH_NAME'): - sql.execute(f""" + sql.execute(""" SELECT watchedValue2 FROM Plugins_Objects - WHERE plugin = '{plugin}' AND objectSecondaryId = '{pIP}' - """) + WHERE plugin = ? AND objectSecondaryId = ? + """, (plugin, pIP)) result = sql.fetchall() # self.db.commitDB() # Issue #1251: Optimize name resolution lookup if result: diff --git a/test/backend/test_notification_templates.py b/test/backend/test_notification_templates.py index f4448fd3..3a17237f 100644 --- a/test/backend/test_notification_templates.py +++ b/test/backend/test_notification_templates.py @@ -247,21 +247,21 @@ class TestConstructNotificationsTemplates(unittest.TestCase): mock_setting.side_effect = self._setting_factory({ "NTFPRCS_TEXT_SECTION_HEADERS": True, - "NTFPRCS_TEXT_TEMPLATE_down_reconnected": "{devName} ({eve_MAC}) reconnected at {eve_DateTime}", + "NTFPRCS_TEXT_TEMPLATE_down_reconnected": "{devName} ({eveMac}) reconnected at {eveDateTime}", }) reconnected = [ { "devName": "Switch", - "eve_MAC": "aa:11:bb:22:cc:33", + "eveMac": "aa:11:bb:22:cc:33", "devVendor": "Netgear", - "eve_IP": "10.0.0.2", - "eve_DateTime": "2025-01-15 09:30:00", - "eve_EventType": "Down Reconnected", + "eveIp": "10.0.0.2", + "eveDateTime": "2025-01-15 09:30:00", + "eveEventType": "Down Reconnected", "devComments": "", } ] - columns = ["devName", "eve_MAC", "devVendor", "eve_IP", "eve_DateTime", "eve_EventType", "devComments"] + columns = ["devName", "eveMac", "devVendor", "eveIp", "eveDateTime", "eveEventType", "devComments"] json_data = _make_json("down_reconnected", reconnected, columns, "🔁 Reconnected down devices") _, text = construct_notifications(json_data, "down_reconnected") @@ -288,7 +288,7 @@ class TestConstructNotificationsTemplates(unittest.TestCase): # Get HTML with template mock_setting.side_effect = self._setting_factory({ "NTFPRCS_TEXT_SECTION_HEADERS": True, - "NTFPRCS_TEXT_TEMPLATE_new_devices": "{devName} ({eve_MAC})", + "NTFPRCS_TEXT_TEMPLATE_new_devices": "{devName} ({eveMac})", }) html_with, _ = construct_notifications(json_data, "new_devices")