From e434a686c663112e779ac967be2cd5573ec9db0f Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Tue, 24 Oct 2023 20:38:44 +1100 Subject: [PATCH] Settings overview dashboard + #462 work --- front/css/pialert.css | 68 ++++- front/js/settings_utils.js | 109 ++++++++ front/php/templates/language/en_us.json | 16 +- front/plugins/README.md | 24 +- front/plugins/arp_scan/config.json | 2 +- front/plugins/dhcp_leases/config.json | 2 +- front/plugins/dhcp_servers/config.json | 2 +- front/plugins/internet_ip/config.json | 2 +- front/plugins/internet_speedtest/config.json | 2 +- front/plugins/nmap_scan/config.json | 2 +- front/plugins/pholus_scan/config.json | 2 +- front/plugins/pihole_scan/config.json | 2 +- front/plugins/snmp_discovery/config.json | 2 +- front/plugins/undiscoverables/config.json | 2 +- front/plugins/unifi_import/config.json | 146 +++++------ front/plugins/website_monitor/config.json | 2 +- front/settings.php | 251 +++++-------------- 17 files changed, 349 insertions(+), 287 deletions(-) create mode 100644 front/js/settings_utils.js diff --git a/front/css/pialert.css b/front/css/pialert.css index 3419fd6b..e15c470a 100755 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -173,6 +173,7 @@ @media (max-width: 767px) { .main-header .logo { width: 100%; + display:none; } .main-header .navbar { @@ -623,6 +624,11 @@ height: 50px; display: none; } +.settingswrap .enabled-disabled-icon +{ + float: right; +} + .settings-group { font-size: 20px; @@ -630,10 +636,39 @@ height: 50px; padding-bottom: 9px; } +.overview-section .small-box .icon +{ + font-size: 38px; + top:0px; +} + +.overview-section +{ + border: solid; + border-width: medium; + border-width: medium; + border-width: 1px; + border-radius: 15px; + margin-bottom: 3px; + +} + .settings-group i{ font-size: 16px; } +.overview-group +{ + font-size: 20px; + padding-top: 7px; + padding-bottom: 9px; + +} + +.overview-group i{ + font-size: 16px; +} + .table_row { padding: 3px; @@ -684,6 +719,18 @@ height: 50px; /* Settings */ +#settingsPage .overview-setting-value{ + display:unset; +} +#settingsPage .panel-title{ + /* display: inline-block; */ + /* width: 120px; */ + white-space: nowrap; + overflow: hidden !important; + text-overflow: ellipsis; +} + + .settings_content { padding: 10px; /* background-color: #272c30; */ @@ -901,30 +948,43 @@ input[readonly] { /*Hidden special button*/ -@media (max-width: 464px) { +@media (max-width: 365px) { #back-button { display: none; } } -@media (max-width: 432px) { +@media (max-width: 335px) { #next-button { display: none; } } -@media (max-width: 400px) { +@media (max-width: 300px) { #reload-button { display: none; } } -@media (max-width: 365px) { +@media (max-width: 300px) { #fullscreen-button { display: none; } } +@media (max-width: 500px) { + .header-server-time { + display: none; + } + } + +#settingsPage .small-box .inner .card-title { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + + /* ----------------------------------------------------------------------------- Spin ----------------------------------------------------------------------------- */ diff --git a/front/js/settings_utils.js b/front/js/settings_utils.js new file mode 100644 index 00000000..9f7d0fdb --- /dev/null +++ b/front/js/settings_utils.js @@ -0,0 +1,109 @@ +// ------------------------------------------------------------------- + // Get all plugin prefixes of a given type + function getPluginsByType(pluginsData, pluginType, onlyEnabled) + { + + var result = [] + + pluginsData.forEach((plug) => { + + if(plug.plugin_type == pluginType) + { + // collect all, or if only enabled, check if NOT disabled + if (onlyEnabled == false || (onlyEnabled && getSetting(plug.unique_prefix + '_RUN') != 'disabled')) { + result.push(plug.unique_prefix) + } + } + }); + + return result; + } + + + // ------------------------------------------------------------------- + // Get plugin type base on prefix + function getPluginType(pluginsData, prefix) + { + var result = "core" + + pluginsData.forEach((plug) => { + + if (plug.unique_prefix == prefix ) { + id = plug.plugin_type; + + // console.log(id) + result = plug.plugin_type; + } + }); + + return result; + } + + // ------------------------------------------------------------------- + // Generate plugin HTML card based on prefixes in an array + function pluginCards(prefixesOfEnabledPlugins, includeSettings) + { + html = "" + + prefixesOfEnabledPlugins.forEach((prefix) => { + + includeSettings_html = '' + + includeSettings.forEach((set) => { + + includeSettings_html += ` + +
+ ${getSetting(prefix + '_' + set)} +
+
+ ` + + }); + + html += ` + +
+
+
+
+ ${getString(prefix+"_display_name")} +
+ ${includeSettings_html} +
+
${getString(prefix+"_icon")}
+ +
+
+ ` + }); + + return html; + } + + // ------------------------------------------------------------------- + // Checks if all schedules are the same + function schedulesAreSynchronized(prefixesOfEnabledPlugins, pluginsData) + { + plug_schedules = [] + + prefixesOfEnabledPlugins.forEach((prefix) => { + pluginsData.forEach((plug) => { + + if (plug.unique_prefix == prefix) { + + plug_schedules.push(getSetting(prefix+"_RUN_SCHD").replace(/\s/g, "")) // replace all white characters to compare them easier + + } + + }); + }); + + // Check if all plug_schedules are the same + if (plug_schedules.length > 0) { + const firstSchedule = plug_schedules[0]; + return plug_schedules.every((schedule) => schedule === firstSchedule); + } + + return true; // Return true if no schedules are found + } \ No newline at end of file diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 5c1855c1..e37ab71d 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -460,10 +460,14 @@ "Plugins_Filters_Mac" : "Mac Filter", "Plugins_Out_of" : "out of", "Plugins_no_control" : "No form control was found to render this value.", + "Plugins_enabled_settings" : "Enabled settings", + "Plugins_enabled_settings_icon" : "fa-solid fa-toggle-on", "Plugins_type_core" : "Core", "Plugins_type_core_icon" : "fa-solid fa-gem", - "Plugins_type_scanner" : "Scanners", - "Plugins_type_scanner_icon" : "fa-solid fa-magnifying-glass-plus", + "Plugins_type_device_scanner" : "Device Scanners", + "Plugins_type_device_scanner_icon" : "fa-solid fa-magnifying-glass-plus", + "Plugins_type_other" : "Others", + "Plugins_type_other_icon" : "fa-solid fa-recycle", "Plugins_type_system" : "System", "Plugins_type_system_icon" : "fa-solid fa-gear", "Plugins_type_publisher" : "Publishers", @@ -475,13 +479,15 @@ "settings_saved" : "
Settings saved to the pialert.conf file.

A time-stamped backup of the previous file created.

Reloading...
", "settings_imported_label" : "Settings imported", "settings_imported" : "Last time settings were imported from the pialert.conf file", - "settings_scanners_enabled_label" : "Enabled scanners", - "settings_scanners_enabled" : "All plugins of the scanner type that are currently enabled.", + "settings_other_scanners_label" : "Other scanners", + "settings_other_scanners" : "Other, non-device scanner plugins that are currently enabled.", "settings_device_scanners_label" : "Device scanners", "settings_device_scanners" : "Device scanners used to discover devices that write into the CurrentScan database table.", - "settings_publishers_enabled_label" : "Enabled publishers", + "settings_publishers_enabled_label" : "Publishers", "settings_publishers_enabled" : "Enabled notification gateways - publishers, that will send a notification depending on your settings.", "settings_expand_all" : "Expand all", + "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.", "Setting_Override" : "Override value", "Setting_Override_Description" : "Enabling this option will override an App supplied default value with the value specified above.", "General_display_name" : "General", diff --git a/front/plugins/README.md b/front/plugins/README.md index a142a40f..6426347e 100755 --- a/front/plugins/README.md +++ b/front/plugins/README.md @@ -17,29 +17,29 @@ | Required | CurrentScan | Unique Prefix | Data source | Type | Link + Docs | |----------|-------------|---------------|--------------------|--------------|------------------------------------------------------------------| | | | APPRISE | Script | ๐Ÿ’ฌ publisher | ๐Ÿ“š[_publisher_apprise](/front/plugins/_publisher_apprise/) | -| | Yes | ARPSCAN | Script | ๐Ÿ”scanner | ๐Ÿ“š[arp_scan](/front/plugins/arp_scan/) | +| | Yes | ARPSCAN | Script | ๐Ÿ”dev scanner| ๐Ÿ“š[arp_scan](/front/plugins/arp_scan/) | | | | CSVBCKP | Script | โš™ system | ๐Ÿ“š[csv_backup](/front/plugins/csv_backup/) | | Yes* | | DBCLNP | Script | โš™ system | ๐Ÿ“š[db_cleanup](/front/plugins/db_cleanup/) | | | | DDNS | Script | โš™ system | ๐Ÿ“š[ddns_update](/front/plugins/ddns_update/) | -| | Yes | DHCPLSS | Script | ๐Ÿ”scanner | ๐Ÿ“š[dhcp_leases](/front/plugins/dhcp_leases/) | -| | | DHCPSRVS | Script | ๐Ÿ”scanner | ๐Ÿ“š[dhcp_servers](/front/plugins/dhcp_servers/) | -| | Yes | INTRNT | Script | ๐Ÿ”scanner | ๐Ÿ“š[internet_ip](/front/plugins/internet_ip/) | -| | | INTRSPD | Script | ๐Ÿ”scanner | ๐Ÿ“š[internet_speedtest](/front/plugins/internet_speedtest/) | +| | Yes | DHCPLSS | Script | ๐Ÿ”dev scanner| ๐Ÿ“š[dhcp_leases](/front/plugins/dhcp_leases/) | +| | | DHCPSRVS | Script | โ™ป other | ๐Ÿ“š[dhcp_servers](/front/plugins/dhcp_servers/) | +| | Yes | INTRNT | Script | ๐Ÿ”dev scanner| ๐Ÿ“š[internet_ip](/front/plugins/internet_ip/) | +| | | INTRSPD | Script | โ™ป other | ๐Ÿ“š[internet_speedtest](/front/plugins/internet_speedtest/) | | Yes | | NEWDEV | Template | โš™ system | ๐Ÿ“š[newdev_template](/front/plugins/newdev_template/) | -| | | PHOLUS | Script | ๐Ÿ”scanner | ๐Ÿ“š[pholus_scan](/front/plugins/pholus_scan/) | +| | | PHOLUS | Script | โ™ป other | ๐Ÿ“š[pholus_scan](/front/plugins/pholus_scan/) | | | | MQTT | Script | ๐Ÿ’ฌ publisher | ๐Ÿ“š[_publisher_mqtt](/front/plugins/_publisher_mqtt/) | -| | | NMAP | Script | ๐Ÿ”scanner | ๐Ÿ“š[nmap_scan](/front/plugins/nmap_scan/) | +| | | NMAP | Script | โ™ป other | ๐Ÿ“š[nmap_scan](/front/plugins/nmap_scan/) | | | | NTFY | Script | ๐Ÿ’ฌ publisher | ๐Ÿ“š[_publisher_ntfy](/front/plugins/_publisher_ntfy/) | -| | Yes | PIHOLE | External SQLite DB | ๐Ÿ”scanner | ๐Ÿ“š[pihole_scan](/front/plugins/pihole_scan/) | +| | Yes | PIHOLE | External SQLite DB | ๐Ÿ”dev scanner| ๐Ÿ“š[pihole_scan](/front/plugins/pihole_scan/) | | | | PUSHSAFER | Script | ๐Ÿ’ฌ publisher | ๐Ÿ“š[_publisher_pushsafer](/front/plugins/_publisher_pushsafer/) | | | | SETPWD | Script | โš™ system | ๐Ÿ“š[set_password](/front/plugins/set_password/) | | | | SMTP | Script | ๐Ÿ’ฌ publisher | ๐Ÿ“š[_publisher_email](/front/plugins/_publisher_email/) | -| | | SNMPDSC | Script | ๐Ÿ”scanner | ๐Ÿ“š[snmp_discovery](/front/plugins/snmp_discovery/) | -| | Yes** | UNDIS | Script | ๐Ÿ”scanner | ๐Ÿ“š[undiscoverables](/front/plugins/undiscoverables/) | -| | Yes | UNFIMP | Script | ๐Ÿ”scanner | ๐Ÿ“š[unifi_import](/front/plugins/unifi_import/) | +| | | SNMPDSC | Script | ๐Ÿ”dev scanner| ๐Ÿ“š[snmp_discovery](/front/plugins/snmp_discovery/) | +| | Yes** | UNDIS | Script | โ™ป other | ๐Ÿ“š[undiscoverables](/front/plugins/undiscoverables/) | +| | Yes | UNFIMP | Script | ๐Ÿ”dev scanner| ๐Ÿ“š[unifi_import](/front/plugins/unifi_import/) | | | | VNDRPDT | Script | โš™ system | ๐Ÿ“š[vendor_update](/front/plugins/vendor_update/) | | | | WEBHOOK | Script | ๐Ÿ’ฌ publisher | ๐Ÿ“š[_publisher_webhook](/front/plugins/_publisher_webhook/) | -| | | WEBMON | Script | ๐Ÿ”scanner | ๐Ÿ“š[website_monitor](/front/plugins/website_monitor/) | +| | | WEBMON | Script | โ™ป other | ๐Ÿ“š[website_monitor](/front/plugins/website_monitor/) | | N/A | | N/A | SQL query | | N/A, but the External SQLite DB plugins work similar | diff --git a/front/plugins/arp_scan/config.json b/front/plugins/arp_scan/config.json index 6af554fc..515652b0 100755 --- a/front/plugins/arp_scan/config.json +++ b/front/plugins/arp_scan/config.json @@ -1,7 +1,7 @@ { "code_name": "arp_scan", "unique_prefix": "ARPSCAN", - "plugin_type": "scanner", + "plugin_type": "device_scanner", "enabled": true, "data_source": "script", "mapped_to_table": "CurrentScan", diff --git a/front/plugins/dhcp_leases/config.json b/front/plugins/dhcp_leases/config.json index 19b6ce9d..a2585d66 100755 --- a/front/plugins/dhcp_leases/config.json +++ b/front/plugins/dhcp_leases/config.json @@ -1,7 +1,7 @@ { "code_name": "dhcp_leases", "unique_prefix": "DHCPLSS", - "plugin_type": "scanner", + "plugin_type": "device_scanner", "enabled": true, "data_source": "script", "data_filters": [ diff --git a/front/plugins/dhcp_servers/config.json b/front/plugins/dhcp_servers/config.json index 1823bd3a..cc202fbd 100755 --- a/front/plugins/dhcp_servers/config.json +++ b/front/plugins/dhcp_servers/config.json @@ -1,7 +1,7 @@ { "code_name": "dhcp_servers", "unique_prefix": "DHCPSRVS", - "plugin_type": "scanner", + "plugin_type": "other", "enabled": true, "data_source": "script", "show_ui": true, diff --git a/front/plugins/internet_ip/config.json b/front/plugins/internet_ip/config.json index 5db22c8f..6e289f7a 100755 --- a/front/plugins/internet_ip/config.json +++ b/front/plugins/internet_ip/config.json @@ -1,7 +1,7 @@ { "code_name": "internet_ip", "unique_prefix": "INTRNT", - "plugin_type": "scanner", + "plugin_type": "device_scanner", "enabled": true, "mapped_to_table": "CurrentScan", "data_filters": [ diff --git a/front/plugins/internet_speedtest/config.json b/front/plugins/internet_speedtest/config.json index 61dd1a90..f1462618 100755 --- a/front/plugins/internet_speedtest/config.json +++ b/front/plugins/internet_speedtest/config.json @@ -1,7 +1,7 @@ { "code_name": "internet_speedtest", "unique_prefix": "INTRSPD", - "plugin_type": "scanner", + "plugin_type": "other", "enabled": true, "data_source": "script", "show_ui": true, diff --git a/front/plugins/nmap_scan/config.json b/front/plugins/nmap_scan/config.json index 4c506659..73ab5592 100755 --- a/front/plugins/nmap_scan/config.json +++ b/front/plugins/nmap_scan/config.json @@ -1,7 +1,7 @@ { "code_name": "nmap_scan", "unique_prefix": "NMAP", - "plugin_type": "scanner", + "plugin_type": "other", "enabled": true, "data_source": "script", "data_filters": [ diff --git a/front/plugins/pholus_scan/config.json b/front/plugins/pholus_scan/config.json index c0f3c3fb..090bdaa9 100755 --- a/front/plugins/pholus_scan/config.json +++ b/front/plugins/pholus_scan/config.json @@ -1,7 +1,7 @@ { "code_name": "pholus_scan", "unique_prefix": "PHOLUS", - "plugin_type": "scanner", + "plugin_type": "other", "enabled": true, "data_source": "script", "mapped_to_table": "Pholus_Scan", diff --git a/front/plugins/pihole_scan/config.json b/front/plugins/pihole_scan/config.json index 9ea4cf7d..025459fe 100755 --- a/front/plugins/pihole_scan/config.json +++ b/front/plugins/pihole_scan/config.json @@ -1,7 +1,7 @@ { "code_name": "pihole_scan", "unique_prefix": "PIHOLE", - "plugin_type": "scanner", + "plugin_type": "device_scanner", "enabled": true, "data_source": "sqlite-db-query", "mapped_to_table": "CurrentScan", diff --git a/front/plugins/snmp_discovery/config.json b/front/plugins/snmp_discovery/config.json index fec025d9..fcf14071 100755 --- a/front/plugins/snmp_discovery/config.json +++ b/front/plugins/snmp_discovery/config.json @@ -1,7 +1,7 @@ { "code_name": "snmp_discovery", "unique_prefix": "SNMPDSC", - "plugin_type": "scanner", + "plugin_type": "device_scanner", "enabled": true, "data_source": "script", "data_filters": [ diff --git a/front/plugins/undiscoverables/config.json b/front/plugins/undiscoverables/config.json index 54be1f33..2894eb02 100755 --- a/front/plugins/undiscoverables/config.json +++ b/front/plugins/undiscoverables/config.json @@ -1,7 +1,7 @@ { "code_name": "undiscoverables", "unique_prefix": "UNDIS", - "plugin_type": "scanner", + "plugin_type": "device_scanner", "enabled": true, "data_source": "script", "mapped_to_table": "CurrentScan", diff --git a/front/plugins/unifi_import/config.json b/front/plugins/unifi_import/config.json index 7781fe13..21d5ba7d 100755 --- a/front/plugins/unifi_import/config.json +++ b/front/plugins/unifi_import/config.json @@ -2,7 +2,77 @@ "code_name": "unifi_import", "show_ui": true, "unique_prefix": "UNFIMP", - "plugin_type": "scanner", + "plugin_type": "device_scanner", + "data_source": "script", + "localized": [ + "display_name", + "description", + "icon" + ], + "display_name": [ + { + "language_code": "en_us", + "string": "UniFi import" + }, + { + "language_code": "es_es", + "string": "Importaciรณn UniFi" + } + ], + "enabled": true, + "mapped_to_table": "CurrentScan", + "icon": [ + { + "language_code": "en_us", + "string": "" + }, + { + "language_code": "es_es", + "string": "" + } + ], + "params": [ + { + "name": "username", + "type": "setting", + "value": "UNFIMP_username" + }, + { + "name": "password", + "type": "setting", + "value": "UNFIMP_password" + }, + { + "name": "host", + "type": "setting", + "value": "UNFIMP_host" + }, + { + "name": "sites", + "type": "setting", + "value": "UNFIMP_sites" + }, + { + "name": "port", + "type": "setting", + "value": "UNFIMP_port" + }, + { + "name": "verifyssl", + "type": "setting", + "value": "UNFIMP_verifyssl" + }, + { + "name": "version", + "type": "setting", + "value": "UNFIMP_version" + }, + { + "name": "fullimport", + "type": "setting", + "value": "UNFIMP_fullimport" + } + ], "data_filters": [ { "compare_column": "Object_PrimaryID", @@ -11,8 +81,7 @@ "compare_operator": "==", "compare_use_quotes": true } - ], - "data_source": "script", + ], "database_column_definitions": [ { "column": "Index", @@ -403,76 +472,7 @@ "language_code": "de_de", "string": "Dieses Plugin imporiert die Gerรคte von einem UNIFI Controller." } - ], - "display_name": [ - { - "language_code": "en_us", - "string": "UniFi import" - }, - { - "language_code": "es_es", - "string": "Importaciรณn UniFi" - } - ], - "enabled": true, - "icon": [ - { - "language_code": "en_us", - "string": "" - }, - { - "language_code": "es_es", - "string": "" - } - ], - "localized": [ - "display_name", - "description", - "icon" - ], - "mapped_to_table": "CurrentScan", - "params": [ - { - "name": "username", - "type": "setting", - "value": "UNFIMP_username" - }, - { - "name": "password", - "type": "setting", - "value": "UNFIMP_password" - }, - { - "name": "host", - "type": "setting", - "value": "UNFIMP_host" - }, - { - "name": "sites", - "type": "setting", - "value": "UNFIMP_sites" - }, - { - "name": "port", - "type": "setting", - "value": "UNFIMP_port" - }, - { - "name": "verifyssl", - "type": "setting", - "value": "UNFIMP_verifyssl" - }, - { - "name": "version", - "type": "setting", - "value": "UNFIMP_version" - }, - { - "name": "fullimport", - "type": "setting", - "value": "UNFIMP_fullimport" - } - ], + ], "settings": [ { "default_value": "disabled", diff --git a/front/plugins/website_monitor/config.json b/front/plugins/website_monitor/config.json index 3efa2fd5..5d009952 100755 --- a/front/plugins/website_monitor/config.json +++ b/front/plugins/website_monitor/config.json @@ -1,7 +1,7 @@ { "code_name": "website_monitor", "unique_prefix": "WEBMON", - "plugin_type": "scanner", + "plugin_type": "other", "enabled": true, "data_source": "script", "show_ui": true, diff --git a/front/settings.php b/front/settings.php index 684345c3..6fd5a7ba 100755 --- a/front/settings.php +++ b/front/settings.php @@ -54,6 +54,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { +
@@ -86,9 +87,11 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
- - +
+ "> +
+
@@ -111,9 +114,16 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
- "> + ">
-
+
+
+ +
+
+ "> +
+
@@ -144,127 +154,8 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {