fix HRS_TO_KEEP_NEWDEV #777

This commit is contained in:
jokob-sk
2024-08-31 12:56:46 +10:00
parent 3473fabdbf
commit 955472ef5c
7 changed files with 85 additions and 52 deletions
+4 -4
View File
@@ -1,13 +1,13 @@
# 🖧🔍 Network scanner & notification framework
Get visibility of what's going on on your WIFI/LAN network. Schedule scans for devices, port changes and get alerts if unknown devices or changes are found. Write your own [Plugins](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins#readme) with auto-generated UI and in-build notification system. Build out and easily maintain your network source of truth (NSoT).
[![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) [![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 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) [![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) [![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)
[![Discord](https://img.shields.io/discord/1274490466481602755?color=0aa8d2&logoColor=fff&logo=Discord&style=for-the-badge)](https://discord.gg/UQnnHNYV) [![Discord](https://img.shields.io/discord/1274490466481602755?color=0aa8d2&logoColor=fff&logo=Discord&style=for-the-badge)](https://discord.gg/UQnnHNYV)
# 🖧🔍 Network scanner & notification framework
Get visibility of what's going on on your WIFI/LAN network. Schedule scans for devices, port changes and get alerts if unknown devices or changes are found. Write your own [Plugins](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins#readme) with auto-generated UI and in-build notification system. Build out and easily maintain your network source of truth (NSoT).
| 🐳 [Docker hub](https://registry.hub.docker.com/r/jokobsk/netalertx) | 📑 [Docker guide](https://github.com/jokob-sk/NetAlertX/blob/main/dockerfiles/README.md) |🆕 [Release notes](https://github.com/jokob-sk/NetAlertX/releases) | 📚 [All Docs](https://github.com/jokob-sk/NetAlertX/tree/main/docs) | | 🐳 [Docker hub](https://registry.hub.docker.com/r/jokobsk/netalertx) | 📑 [Docker guide](https://github.com/jokob-sk/NetAlertX/blob/main/dockerfiles/README.md) |🆕 [Release notes](https://github.com/jokob-sk/NetAlertX/releases) | 📚 [All Docs](https://github.com/jokob-sk/NetAlertX/tree/main/docs) |
|----------------------|----------------------| ----------------------| ----------------------| |----------------------|----------------------| ----------------------| ----------------------|
+22 -5
View File
@@ -1079,6 +1079,23 @@ input[readonly] {
margin-bottom:20px; margin-bottom:20px;
} }
#settingsPage .select2-selection
{
width: initial;
display: inline-block;
}
#settingsPage .select2-selection
{
background-color: rgb(96, 96, 96);
}
#settingsPage .select2-container
{
width: 100% !important;
}
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/* Devices page */ /* Devices page */
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
@@ -1110,18 +1127,18 @@ input[readonly] {
cursor: -webkit-grab; cursor: -webkit-grab;
} }
.db_info_table_row .select2-container--default .select2-selection--multiple .select2-selection__choice .select2-container--default .select2-selection--multiple .select2-selection__choice
{ {
background-color:#258744; background-color:#258744 !important;
} }
.db_info_table_row .select2-container--default .select2-selection--multiple .select2-container--default .select2-selection--multiple
{ {
background-color:#606060; background-color:#606060 !important;
} }
.select2-container .select2-dropdown .select2-container .select2-dropdown
{ {
background-color:#606060; background-color:#606060 !important;
} }
.networkPageHelp{ .networkPageHelp{
+8
View File
@@ -568,6 +568,10 @@ function applyTransformers(val, transformers) {
val = btoa(val); val = btoa(val);
} }
break; break;
case "getString":
// no change
val = val;
break;
default: default:
console.warn(`Unknown transformer: ${transformer}`); console.warn(`Unknown transformer: ${transformer}`);
} }
@@ -590,6 +594,10 @@ function reverseTransformers(val, transformers) {
val = atob(val); val = atob(val);
} }
break; break;
case "getString":
// retrieve string
val = getString(val);
break;
default: default:
console.warn(`Unknown transformer: ${transformer}`); console.warn(`Unknown transformer: ${transformer}`);
} }
+1 -1
View File
@@ -286,7 +286,7 @@ function initSelect2() {
// try to initialize select2 // try to initialize select2
setTimeout(() => { setTimeout(() => {
initSelect2() initSelect2()
}, 500); }, 1000);
console.log("init ui_components.js") console.log("init ui_components.js")
+3 -2
View File
@@ -147,8 +147,9 @@ def cleanup_database (dbPath, DAYS_TO_KEEP_EVENTS, PHOLUS_DAYS_DATA, HRS_TO_KEEP
# Cleanup New Devices # Cleanup New Devices
if HRS_TO_KEEP_NEWDEV != 0: if HRS_TO_KEEP_NEWDEV != 0:
mylog('verbose', [f'[{pluginName}] Devices: Delete all New Devices older than {str(HRS_TO_KEEP_NEWDEV)} hours (HRS_TO_KEEP_NEWDEV setting)']) mylog('verbose', [f'[{pluginName}] Devices: Delete all New Devices older than {str(HRS_TO_KEEP_NEWDEV)} hours (HRS_TO_KEEP_NEWDEV setting)'])
cursor.execute (f"""DELETE FROM Devices query = f"""DELETE FROM Devices WHERE dev_NewDevice = 1 AND dev_FirstConnection < date('now', '-{str(HRS_TO_KEEP_NEWDEV)} hour')"""
WHERE dev_NewDevice = 1 AND dev_FirstConnection < date('now', '+{str(HRS_TO_KEEP_NEWDEV)} hour')""") mylog('verbose', [f'[{pluginName}] Query: {query} '])
cursor.execute (query)
# ----------------------------------------------------- # -----------------------------------------------------
# Cleanup Pholus_Scan # Cleanup Pholus_Scan
+30 -30
View File
@@ -34,43 +34,43 @@
{ {
"elementType": "select", "elementType": "select",
"elementOptions": [{ "multiple": "true", "ordeable": "true" }], "elementOptions": [{ "multiple": "true", "ordeable": "true" }],
"transformers": [] "transformers": ["getString"]
} }
] ]
}, },
"maxLength": 50, "maxLength": 50,
"default_value": [ "default_value": [
"getString-Device_TableHead_Icon-value-3", "Device_TableHead_Icon",
"getString-Device_TableHead_Name-value-0", "Device_TableHead_Name",
"getString-Device_TableHead_Type-value-2", "Device_TableHead_Type",
"getString-Device_TableHead_LastIP-value-8", "Device_TableHead_LastIP",
"getString-Device_TableHead_Status-value-10", "Device_TableHead_Status",
"getString-Device_TableHead_MAC_full-value-11" "Device_TableHead_MAC_full"
], ],
"options": [ "options": [
"getString-Device_TableHead_Name-value-0", "Device_TableHead_Name",
"getString-Device_TableHead_Owner-value-1", "Device_TableHead_Owner",
"getString-Device_TableHead_Type-value-2", "Device_TableHead_Type",
"getString-Device_TableHead_Icon-value-3", "Device_TableHead_Icon",
"getString-Device_TableHead_Favorite-value-4", "Device_TableHead_Favorite",
"getString-Device_TableHead_Group-value-5", "Device_TableHead_Group",
"getString-Device_TableHead_FirstSession-value-6", "Device_TableHead_FirstSession",
"getString-Device_TableHead_LastSession-value-7", "Device_TableHead_LastSession",
"getString-Device_TableHead_LastIP-value-8", "Device_TableHead_LastIP",
"getString-Device_TableHead_MAC-value-9", "Device_TableHead_MAC",
"getString-Device_TableHead_Status-value-10", "Device_TableHead_Status",
"getString-Device_TableHead_MAC_full-value-11", "Device_TableHead_MAC_full",
"getString-Device_TableHead_LastIPOrder-value-12", "Device_TableHead_LastIPOrder",
"getString-Device_TableHead_Rowid-value-13", "Device_TableHead_Rowid",
"getString-Device_TableHead_Parent_MAC-value-14", "Device_TableHead_Parent_MAC",
"getString-Device_TableHead_Connected_Devices-value-15", "Device_TableHead_Connected_Devices",
"getString-Device_TableHead_Location-value-16", "Device_TableHead_Location",
"getString-Device_TableHead_Vendor-value-17", "Device_TableHead_Vendor",
"getString-Device_TableHead_Port-value-18", "Device_TableHead_Port",
"getString-Device_TableHead_GUID-value-19", "Device_TableHead_GUID",
"getString-Device_TableHead_SyncHubNodeName-value-20", "Device_TableHead_SyncHubNodeName",
"getString-Device_TableHead_NetworkSite-value-21", "Device_TableHead_NetworkSite",
"getString-Device_TableHead_SSID-value-22" "Device_TableHead_SSID"
], ],
"localized": ["name", "description"], "localized": ["name", "description"],
"name": [ "name": [
+17 -10
View File
@@ -676,17 +676,24 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
settingsArray.push([prefix, setCodeName, dataType, value]); settingsArray.push([prefix, setCodeName, dataType, value]);
} else if (dataType === "array" ) { } else if (dataType === "array" ) {
// make sure to collect all if set as "editable" or selected only otherwise
$(`#${setCodeName}`).attr("my-editable") == "true" ? additionalSelector = "" : additionalSelector = ":selected"
const temps = []; let temps = [];
$(`#${setCodeName} option${additionalSelector}`).each(function() {
const vl = $(this).val(); if(isOrdeable)
if (vl !== '') { {
temps.push(applyTransformers(vl, transformers)); temps = $(`#${setCodeName}`).val()
} } else
}); {
// make sure to collect all if set as "editable" or selected only otherwise
$(`#${setCodeName}`).attr("my-editable") == "true" ? additionalSelector = "" : additionalSelector = ":selected";
$(`#${setCodeName} option${additionalSelector}`).each(function() {
const vl = $(this).val();
if (vl !== '') {
temps.push(applyTransformers(vl, transformers));
}
});
}
value = JSON.stringify(temps); value = JSON.stringify(temps);
settingsArray.push([prefix, setCodeName, dataType, value]); settingsArray.push([prefix, setCodeName, dataType, value]);