From 1101bc9477814afbe999269e50adf00a4755e705 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Tue, 1 Aug 2023 08:11:52 +1000 Subject: [PATCH] settings rewrite to JS --- front/css/pialert.css | 5 ++ front/php/server/util.php | 18 ++--- front/php/templates/language/en_us.json | 1 + front/settings.php | 99 ++++++++++++++----------- pialert/initialise.py | 4 +- 5 files changed, 70 insertions(+), 57 deletions(-) diff --git a/front/css/pialert.css b/front/css/pialert.css index 209c1ec9..22acde6b 100755 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -646,6 +646,11 @@ height: 50px; } } +.settingswrap .metadata +{ + display: none; +} + .table_row { padding: 3px; width:100%; diff --git a/front/php/server/util.php b/front/php/server/util.php index de7df32e..b4ee1e3e 100755 --- a/front/php/server/util.php +++ b/front/php/server/util.php @@ -295,14 +295,12 @@ function saveSettings() $txt .= $settingKey . "=" . $val . "\n"; } elseif ($settingType == 'text.multiselect' || $settingType == 'subnets' || $settingType == 'list') { - $temp = '['; - - echo $settingType.'
'; - echo $settingKey.'
'; - echo json_encode($settingValue).'
'; - // echo json_decode($settingValue).'
'; - - // json_decode($settingValue) todo + $temp = ''; + + if(is_array($settingValue) == FALSE) + { + $settingValue = json_decode($settingValue); + } if (count($setting) > 3 && is_array($settingValue) == true) { foreach ($settingValue as $val) { @@ -312,7 +310,7 @@ function saveSettings() $temp = substr_replace($temp, "", -1); // remove last comma ',' } - $temp .= ']'; // close brackets + $temp = '['.$temp.']'; // wrap brackets $txt .= $settingKey . "=" . $temp . "\n"; } elseif ($settingType == 'json') { $txt .= $settingKey . "=" . $settingValue . "\n"; @@ -330,7 +328,7 @@ function saveSettings() $txt = $txt."#-------------------IMPORTANT INFO-------------------#\n"; // open new file and write the new configuration - $newConfig = fopen($fullConfPath.'_debug', "w") or die("Unable to open file!"); // todo + $newConfig = fopen($fullConfPath, "w") or die("Unable to open file!"); fwrite($newConfig, $txt); fclose($newConfig); diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 6a8aeaec..3f57aaf1 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -414,6 +414,7 @@ "Plugins_DeleteAll" : "Delete all (filters are ignored)", "Plugins_History" : "Events History", "Plugins_Filters_Mac" : "Mac Filter", + "Settings_Metadata_Toggle" : "Show/hide metadata for the given setting.", "settings_missing" : "Not all settings loaded, refresh the page! This is probably caused by a high load on the database.", "settings_missing_block" : "You can not 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 not have time to import it yet to the DB. You can wait until the settings get refreshed so you do not overwrite your old values. Feel free to save your settings either way if you don not mind losing the settings between the last save and now. There are also backup files created if you need to compare your settings later.", diff --git a/front/settings.php b/front/settings.php index 365cec67..c60bb28c 100755 --- a/front/settings.php +++ b/front/settings.php @@ -71,7 +71,7 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
-
+
@@ -93,7 +93,6 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { ?> -