From 2e0cb923db51640791a9cd64f9b56d5e985b0b06 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sun, 29 Jan 2023 14:13:31 +1100 Subject: [PATCH] Column settings preserved after restart --- back/pialert.py | 2 ++ front/devices.php | 21 +++++++++++++++------ front/php/templates/language/en_us.php | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/back/pialert.py b/back/pialert.py index e0f8fb04..f1dedb0a 100755 --- a/back/pialert.py +++ b/back/pialert.py @@ -3234,6 +3234,8 @@ def isNewVersion(): buildTimestamp = int(f.read().strip()) f.close() + data = "" + try: url = requests.get("https://api.github.com/repos/jokob-sk/Pi.Alert/releases") text = url.text diff --git a/front/devices.php b/front/devices.php index 67af8d2f..ed0d08c0 100755 --- a/front/devices.php +++ b/front/devices.php @@ -204,14 +204,26 @@ // ----------------------------------------------------------------------------- function main () { + // get from cookie if available (need to use decodeURI as saved as part of URI in PHP) + cookieColumnsVisibleStr = decodeURI(getCookie("Front_Devices_Columns_Visible")).replaceAll('%2C',',') + + defaultValue = cookieColumnsVisibleStr == "" ? columnsStr : cookieColumnsVisibleStr; + // get visible columns - $.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'¶meter=Front_Devices_Columns_Visible&skipcache', function(data) { + $.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+defaultValue+'¶meter=Front_Devices_Columns_Visible&skipcache', function(data) { + // save which columns are in the Devices page visible tableColumnVisible = numberArrayFromString(data); + // get from cookie if available (need to use decodeURI as saved as part of URI in PHP) + cookieColumnsOrderStr = decodeURI(getCookie("Front_Devices_Columns_Order")).replaceAll('%2C',',') + + defaultValue = cookieColumnsOrderStr == "" ? columnsStr : cookieColumnsOrderStr; + // get the custom order specified by the user - $.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'¶meter=Front_Devices_Columns_Order&skipcache', function(data) { + $.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+defaultValue+'¶meter=Front_Devices_Columns_Order&skipcache', function(data) { + // save the columns order in the Devices page tableColumnOrder = numberArrayFromString(data); //initialize the table headers in the correct order @@ -243,8 +255,6 @@ function main () { } $('#tableDevices tr').html(html); - - // get parameter value $.get('php/server/parameters.php?action=get&defaultValue=50¶meter='+ parTableRows, function(data) { @@ -282,14 +292,13 @@ function main () { // ----------------------------------------------------------------------------- var tableColumnHide = []; +// mapping the default order to the user specified one function mapIndx(oldIndex) { for(i=0;i 'Scan device', 'DevDetail_EveandAl_AlertAllEvents' => 'Alert All Events', 'DevDetail_EveandAl_AlertDown' => 'Alert Down', -'DevDetail_EveandAl_Skip' => 'Skip repeated notifications during', +'DevDetail_EveandAl_Skip' => 'Skip repeated notifications for', 'DevDetail_EveandAl_NewDevice' => 'New Device', 'DevDetail_EveandAl_Archived' => 'Archived', 'DevDetail_EveandAl_RandomMAC' => 'Random MAC', @@ -638,7 +638,7 @@ the arp-scan will take hours to complete instead of seconds. 'NMAP_ACTIVE_name' => 'Cycle run', 'NMAP_ACTIVE_description' => 'If enabled this will execute a scan on a newly found device. For a scheduled or one-off scan, check the NMAP_RUN setting.', 'NMAP_TIMEOUT_name' => 'Run timeout', -'NMAP_TIMEOUT_description' => 'Maximum time to wait for an Nmap scan to finish on any device.', +'NMAP_TIMEOUT_description' => 'Maximum time in seconds to wait for an Nmap scan to finish on any device.', 'NMAP_RUN_name' => 'Scheduled run', 'NMAP_RUN_description' => 'Enable a regular Nmap scan on your network on all devices. The scheduling settings can be found below. If you select once Nmap is run only once on start for the time specified in NMAP_TIMEOUT setting.', 'NMAP_RUN_SCHD_name' => 'Schedule',