From d951e26fa86d62827f4dfeb291839f9c64956bb8 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sat, 7 Jan 2023 12:51:01 +1100 Subject: [PATCH] settings revamp --- front/help_faq.php | 9 +- front/js/pialert_common.js | 1 + front/php/templates/language/en_us.php | 7 +- front/settings.php | 332 ++++++++++++++----------- 4 files changed, 198 insertions(+), 151 deletions(-) diff --git a/front/help_faq.php b/front/help_faq.php index 724ff17b..73c464d6 100755 --- a/front/help_faq.php +++ b/front/help_faq.php @@ -15,22 +15,29 @@

+
+ +


-
+ +
+
+ +

diff --git a/front/js/pialert_common.js b/front/js/pialert_common.js index ecd459a7..c989916b 100755 --- a/front/js/pialert_common.js +++ b/front/js/pialert_common.js @@ -240,6 +240,7 @@ function saveData(functionName, index, value) { } + // ----------------------------------------------------------------------------- function sleep(milliseconds) { const date = Date.now(); diff --git a/front/php/templates/language/en_us.php b/front/php/templates/language/en_us.php index f6b2d5ac..ee7582fd 100755 --- a/front/php/templates/language/en_us.php +++ b/front/php/templates/language/en_us.php @@ -439,10 +439,11 @@ $lang['en_us'] = array( 'settings_missing_block' => 'You can\'t save your settings without specifying all setting keys. Refresh the page. This is probably caused by a high load on the database.', 'settings_old' => 'The settings in the DB (shown on this page) are outdated. This is probably caused by a running scan. The settings were saved in the pialert.conf file, but the background process didn\'t have time to import it yet to the DB. You can wait until the settings get refreshed so you don\'t overwrite your old values. Feel free to save your settings either way if you don\'t mind losing the settings between the last save and now. There are also backup files created if you need to compare your settings later.', 'settings_imported' => 'Last time settings were imported from the pialert.conf file:', +'settings_expand_all' => 'Expand all', //General 'ENABLE_ARPSCAN_name' => 'Enable ARP scan', -'ENABLE_ARPSCAN_description' => 'Arp-scan is a command-line tool that uses the ARP protocol to discover and fingerprint IP hosts on the local network. An alternative to ARP scan is to enable the PIHOLE_ACTIVEPiHole integration settings.', +'ENABLE_ARPSCAN_description' => 'Arp-scan is a command-line tool that uses the ARP protocol to discover and fingerprint IP hosts on the local network. An alternative to ARP scan is to enable the PIHOLE_ACTIVEPiHole integration settings.', 'SCAN_SUBNETS_name' => 'Subnets to scan', 'SCAN_SUBNETS_description' => ' @@ -566,7 +567,7 @@ the arp-scan will take hours to complete instead of seconds. // Pholus 'PHOLUS_ACTIVE_name' => 'Cycle run', -'PHOLUS_ACTIVE_description' => 'Pholus is a sniffing tool to discover additional information about the devices on the network, including the device name. If enabled this will execute the scan before every network scan cycle until there are no (unknown) or (name not found) devices. Please be aware it can spam the network with unnecessary traffic. Depends on the SCAN_SUBNETS setting. For a scheduled or one-off scan, check the PHOLUS_RUN setting.', +'PHOLUS_ACTIVE_description' => 'Pholus is a sniffing tool to discover additional information about the devices on the network, including the device name. If enabled this will execute the scan before every network scan cycle until there are no (unknown) or (name not found) devices. Please be aware it can spam the network with unnecessary traffic. Depends on the SCAN_SUBNETS setting. For a scheduled or one-off scan, check the PHOLUS_RUN setting.', 'PHOLUS_TIMEOUT_name' => 'Cycle run timeout', 'PHOLUS_TIMEOUT_description' => 'How long in seconds should Pholus be sniffing on each interface if above condition is fulfilled. The longer you leave it on, the more likely devices would broadcast more info. This timeout adds to the time it takes to perform an arp-scan on your network.', 'PHOLUS_FORCE_name' => 'Cycle force scan', @@ -577,7 +578,7 @@ the arp-scan will take hours to complete instead of seconds. 'PHOLUS_RUN_TIMEOUT_description' => 'The timeout in seconds for the scheduled Pholus scan. Same notes regarding the duration apply as on the PHOLUS_TIMEOUT setting. A scheduled scan doesn\'t check if there are (unknown) or (name not found) devices, the scan is executed either way.', 'PHOLUS_RUN_SCHD_name' => 'Schedule', 'PHOLUS_RUN_SCHD_description' => 'Only enabled if you select schedule in the PHOLUS_RUN setting. Make sure you enter the schedule in the correct cron-like format -(e.g. validate at crontab.guru). For example entering 0 4 * * * will run the scan after 4 am in the TIMEZONE you set above. Will be run NEXT time the time passes.', +(e.g. validate at crontab.guru). For example entering 0 4 * * * will run the scan after 4 am in the TIMEZONE you set above. Will be run NEXT time the time passes.', 'PHOLUS_DAYS_DATA_name' => 'Data retention', 'PHOLUS_DAYS_DATA_description' => 'How many days of Pholus scan entries should be kept (globally, not device specific!). The pialert_pholus.log file is not touched. Enter 0 to disable.', diff --git a/front/settings.php b/front/settings.php index 0748ce0d..dafac46a 100644 --- a/front/settings.php +++ b/front/settings.php @@ -49,11 +49,11 @@ CommitDB();

- +

-
+
-

'.$group.'

'; - - // populate settings for each group - foreach ($settings as $set) { - if($set["Group"] == $group) - { - $html = $html. - '
-
'; } echo $html; @@ -382,6 +390,36 @@ CommitDB(); }); } + + + // ----------------------------------------------------------------------------- + function toggleAllSettings() + { + inStr = ' in'; + allOpen = true; + openIcon = 'fa-angle-double-down'; + closeIcon = 'fa-angle-double-up'; + + $('.panel-collapse').each(function(){ + if($(this).attr('class').indexOf(inStr) == -1) + { + allOpen = false; + } + }) + + if(allOpen) + { + // close all + $('.panel-collapse').each(function(){$(this).attr('class', 'panel-collapse collapse ')}) + $('#toggleSettings').attr('class', $('#toggleSettings').attr('class').replace(closeIcon, openIcon)) + } + else{ + // open all + $('.panel-collapse').each(function(){$(this).attr('class', 'panel-collapse collapse in')}) + $('#toggleSettings').attr('class', $('#toggleSettings').attr('class').replace(openIcon, closeIcon)) + } + + }