diff --git a/front/css/app.css b/front/css/app.css index 71719b15..4165300d 100755 --- a/front/css/app.css +++ b/front/css/app.css @@ -124,6 +124,21 @@ border: none; } +@media (min-width: 768px) { + + .hideOnBigScreen{ + display: none; + } +} + +@media (max-width: 767px) { /* on mobile */ + + .hideOnMobile{ + display: none; + } +} + + /* ----------------------------------------------------------------------------- Main Sections ----------------------------------------------------------------------------- */ @@ -781,20 +796,20 @@ height: 50px; /* settings */ /* --------------------------------------------------------- */ -@media (max-width: 767px) { +@media (max-width: 767px) { /* on mobile */ /* hide on mobile */ .setting_description { /* color: red; */ display: none; } - .setting_input{ + /* .setting_input{ width:70%; - /* background-color: red; */ + } .setting_name { width:30%; - } + } */ } @media (min-width: 768px) { @@ -802,14 +817,14 @@ height: 50px; /* color: green; */ display: block; } -.setting_input{ +/* .setting_input{ width:40%; - /* background-color: green; */ + } .setting_name { width:19%; -} +} */ } .settingswrap @@ -874,10 +889,10 @@ height: 50px; } -.table_row { +#settingsPage .table_row { padding: 3px; - width:100%; - display: flex; + /* width:100%; */ + /* display: flex; */ border-bottom-width: 1px; border-bottom-style: solid; border-color: #606060; @@ -897,10 +912,6 @@ height: 50px; font-weight: 300; } -.setting_description -{ - width:40%; -} .myhidden { diff --git a/front/js/settings_utils.js b/front/js/settings_utils.js index 064f1f96..237da87e 100755 --- a/front/js/settings_utils.js +++ b/front/js/settings_utils.js @@ -512,6 +512,17 @@ function toggleMetadata(element) { $(`#${id}`).toggle(); } +// ----------------------------------------------------------------------------- +// Show setting description in a modal on smaller screens +// ----------------------------------------------------------------------------- +function showDescription(element) { + const id = $(element).attr("my-to-show"); + + description = $(`${id}`)[0].innerHTML + console.log(description); + showModalOK(getString("Gen_Description"), description); +} + // --------------------------------------------------------- // Helper methods // --------------------------------------------------------- diff --git a/front/php/templates/language/ar_ar.json b/front/php/templates/language/ar_ar.json index 379f7427..0f2261a7 100755 --- a/front/php/templates/language/ar_ar.json +++ b/front/php/templates/language/ar_ar.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "", "Gen_Delete": "", "Gen_DeleteAll": "", + "Gen_Description": "", "Gen_Error": "", "Gen_Filter": "", "Gen_LockedDB": "", @@ -567,6 +568,7 @@ "Setting_Override": "", "Setting_Override_Description": "", "Settings_Metadata_Toggle": "", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "", "Settings_device_Scanners_desync_popup": "", "Speedtest_Results": "", diff --git a/front/php/templates/language/cs_cz.json b/front/php/templates/language/cs_cz.json index 379f7427..0f2261a7 100755 --- a/front/php/templates/language/cs_cz.json +++ b/front/php/templates/language/cs_cz.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "", "Gen_Delete": "", "Gen_DeleteAll": "", + "Gen_Description": "", "Gen_Error": "", "Gen_Filter": "", "Gen_LockedDB": "", @@ -567,6 +568,7 @@ "Setting_Override": "", "Setting_Override_Description": "", "Settings_Metadata_Toggle": "", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "", "Settings_device_Scanners_desync_popup": "", "Speedtest_Results": "", diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json index 59e74534..f4ac558c 100755 --- a/front/php/templates/language/de_de.json +++ b/front/php/templates/language/de_de.json @@ -293,6 +293,7 @@ "Gen_DataUpdatedUITakesTime": "OK – Es kann einen Moment dauern, bis die Benutzeroberfläche aktualisiert wird, während ein Scan ausgeführt wird.", "Gen_Delete": "Löschen", "Gen_DeleteAll": "Delete all", + "Gen_Description": "", "Gen_Error": "Fehler", "Gen_Filter": "Filter", "Gen_LockedDB": "ERROR - DB eventuell gesperrt - Nutze die Konsole in den Entwickler Werkzeugen (F12) zur Überprüfung oder probiere es später erneut.", @@ -636,6 +637,7 @@ "Setting_Override": "Override value", "Setting_Override_Description": "Enabling this option will override an App supplied default value with the value specified above.", "Settings_Metadata_Toggle": "Show/hide metadata for the given setting.", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "⚠ Die Zeitpläne des Gerätescanners sind nicht synchronisiert.", "Settings_device_Scanners_desync_popup": "", "Speedtest_Results": "Ergebnisse des Geschwindigkeitstests", diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index aa6ee345..2179ca48 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "OK - It may take a while for the UI to update if a scan is running.", "Gen_Delete": "Delete", "Gen_DeleteAll": "Delete all", + "Gen_Description": "Description", "Gen_Error": "Error", "Gen_Filter": "Filter", "Gen_LockedDB": "ERROR - DB might be locked - Check F12 Dev tools -> Console or try later.", @@ -567,6 +568,7 @@ "Setting_Override": "Override value", "Setting_Override_Description": "Enabling this option will override an App supplied default value with the value specified above.", "Settings_Metadata_Toggle": "Show/hide metadata for the given setting.", + "Settings_Show_Description": "Show setting description.", "Settings_device_Scanners_desync": "⚠ Device scanner schedules are out-of-sync.", "Settings_device_Scanners_desync_popup": "Schedules of devices scanners (*_RUN_SCHD) are not the same. This will result into inconsistent device online/offline notifications. Unless this is intended, please use the same schedule for all enabled 🔍Device scanners.", "Speedtest_Results": "Speedtest Results", diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json index fb271f14..6080d235 100755 --- a/front/php/templates/language/es_es.json +++ b/front/php/templates/language/es_es.json @@ -291,6 +291,7 @@ "Gen_DataUpdatedUITakesTime": "Correcto - La interfaz puede tardar en actualizarse si se está ejecutando un escaneo.", "Gen_Delete": "Eliminar", "Gen_DeleteAll": "Eliminar todo", + "Gen_Description": "", "Gen_Error": "Error", "Gen_Filter": "Filtro", "Gen_LockedDB": "Fallo - La base de datos puede estar bloqueada - Pulsa F1 -> Ajustes de desarrolladores -> Consola o prueba más tarde.", @@ -634,6 +635,7 @@ "Setting_Override": "Sobreescribir el valor", "Setting_Override_Description": "Habilitar esta opción anulará un valor predeterminado proporcionado por la aplicación con el valor especificado anteriormente.", "Settings_Metadata_Toggle": "Mostrar/ocultar los metadatos de la configuración.", + "Settings_Show_Description": "", "Settings_Title": " Configuración", "Settings_device_Scanners_desync": "⚠ Los horarios del escáner de los dispositivos no están sincronizados.", "Settings_device_Scanners_desync_popup": "Los horarios de escáneres de dispositivos ( *_RUN_SCHD ) no son lo mismo. Esto resultará en notificaciones inconsistentes del dispositivo en línea/fuera de línea. A menos que sea así, utilice el mismo horario para todos los habilitados. 🔍Escáneres de dispositivos .", diff --git a/front/php/templates/language/fr_fr.json b/front/php/templates/language/fr_fr.json index 6c270232..d75d3714 100755 --- a/front/php/templates/language/fr_fr.json +++ b/front/php/templates/language/fr_fr.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "OK - cela peut prendre du temps à l'interface pour se mettre à jour si un scan est en cours.", "Gen_Delete": "Supprimer", "Gen_DeleteAll": "Supprimer tous", + "Gen_Description": "", "Gen_Error": "Erreur", "Gen_Filter": "Filtrer", "Gen_LockedDB": "Erreur - La base de données est peut-être verrouillée - Vérifier avec les outils de dév via F12 -> Console ou essayer plus tard.", @@ -567,6 +568,7 @@ "Setting_Override": "Remplacer la valeur", "Setting_Override_Description": "Activer cette option va remplacer la valeur fournie par défaut par une application par la valeur renseignée au-dessus.", "Settings_Metadata_Toggle": "Afficher/masquer les méta données pour le paramètre sélectionné.", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "⚠ La planification des différents scanners d'appareils est désynchronisée.", "Settings_device_Scanners_desync_popup": "La planification des scanners (*_RUN_SCHD) n'est pas identique entre scanners. Cela va entraîner des notifications en ligne/hors-ligne non cohérentes. À moins que cela soit attendu, utilisez la même planification pour tous les 🔍scanners d'appareils activés.", "Speedtest_Results": "Résultats du test de débit", diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json index 97263bd7..17a2f027 100755 --- a/front/php/templates/language/it_it.json +++ b/front/php/templates/language/it_it.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "OK: l'aggiornamento dell'interfaccia utente potrebbe richiedere del tempo se è in esecuzione una scansione.", "Gen_Delete": "Elimina", "Gen_DeleteAll": "Elimina tutti", + "Gen_Description": "", "Gen_Error": "Errore", "Gen_Filter": "Filtro", "Gen_LockedDB": "ERRORE: il DB potrebbe essere bloccato, controlla F12 Strumenti di sviluppo -> Console o riprova più tardi.", @@ -567,6 +568,7 @@ "Setting_Override": "Sovrascrivi valore", "Setting_Override_Description": "L'abilitazione di questa opzione sovrascriverà il valore predefinito fornito dall'app con il valore specificato sopra.", "Settings_Metadata_Toggle": "Mostra/nascondi i metadati per l'impostazione specificata.", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "⚠ Le pianificazioni dello scanner del dispositivo non sono sincronizzate.", "Settings_device_Scanners_desync_popup": "Gli orari degli scanner dei dispositivi (*_RUN_SCHD) non sono gli stessi. Questo comporterà notifiche online/offline incoerenti del dispositivo. A meno che ciò non sia previsto, utilizza la stessa pianificazione per tutti gli 🔍Scanner dispositivi abilitati.", "Speedtest_Results": "Risultati test di velocità", diff --git a/front/php/templates/language/nb_no.json b/front/php/templates/language/nb_no.json index 1079a167..36df5953 100755 --- a/front/php/templates/language/nb_no.json +++ b/front/php/templates/language/nb_no.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "OK - Det kan ta litt tid før brukergrensesnittet oppdateres hvis en skanning kjøres.", "Gen_Delete": "Slett", "Gen_DeleteAll": "Slett alle", + "Gen_Description": "", "Gen_Error": "Feil", "Gen_Filter": "Filter", "Gen_LockedDB": "FEIL - DB kan være låst - Sjekk F12 Dev tools -> Konsoll eller prøv senere.", @@ -567,6 +568,7 @@ "Setting_Override": "Overstyr verdi", "Setting_Override_Description": "Aktivering av dette alternativet vil overstyre en App som leveres standard-verdi med verdien som er spesifisert ovenfor.", "Settings_Metadata_Toggle": "Vis/skjul metadata for den gitte innstillingen.", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "⚠ Enhetsskanning tidsplan er ikke synkronisert lenger.", "Settings_device_Scanners_desync_popup": "Tidsplanene for enhetsskanning (*_RUN_SCHD) er ikke de samme. Dette vil føre til inkonsekvent enhet på online/offline varsler. Med mindre dette er ment, kan du bruke den samme tidsplanen for alle aktiverte 🔍Enhets-skannere.", "Speedtest_Results": "Speedtest resultater", diff --git a/front/php/templates/language/pl_pl.json b/front/php/templates/language/pl_pl.json index 56761301..3711177b 100755 --- a/front/php/templates/language/pl_pl.json +++ b/front/php/templates/language/pl_pl.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "OK - Aktualizacja UI może chwile potrwać jeżeli wykonywany jest skan.", "Gen_Delete": "Usuń", "Gen_DeleteAll": "Usuń wszystko", + "Gen_Description": "", "Gen_Error": "Błąd", "Gen_Filter": "Filtr", "Gen_LockedDB": "BŁĄD - BAZA DANYCH może być zablokowana - Sprawdź F12 narzędzia dewelopera -> Konsola lub spróbuj ponownie później.", @@ -567,6 +568,7 @@ "Setting_Override": "Nadpisz wartość", "Setting_Override_Description": "Włączanie tej opcji nadpisze podstawową wartość na wartość podaną powyżej.", "Settings_Metadata_Toggle": "Pokaż/Ukryj metadane dla podanego ustawienia.", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "⚠ Harmonogramy skanowania urządzeń są niesynchronizowane.", "Settings_device_Scanners_desync_popup": "Harmonogramy skanowania urządzeń (*_RUN_SCHD) nie są takie same. Powodować to będzie nierównomierne powiadomienia o urządzeniach włączynych/wyłączonych. Jeżeli nie jest to zamierzone to proszę włączyć ten sam harmonogram dla wszyskich 🔍Skanerów Urządzeń.", "Speedtest_Results": "Wyniki Testu Prędkości", diff --git a/front/php/templates/language/pt_br.json b/front/php/templates/language/pt_br.json index 0aba2ef3..56bb5bbd 100755 --- a/front/php/templates/language/pt_br.json +++ b/front/php/templates/language/pt_br.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "OK - Pode levar um tempo para a interface do usuário ser atualizada se uma verificação estiver em execução.", "Gen_Delete": "Excluir", "Gen_DeleteAll": "Excluir todos", + "Gen_Description": "", "Gen_Error": "Erro", "Gen_Filter": "Filtro", "Gen_LockedDB": "ERRO - O banco de dados pode estar bloqueado - Verifique F12 Ferramentas de desenvolvimento -> Console ou tente mais tarde.", @@ -567,6 +568,7 @@ "Setting_Override": "", "Setting_Override_Description": "", "Settings_Metadata_Toggle": "", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "", "Settings_device_Scanners_desync_popup": "", "Speedtest_Results": "", diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json index abc31829..9ccb9b21 100755 --- a/front/php/templates/language/ru_ru.json +++ b/front/php/templates/language/ru_ru.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "ОК - Обновление UI может занять некоторое время, если сканирование выполняется.", "Gen_Delete": "Удалить", "Gen_DeleteAll": "Удалить все", + "Gen_Description": "", "Gen_Error": "Ошибка", "Gen_Filter": "Фильтр", "Gen_LockedDB": "ОШИБКА - Возможно, база данных заблокирована. Проверьте инструменты разработчика F12 -> Консоль или повторите попытку позже.", @@ -567,6 +568,7 @@ "Setting_Override": "Переопределить значение", "Setting_Override_Description": "Включение этой опции приведет к переопределению значения по умолчанию, предоставленного приложением, на значение, указанное выше.", "Settings_Metadata_Toggle": "Показать/скрыть метаданные для данного параметра.", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "⚠ Расписания сканера устройств не синхронизированы.", "Settings_device_Scanners_desync_popup": "Расписания сканеров устройств (*_RUN_SCHD) не совпадают. Это приведет к несогласованным онлайн/оффлайн уведомлениям устройства. Если это не предусмотрено, используйте одно и то же расписание для всех включенных 🔍Сканеров устройств.", "Speedtest_Results": "Результаты теста скорости", diff --git a/front/php/templates/language/tr_tr.json b/front/php/templates/language/tr_tr.json index 9fc61be6..4263ab7e 100755 --- a/front/php/templates/language/tr_tr.json +++ b/front/php/templates/language/tr_tr.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "TAMAM - Eğer bir tarama çalışıyorsa arayüzün güncellenmesi biraz zaman alabilir", "Gen_Delete": "Sil", "Gen_DeleteAll": "Tümünü sil", + "Gen_Description": "", "Gen_Error": "Hata", "Gen_Filter": "Filtre", "Gen_LockedDB": "", @@ -567,6 +568,7 @@ "Setting_Override": "", "Setting_Override_Description": "", "Settings_Metadata_Toggle": "", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "", "Settings_device_Scanners_desync_popup": "", "Speedtest_Results": "", diff --git a/front/php/templates/language/zh_cn.json b/front/php/templates/language/zh_cn.json index 95f18dd0..c39fab22 100755 --- a/front/php/templates/language/zh_cn.json +++ b/front/php/templates/language/zh_cn.json @@ -281,6 +281,7 @@ "Gen_DataUpdatedUITakesTime": "好的 - 如果扫描正在运行,UI 可能需要一段时间才能更新。", "Gen_Delete": "删除", "Gen_DeleteAll": "全部删除", + "Gen_Description": "", "Gen_Error": "错误", "Gen_Filter": "筛选", "Gen_LockedDB": "错误 - DB 可能被锁定 - 检查 F12 开发工具 -> 控制台或稍后重试。", @@ -567,6 +568,7 @@ "Setting_Override": "覆盖值", "Setting_Override_Description": "启用此选项将用上面指定的值覆盖应用程序提供的默认值。", "Settings_Metadata_Toggle": "显示/隐藏给定设置的元数据。", + "Settings_Show_Description": "", "Settings_device_Scanners_desync": "⚠ 设备扫描计划不同步。", "Settings_device_Scanners_desync_popup": "设备扫描 (*_RUN_SCHD) 的时间表并不相同。这将导致设备在线/离线通知不一致。除非有意为之,否则请对所有启用的 🔍设备扫描 使用相同的时间表。", "Speedtest_Results": "Speedtest 结果", diff --git a/front/plugins/__template/config.json b/front/plugins/__template/config.json index 639bb89f..af242e90 100755 --- a/front/plugins/__template/config.json +++ b/front/plugins/__template/config.json @@ -259,9 +259,13 @@ "function": "CMD", "type": { "dataType": "string", - "element": "input", - "elementOptions": ["readonly"], - "transformers": [] + "elements": [ + { + "elementType": "input", + "elementOptions": [{ "readonly": "true" }], + "transformers": [] + } + ] }, "default_value": "python3 /app/front/plugins//rename_me.py", "options": [], diff --git a/front/plugins/dhcp_servers/config.json b/front/plugins/dhcp_servers/config.json index 1f1021e1..0dca4796 100755 --- a/front/plugins/dhcp_servers/config.json +++ b/front/plugins/dhcp_servers/config.json @@ -2,7 +2,7 @@ "code_name": "dhcp_servers", "unique_prefix": "DHCPSRVS", "plugin_type": "other", - "execution_order" : "Layer_3", + "execution_order": "Layer_3", "enabled": true, "data_source": "script", "show_ui": true, @@ -349,7 +349,11 @@ "type": { "dataType": "string", "elements": [ - { "elementType": "input", "elementOptions": [], "transformers": [] } + { + "elementType": "input", + "elementOptions": [{ "readonly": "true" }], + "transformers": [] + } ] }, "default_value": "python3 /app/front/plugins/dhcp_servers/script.py", diff --git a/front/plugins/notification_processing/config.json b/front/plugins/notification_processing/config.json index 42ac8a0c..53d997aa 100755 --- a/front/plugins/notification_processing/config.json +++ b/front/plugins/notification_processing/config.json @@ -125,7 +125,7 @@ "description": [ { "language_code": "en_us", - "string": "You can specify a SQL where condition to filter out New Devices from notifications. For example AND dev_LastIP NOT LIKE '192.168.3.%' will always exlude New Device notifications for all devices with the IP starting with 192.168.3.%." + "string": "You can specify a SQL where condition to filter out New Devices from notifications. For example AND dev_LastIP NOT LIKE '192.168.3.%' will always exclude New Device notifications for all devices with the IP starting with 192.168.3.%." } ] }, @@ -149,7 +149,7 @@ "description": [ { "language_code": "en_us", - "string": "You can specify a SQL where condition to filter out Events from notifications. For example AND dev_LastIP NOT LIKE '192.168.3.%' will always exlude New Device notifications for all devices with the IP starting with 192.168.3.%." + "string": "You can specify a SQL where condition to filter out Events from notifications. For example AND dev_LastIP NOT LIKE '192.168.3.%' will always exclude New Device notifications for all devices with the IP starting with 192.168.3.%." } ] } diff --git a/front/plugins/unifi_import/script.py b/front/plugins/unifi_import/script.py index a25ff427..c2a1e901 100755 --- a/front/plugins/unifi_import/script.py +++ b/front/plugins/unifi_import/script.py @@ -238,7 +238,7 @@ def get_ip(*ips: str) -> str: for ip in ips: if ip and ip != 'null': return ip - return '0:0:0:0' + return '0.0.0.0' # ----------------------------------------------------------------------------- diff --git a/front/settings.php b/front/settings.php index 7200a674..4510a95d 100755 --- a/front/settings.php +++ b/front/settings.php @@ -398,26 +398,32 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX { // hide metadata by default by assigning it a special class isMetadata ? metadataClass = 'metadata' : metadataClass = ''; - isMetadata ? infoIcon = '' : infoIcon = ` ` ; + infoIcon = ` + ` ; + // NAME & DESCRIPTION columns setHtml += ` -
-
+
+
- ${codeName}${infoIcon} + ${codeName}${showMetadata}${infoIcon}
-
+
${getString(codeName + '_description', set['Description'])}
-
+
`; // OVERRIDE diff --git a/server/device.py b/server/device.py index 32f5cf77..d85bdd6c 100755 --- a/server/device.py +++ b/server/device.py @@ -41,6 +41,39 @@ class Device_obj: return result[column_name] if result else None +#------------------------------------------------------------------------------- +# Removing devices from the CurrentScan DB table which the user chose to ignore by MAC or IP +def exclude_ignored_devices(db): + sql = db.sql # Database interface for executing queries + + mac_condition = list_to_where('OR', 'cur_MAC', 'LIKE', get_setting_value('NEWDEV_ignored_MACs')) + ip_condition = list_to_where('OR', 'cur_IP', 'LIKE', get_setting_value('NEWDEV_ignored_IPs')) + + # Only delete if either the MAC or IP matches an ignored condition + conditions = [] + if mac_condition: + conditions.append(mac_condition) + if ip_condition: + conditions.append(ip_condition) + + # Join conditions and prepare the query + conditions_str = " OR ".join(conditions) + if conditions_str: + query = f"""DELETE FROM CurrentScan WHERE + 1=1 + AND ( + {conditions_str} + ) + """ + else: + query = "DELETE FROM CurrentScan WHERE 1=1 AND 1=0" # No valid conditions, prevent deletion + + mylog('debug', f'[New Devices] Excluding Ignored Devices Query: {query}') + + sql.execute(query) + + + #------------------------------------------------------------------------------- def save_scanned_devices (db): sql = db.sql #TO-DO @@ -145,13 +178,11 @@ def create_new_devices (db): SELECT cur_MAC, cur_IP, '{startTime}', 'New Device', cur_Vendor, 1 FROM CurrentScan WHERE NOT EXISTS (SELECT 1 FROM Devices - WHERE dev_MAC = cur_MAC) - {list_to_where('OR', 'cur_MAC', 'NOT LIKE', get_setting_value('NEWDEV_ignored_MACs'))} - {list_to_where('OR', 'cur_IP', 'NOT LIKE', get_setting_value('NEWDEV_ignored_IPs'))} + WHERE dev_MAC = cur_MAC) """ - mylog('debug',f'[New Devices] Query: {query}') + mylog('debug',f'[New Devices] Log Events Query: {query}') sql.execute(query) @@ -163,27 +194,25 @@ def create_new_devices (db): FROM CurrentScan WHERE NOT EXISTS (SELECT 1 FROM Sessions WHERE ses_MAC = cur_MAC) - {list_to_where('OR', 'cur_MAC', 'NOT LIKE', get_setting_value('NEWDEV_ignored_MACs'))} - {list_to_where('OR', 'cur_IP', 'NOT LIKE', get_setting_value('NEWDEV_ignored_IPs'))} """) # Create new devices from CurrentScan mylog('debug','[New Devices] 2 Create devices') # default New Device values preparation - newDevColumns = """dev_AlertEvents, - dev_AlertDeviceDown, - dev_PresentLastScan, - dev_Archived, - dev_NewDevice, - dev_SkipRepeated, - dev_ScanCycle, - dev_Owner, - dev_Favorite, - dev_Group, - dev_Comments, - dev_LogEvents, - dev_Location""" + newDevColumns = """dev_AlertEvents, + dev_AlertDeviceDown, + dev_PresentLastScan, + dev_Archived, + dev_NewDevice, + dev_SkipRepeated, + dev_ScanCycle, + dev_Owner, + dev_Favorite, + dev_Group, + dev_Comments, + dev_LogEvents, + dev_Location""" newDevDefaults = f"""{get_setting_value('NEWDEV_dev_AlertEvents')}, {get_setting_value('NEWDEV_dev_AlertDeviceDown')}, @@ -199,8 +228,13 @@ def create_new_devices (db): {get_setting_value('NEWDEV_dev_LogEvents')}, '{sanitize_SQL_input(get_setting_value('NEWDEV_dev_Location'))}'""" - # Fetch data from CurrentScan - current_scan_data = sql.execute("SELECT cur_MAC, cur_Name, cur_Vendor, cur_IP, cur_SyncHubNodeName, cur_NetworkNodeMAC, cur_PORT, cur_NetworkSite, cur_SSID, cur_Type FROM CurrentScan").fetchall() + # Fetch data from CurrentScan skipping ignored devices by IP and MAC + query = f"""SELECT cur_MAC, cur_Name, cur_Vendor, cur_IP, cur_SyncHubNodeName, cur_NetworkNodeMAC, cur_PORT, cur_NetworkSite, cur_SSID, cur_Type + FROM CurrentScan """ + + + mylog('debug',f'[New Devices] Collecting New Devices Query: {query}') + current_scan_data = sql.execute(query).fetchall() for row in current_scan_data: cur_MAC, cur_Name, cur_Vendor, cur_IP, cur_SyncHubNodeName, cur_NetworkNodeMAC, cur_PORT, cur_NetworkSite, cur_SSID, cur_Type = row diff --git a/server/helper.py b/server/helper.py index 1bf2aaf7..f38b976d 100755 --- a/server/helper.py +++ b/server/helper.py @@ -462,19 +462,23 @@ def list_to_where(logical_operator, column_name, condition_operator, values_list - A string representing the WHERE condition. """ + # If the list is empty, return an empty string if not values_list: - return " AND 1=1 " # Return a conditioneitehr way if the list is empty to avoid breaking the SQL condition. + return "" # Replace {s-quote} with single quote in values_list values_list = [value.replace("{s-quote}", "'") for value in values_list] - # Build the WHERE condition + # Build the WHERE condition for the first value condition = f"{column_name} {condition_operator} '{values_list[0]}'" + # Add the rest of the values using the logical operator for value in values_list[1:]: condition += f" {logical_operator} {column_name} {condition_operator} '{value}'" - return f' AND ({condition}) ' + return f'({condition})' + + diff --git a/server/networkscan.py b/server/networkscan.py index 7fa7cd90..20e3f281 100755 --- a/server/networkscan.py +++ b/server/networkscan.py @@ -3,7 +3,7 @@ import conf -from device import create_new_devices, print_scan_stats, save_scanned_devices, update_devices_data_from_scan +from device import create_new_devices, print_scan_stats, save_scanned_devices, update_devices_data_from_scan, exclude_ignored_devices from helper import timeNowTZ from logger import mylog from reporting import skip_repeated_notifications @@ -16,7 +16,11 @@ from reporting import skip_repeated_notifications def process_scan (db): - # Load current scan data + # Apply exclusions + mylog('verbose','[Process Scan] Exclude ignored devices') + exclude_ignored_devices (db) + + # Load current scan data mylog('verbose','[Process Scan] Processing scan results') save_scanned_devices (db)