mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-05 09:41:56 -07:00
Update config.json files to add 'ordeable' option and refactor cacheStrings function for consistency
This commit is contained in:
@@ -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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user