mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Settings overview dashboard + #462 work
This commit is contained in:
@@ -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
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
109
front/js/settings_utils.js
Normal file
109
front/js/settings_utils.js
Normal file
@@ -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 += `
|
||||
<a href="#${prefix + '_' + set}" onclick="toggleAllSettings()">
|
||||
<div class="overview-setting-value pointer" title="${prefix + '_' + set}">
|
||||
<code>${getSetting(prefix + '_' + set)}</code>
|
||||
</div>
|
||||
</a>
|
||||
`
|
||||
|
||||
});
|
||||
|
||||
html += `
|
||||
|
||||
<div class="col-sm-4 ">
|
||||
<div class="small-box bg-green " >
|
||||
<div class="inner ">
|
||||
<h5 class="card-title">
|
||||
${getString(prefix+"_display_name")}
|
||||
</h5>
|
||||
${includeSettings_html}
|
||||
</div>
|
||||
<div class="icon"> ${getString(prefix+"_icon")} </div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
});
|
||||
|
||||
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
|
||||
}
|
||||
@@ -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" : "<br/>Settings saved to the <code>pialert.conf</code> file.<br/><br/>A time-stamped backup of the previous file created. <br/><br/> Reloading...<br/>",
|
||||
"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 (<code>*_RUN_SCHD</code>) 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 <b>🔍Device scanners</b>.",
|
||||
"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",
|
||||
|
||||
@@ -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 |
|
||||
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": [
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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": [
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"code_name": "nmap_scan",
|
||||
"unique_prefix": "NMAP",
|
||||
"plugin_type": "scanner",
|
||||
"plugin_type": "other",
|
||||
"enabled": true,
|
||||
"data_source": "script",
|
||||
"data_filters": [
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": [
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": "<i class=\"fa-solid fa-upload\"></i>"
|
||||
},
|
||||
{
|
||||
"language_code": "es_es",
|
||||
"string": "<i class=\"fa-solid fa-upload\"></i>"
|
||||
}
|
||||
],
|
||||
"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": "<i class=\"fa-solid fa-upload\"></i>"
|
||||
},
|
||||
{
|
||||
"language_code": "es_es",
|
||||
"string": "<i class=\"fa-solid fa-upload\"></i>"
|
||||
}
|
||||
],
|
||||
"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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -54,6 +54,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
<!-- Page ------------------------------------------------------------------ -->
|
||||
|
||||
<script src="js/pialert_common.js"></script>
|
||||
<script src="js/settings_utils.js"></script>
|
||||
|
||||
|
||||
<div id="settingsPage" class="content-wrapper">
|
||||
@@ -86,9 +87,11 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
|
||||
<div id="settingsOverview" class ="bg-white color-palette box panel panel-default col-sm-12 box-default box-info" >
|
||||
<!-- Settings imported time -->
|
||||
|
||||
|
||||
|
||||
<div class ="settings-group col-sm-12">
|
||||
<i class="<?= lang("Plugins_enabled_settings_icon");?>"></i> <?= lang("Plugins_enabled_settings");?>
|
||||
</div>
|
||||
<div class =" col-sm-12" id=""></div>
|
||||
|
||||
</section>
|
||||
|
||||
@@ -111,9 +114,16 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
|
||||
<div class ="bg-grey-dark color-palette box panel panel-default col-sm-12 box-default box-info" >
|
||||
<div class ="settings-group col-sm-12">
|
||||
<i class="<?= lang("Plugins_type_scanner_icon");?>"></i> <?= lang("Plugins_type_scanner");?>
|
||||
<i class="<?= lang("Plugins_type_device_scanner_icon");?>"></i> <?= lang("Plugins_type_device_scanner");?>
|
||||
</div>
|
||||
<div class =" col-sm-12" id="scanner_content"></div>
|
||||
<div class =" col-sm-12" id="device_scanner_content"></div>
|
||||
</div>
|
||||
|
||||
<div class ="bg-grey-dark color-palette box panel panel-default col-sm-12 box-default box-info" >
|
||||
<div class ="settings-group col-sm-12">
|
||||
<i class="<?= lang("Plugins_type_other_icon");?>"></i> <?= lang("Plugins_type_other");?>
|
||||
</div>
|
||||
<div class =" col-sm-12" id="other_content"></div>
|
||||
</div>
|
||||
|
||||
<div class ="bg-grey-dark color-palette box panel panel-default col-sm-12 box-default box-info" >
|
||||
@@ -144,127 +154,8 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
|
||||
|
||||
<script>
|
||||
// -------------------------------------------------------------------
|
||||
// Get plugin type base on prefix
|
||||
function getPluginType(pluginsData, prefix)
|
||||
{
|
||||
|
||||
|
||||
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 += `<div><code>${getSetting(prefix+set)}</code></div>`
|
||||
|
||||
});
|
||||
|
||||
html += `<div class="col-sm-3 ">
|
||||
<div class="info-box bg-aqua">
|
||||
<span class="info-box-icon"> ${getString(prefix+"_icon")} </span>
|
||||
<div class="info-box-content">
|
||||
<span class="info-box-text">
|
||||
${getString(prefix+"_display_name")}
|
||||
${includeSettings_html}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
});
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Gets scanners that write into the CurrentScan table
|
||||
function getMappedToCurrentScan(prefixesOfEnabledPlugins, pluginsData, onlyEnabled)
|
||||
{
|
||||
plug_schedules = []
|
||||
plug_prefixes = []
|
||||
|
||||
prefixesOfEnabledPlugins.forEach((prefix) => {
|
||||
pluginsData.forEach((plug) => {
|
||||
|
||||
// enabled plugin is mapping to the CurrentScan table -> save the data to check the schedule
|
||||
if (plug.unique_prefix == prefix && plug.mapped_to_table == "CurrentScan") {
|
||||
|
||||
shouldContinue = true;
|
||||
|
||||
// skip if not enabled and should return only enabled
|
||||
if(onlyEnabled && getSetting(prefix+"_RUN") != 'schedule')
|
||||
{
|
||||
shouldContinue = false
|
||||
}
|
||||
|
||||
if(shouldContinue)
|
||||
{
|
||||
plug_prefixes.push(prefix)
|
||||
plug_schedules.push(getSetting(prefix+"_RUN_SCHD").replace(/\s/g, "")) // replace all white characters to compare them easier
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
return plug_prefixes;
|
||||
}
|
||||
|
||||
// // -------------------------------------------------------------------
|
||||
// // Gets scanners that write into the CurrentScan table
|
||||
// function getMappedToCurrentScan(prefixesOfEnabledPlugins, pluginsData, onlyEnabled)
|
||||
// {
|
||||
// plug_schedules = []
|
||||
// plug_prefixes = []
|
||||
|
||||
// prefixesOfEnabledPlugins.forEach((prefix) => {
|
||||
// pluginsData.forEach((plug) => {
|
||||
|
||||
// // enabled plugin is mapping to the CurrentScan table -> save the data to check the schedule
|
||||
// if (plug.unique_prefix == prefix && plug.mapped_to_table == "CurrentScan") {
|
||||
|
||||
// shouldContinue = true;
|
||||
|
||||
// // skip if not enabled and should return only enabled
|
||||
// if(onlyEnabled && getSetting(prefix+"_RUN") != 'schedule')
|
||||
// {
|
||||
// shouldContinue = false
|
||||
// }
|
||||
|
||||
// if(shouldContinue)
|
||||
// {
|
||||
// plug_prefixes.push(prefix)
|
||||
// plug_schedules.push(getSetting(prefix+"_RUN_SCHD").replace(/\s/g, "")) // replace all white characters to compare them easier
|
||||
|
||||
// }
|
||||
// }
|
||||
|
||||
// });
|
||||
// });
|
||||
|
||||
// return plug_prefixes;
|
||||
// }
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// Get plugin and settings data from API endpoints
|
||||
@@ -288,15 +179,13 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
function initSettingsPage(settingsData, pluginsData){
|
||||
|
||||
const settingGroups = [];
|
||||
|
||||
const enabledScanners = [];
|
||||
|
||||
const enabledPublishers = [];
|
||||
const pluginTypes = [];
|
||||
const settingKeyOfLists = [];
|
||||
|
||||
const enabledDeviceScanners = getPluginsByType(pluginsData, "device_scanner", true);
|
||||
const enabledOthers = getPluginsByType(pluginsData, "other", true);
|
||||
const enabledPublishers = getPluginsByType(pluginsData, "publisher", true);
|
||||
|
||||
|
||||
// core groups are the ones not generated by plugins
|
||||
const settingCoreGroups = ['General'];
|
||||
|
||||
// Loop through the settingsArray and:
|
||||
// - collect unique settingGroups
|
||||
@@ -306,74 +195,52 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
// settingGroups
|
||||
if (!settingGroups.includes(set.Group)) {
|
||||
settingGroups.push(set.Group); // = Unique plugin prefix
|
||||
}
|
||||
// check if NOT disabled
|
||||
if (set.Code_Name.endsWith("_RUN") && set.Value != 'disabled') {
|
||||
|
||||
switch(getPluginType(pluginsData, set.Group))
|
||||
{
|
||||
case "scanner":
|
||||
enabledScanners.push(set.Group);
|
||||
break;
|
||||
case "publisher":
|
||||
enabledPublishers.push(set.Group);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const enabledDeviceScanners = getMappedToCurrentScan(enabledScanners, pluginsData, true);
|
||||
}
|
||||
});
|
||||
|
||||
// Init the overview section
|
||||
overviewSections = [
|
||||
'scanners_enabled',
|
||||
'publishers_enabled',
|
||||
'device_scanners'
|
||||
'device_scanners',
|
||||
'other_scanners',
|
||||
'publishers_enabled'
|
||||
]
|
||||
overviewSectionsHtml = [
|
||||
pluginCards(enabledScanners, []),
|
||||
pluginCards(enabledDeviceScanners,['RUN', 'RUN_SCHD']),
|
||||
pluginCards(enabledOthers, ['RUN', 'RUN_SCHD']),
|
||||
pluginCards(enabledPublishers, []),
|
||||
pluginCards(enabledDeviceScanners,['_RUN', '_RUN_SCHD'])
|
||||
|
||||
]
|
||||
|
||||
// "settings_device_scanners_label"
|
||||
// <!-- Enabled scanners -->
|
||||
// <div class="col-sm-2" title="<?= lang("settings_scanners_enabled");?> ">
|
||||
// <div class="">
|
||||
// <?= lang("settings_scanners_enabled_label");?>
|
||||
// </div>
|
||||
// </div>
|
||||
// <div class="col-sm-10" id="enabledScanners">
|
||||
|
||||
// </div>
|
||||
|
||||
index = 0
|
||||
overviewSections_html = ''
|
||||
|
||||
overviewSections.forEach((section) => {
|
||||
|
||||
overviewSections_html += `<div>
|
||||
<div class="col-sm-2 " title="${getString("settings_"+section)}">
|
||||
<div class="">
|
||||
${getString("settings_"+section+"_label")}
|
||||
</div>
|
||||
overviewSections_html += `<div class="overview-section col-sm-12" id="${section}">
|
||||
<div class="col-sm-12 " title="${getString("settings_"+section)}">
|
||||
<div class="overview-group col-sm-12">
|
||||
${getString("settings_"+section+"_label")}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="col-sm-12">
|
||||
${overviewSectionsHtml[index]}
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
index++;
|
||||
|
||||
});
|
||||
|
||||
|
||||
// checkSchedules(enabledScanners, pluginsData)
|
||||
|
||||
$('#settingsOverview').append(overviewSections_html);
|
||||
|
||||
// Display warning
|
||||
if(schedulesAreSynchronized(enabledDeviceScanners, pluginsData) == false)
|
||||
{
|
||||
$("#device_scanners").append(
|
||||
`
|
||||
<small class="label pull-right bg-red pointer" onClick="showModalOk('WARNING', '${getString("Settings_device_Scanners_desync_popup")}')">
|
||||
${getString('Settings_device_Scanners_desync')}
|
||||
</small>
|
||||
`)
|
||||
}
|
||||
|
||||
// Start constructing the main settings HTML
|
||||
let pluginHtml = `
|
||||
@@ -381,25 +248,45 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
||||
<div class="table_cell bold">
|
||||
<i class="fa-regular fa-book fa-sm"></i>
|
||||
<a href="https://github.com/jokob-sk/Pi.Alert/tree/main/front/plugins" target="_blank">
|
||||
<?= lang('Gen_ReadDocs');?>
|
||||
${getString('Gen_ReadDocs')}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
let isIn = ' in '; // to open the active panel in AdminLTE
|
||||
|
||||
for (const group of settingGroups) {
|
||||
let isPlugin = false;
|
||||
for (const group of settingGroups) {
|
||||
|
||||
// enabled / disabled icons
|
||||
enabledHtml = ''
|
||||
|
||||
if(getSetting(group+"_RUN") != "")
|
||||
{
|
||||
let isEnabled = ["once", "schedule", "always_after_scan", "on_new_device", "on_notification", "before_config_save" ].includes(getSetting(group+"_RUN"));
|
||||
|
||||
isEnabled ? onOff = 'on' : onOff = 'off';
|
||||
|
||||
enabledHtml = `
|
||||
<div class="enabled-disabled-icon">
|
||||
<i class="fa-solid fa-toggle-${onOff}"></i>
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
headerHtml = `<div class="box box-solid box-primary panel panel-default">
|
||||
<a data-toggle="collapse" data-parent="#accordion_gen" href="#${group}">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title">${getString(group+"_icon")} ${getString(group+"_display_name")}</h4>
|
||||
<h4 class="panel-title">
|
||||
<div class="col-sm-1 col-xs-1">${getString(group+"_icon")} </div>
|
||||
<div class="col-sm-10 col-xs-8">${getString(group+"_display_name")} </div>
|
||||
<div class="col-sm-1 col-xs-1">${enabledHtml} </div>
|
||||
</h4>
|
||||
</div>
|
||||
</a>
|
||||
<div id="${group}" data-myid="collapsible" class="panel-collapse collapse ${isIn}">
|
||||
<div class="panel-body">
|
||||
${isPlugin ? pluginHtml: ""}
|
||||
${group != "general" ? pluginHtml: ""}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user