Update config.json files to add 'ordeable' option and refactor cacheStrings function for consistency

This commit is contained in:
Jokob @NetAlertX
2026-03-17 09:22:25 +00:00
parent c7399215ec
commit 0a7ecb5b7c
20 changed files with 49 additions and 45 deletions

View File

@@ -290,7 +290,7 @@ function getSetting (key) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function cacheStrings() { function cacheStrings() {
return new Promise((resolve, reject) => { 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 // 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 // the first load (non-fatal fetch). Always re-fetch them so that plugin
@@ -370,7 +370,7 @@ function cacheStrings() {
}) })
.catch((error) => { .catch((error) => {
// Handle failure in any of the language processing // Handle failure in any of the language processing
handleFailure('cacheStrings'); handleFailure('cacheStrings_v2');
reject(error); reject(error);
}); });

View File

@@ -338,7 +338,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -387,7 +387,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -432,7 +432,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -477,7 +477,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -753,7 +753,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -802,7 +802,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -478,7 +478,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -519,7 +519,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -324,7 +324,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -369,7 +369,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -561,7 +561,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -610,7 +610,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -553,7 +553,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -594,7 +594,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -429,7 +429,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -462,7 +462,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -402,7 +402,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -435,7 +435,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -290,7 +290,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -331,7 +331,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -658,7 +658,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -699,7 +699,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -1026,7 +1026,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -1067,7 +1067,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -299,7 +299,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -344,7 +344,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -538,7 +538,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]
@@ -579,7 +579,7 @@
"elements": [ "elements": [
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true"}],
"transformers": [] "transformers": []
} }
] ]

View File

@@ -174,7 +174,7 @@
} else { } else {
// Initial data load // 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
} }
}); });

View File

@@ -817,7 +817,7 @@ def migrate_to_camelcase(sql) -> bool:
for table, column_map in _CAMELCASE_COLUMN_MAP.items(): for table, column_map in _CAMELCASE_COLUMN_MAP.items():
# Check table exists # 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(): if not sql.fetchone():
mylog("verbose", [f"[db_upgrade] Table '{table}' does not exist — skipping"]) mylog("verbose", [f"[db_upgrade] Table '{table}' does not exist — skipping"])
continue continue

View File

@@ -865,6 +865,10 @@ _column_replacements = {
# Session columns # Session columns
r"\bses_MAC\b": "sesMac", r"\bses_MAC\b": "sesMac",
r"\bses_IP\b": "sesIp", 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_StillConnected\b": "sesStillConnected",
r"\bses_AdditionalInfo\b": "sesAdditionalInfo", r"\bses_AdditionalInfo\b": "sesAdditionalInfo",
# Plugin columns (templates + WATCH values) # Plugin columns (templates + WATCH values)

View File

@@ -23,10 +23,10 @@ class NameResolver:
nameNotFound = ResolvedName() nameNotFound = ResolvedName()
# Check by MAC # Check by MAC
sql.execute(f""" sql.execute("""
SELECT watchedValue2 FROM Plugins_Objects SELECT watchedValue2 FROM Plugins_Objects
WHERE plugin = '{plugin}' AND objectPrimaryId = '{pMAC}' WHERE plugin = ? AND objectPrimaryId = ?
""") """, (plugin, pMAC))
result = sql.fetchall() result = sql.fetchall()
# self.db.commitDB() # Issue #1251: Optimize name resolution lookup # self.db.commitDB() # Issue #1251: Optimize name resolution lookup
if result: if result:
@@ -36,10 +36,10 @@ class NameResolver:
# Check name by IP if enabled # Check name by IP if enabled
if get_setting_value('NEWDEV_IP_MATCH_NAME'): if get_setting_value('NEWDEV_IP_MATCH_NAME'):
sql.execute(f""" sql.execute("""
SELECT watchedValue2 FROM Plugins_Objects SELECT watchedValue2 FROM Plugins_Objects
WHERE plugin = '{plugin}' AND objectSecondaryId = '{pIP}' WHERE plugin = ? AND objectSecondaryId = ?
""") """, (plugin, pIP))
result = sql.fetchall() result = sql.fetchall()
# self.db.commitDB() # Issue #1251: Optimize name resolution lookup # self.db.commitDB() # Issue #1251: Optimize name resolution lookup
if result: if result:

View File

@@ -247,21 +247,21 @@ class TestConstructNotificationsTemplates(unittest.TestCase):
mock_setting.side_effect = self._setting_factory({ mock_setting.side_effect = self._setting_factory({
"NTFPRCS_TEXT_SECTION_HEADERS": True, "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 = [ reconnected = [
{ {
"devName": "Switch", "devName": "Switch",
"eve_MAC": "aa:11:bb:22:cc:33", "eveMac": "aa:11:bb:22:cc:33",
"devVendor": "Netgear", "devVendor": "Netgear",
"eve_IP": "10.0.0.2", "eveIp": "10.0.0.2",
"eve_DateTime": "2025-01-15 09:30:00", "eveDateTime": "2025-01-15 09:30:00",
"eve_EventType": "Down Reconnected", "eveEventType": "Down Reconnected",
"devComments": "", "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") json_data = _make_json("down_reconnected", reconnected, columns, "🔁 Reconnected down devices")
_, text = construct_notifications(json_data, "down_reconnected") _, text = construct_notifications(json_data, "down_reconnected")
@@ -288,7 +288,7 @@ class TestConstructNotificationsTemplates(unittest.TestCase):
# Get HTML with template # Get HTML with template
mock_setting.side_effect = self._setting_factory({ mock_setting.side_effect = self._setting_factory({
"NTFPRCS_TEXT_SECTION_HEADERS": True, "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") html_with, _ = construct_notifications(json_data, "new_devices")