Column settings preserved after restart

This commit is contained in:
Jokob-sk
2023-01-29 14:13:31 +11:00
parent 2e532abf6b
commit 2e0cb923db
3 changed files with 19 additions and 8 deletions

View File

@@ -3234,6 +3234,8 @@ def isNewVersion():
buildTimestamp = int(f.read().strip()) buildTimestamp = int(f.read().strip())
f.close() f.close()
data = ""
try: try:
url = requests.get("https://api.github.com/repos/jokob-sk/Pi.Alert/releases") url = requests.get("https://api.github.com/repos/jokob-sk/Pi.Alert/releases")
text = url.text text = url.text

View File

@@ -204,14 +204,26 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function main () { 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 visible columns
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'&parameter=Front_Devices_Columns_Visible&skipcache', function(data) { $.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+defaultValue+'&parameter=Front_Devices_Columns_Visible&skipcache', function(data) {
// save which columns are in the Devices page visible
tableColumnVisible = numberArrayFromString(data); 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 the custom order specified by the user
$.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+columnsStr+'&parameter=Front_Devices_Columns_Order&skipcache', function(data) { $.get('php/server/parameters.php?action=get&expireMinutes=525600&defaultValue='+defaultValue+'&parameter=Front_Devices_Columns_Order&skipcache', function(data) {
// save the columns order in the Devices page
tableColumnOrder = numberArrayFromString(data); tableColumnOrder = numberArrayFromString(data);
//initialize the table headers in the correct order //initialize the table headers in the correct order
@@ -243,8 +255,6 @@ function main () {
} }
$('#tableDevices tr').html(html); $('#tableDevices tr').html(html);
// get parameter value // get parameter value
$.get('php/server/parameters.php?action=get&defaultValue=50&parameter='+ parTableRows, function(data) { $.get('php/server/parameters.php?action=get&defaultValue=50&parameter='+ parTableRows, function(data) {
@@ -282,14 +292,13 @@ function main () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
var tableColumnHide = []; var tableColumnHide = [];
// mapping the default order to the user specified one
function mapIndx(oldIndex) function mapIndx(oldIndex)
{ {
for(i=0;i<tableColumnOrder.length;i++) for(i=0;i<tableColumnOrder.length;i++)
{ {
if(tableColumnOrder[i] == oldIndex) if(tableColumnOrder[i] == oldIndex)
{ {
// console.log('newIndex')
// console.log(i)
return i; return i;
} }
} }

View File

@@ -195,7 +195,7 @@ $lang['en_us'] = array(
'DevDetail_EveandAl_ScanCycle' => 'Scan device', 'DevDetail_EveandAl_ScanCycle' => 'Scan device',
'DevDetail_EveandAl_AlertAllEvents' => 'Alert All Events', 'DevDetail_EveandAl_AlertAllEvents' => 'Alert All Events',
'DevDetail_EveandAl_AlertDown' => 'Alert Down', '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_NewDevice' => 'New Device',
'DevDetail_EveandAl_Archived' => 'Archived', 'DevDetail_EveandAl_Archived' => 'Archived',
'DevDetail_EveandAl_RandomMAC' => 'Random MAC', '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_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 <a href="#NMAP_RUN"><code>NMAP_RUN</code> setting</a>.', 'NMAP_ACTIVE_description' => 'If enabled this will execute a scan on a newly found device. For a scheduled or one-off scan, check the <a href="#NMAP_RUN"><code>NMAP_RUN</code> setting</a>.',
'NMAP_TIMEOUT_name' => 'Run timeout', '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_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 <code>once</code> Nmap is run only once on start for the time specified in <a href="#NMAP_TIMEOUT"><code>NMAP_TIMEOUT</code> setting</a>.', 'NMAP_RUN_description' => 'Enable a regular Nmap scan on your network on all devices. The scheduling settings can be found below. If you select <code>once</code> Nmap is run only once on start for the time specified in <a href="#NMAP_TIMEOUT"><code>NMAP_TIMEOUT</code> setting</a>.',
'NMAP_RUN_SCHD_name' => 'Schedule', 'NMAP_RUN_SCHD_name' => 'Schedule',