mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
settings rewrite to JS
This commit is contained in:
@@ -229,7 +229,7 @@ function saveSettings()
|
|||||||
{
|
{
|
||||||
global $SETTINGS, $FUNCTION, $config_file, $fullConfPath, $configFolderPath, $timestamp;
|
global $SETTINGS, $FUNCTION, $config_file, $fullConfPath, $configFolderPath, $timestamp;
|
||||||
|
|
||||||
// save in the file
|
// save to the file
|
||||||
$new_name = $config_file.'_'.$timestamp.'.backup';
|
$new_name = $config_file.'_'.$timestamp.'.backup';
|
||||||
$new_location = $configFolderPath.$new_name;
|
$new_location = $configFolderPath.$new_name;
|
||||||
|
|
||||||
@@ -265,15 +265,64 @@ function saveSettings()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "--SETTINGS<br>";
|
||||||
|
echo count($SETTINGS);
|
||||||
|
echo "--SETTINGS session<br>";
|
||||||
|
echo count($_SESSION['pia_settingsArray']); //pia_settingsArray
|
||||||
|
echo "--SETTINGS session<br>";
|
||||||
|
echo $_SESSION['pia_settingsArray']; //pia_settingsArray
|
||||||
|
|
||||||
|
$index = 0;
|
||||||
|
foreach($SETTINGS as $setting)
|
||||||
|
{
|
||||||
|
if(count($setting) < 3)
|
||||||
|
{
|
||||||
|
echo "--PREV<br>";
|
||||||
|
echo json_encode($SETTINGS[$index -1]);
|
||||||
|
echo "--<br>";
|
||||||
|
echo json_encode($setting);
|
||||||
|
echo "--<br>";
|
||||||
|
echo count($setting);
|
||||||
|
echo "--NEXT<br>";
|
||||||
|
echo json_encode($SETTINGS[$index +1]);
|
||||||
|
echo "--<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$index = $index +1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// go thru the groups and prepare settings to write to file
|
// go thru the groups and prepare settings to write to file
|
||||||
foreach($groups as $group)
|
foreach($groups as $group)
|
||||||
{
|
{
|
||||||
$txt = $txt."\n\n# ".$group;
|
$txt = $txt."\n\n# ".$group;
|
||||||
$txt = $txt."\n#---------------------------\n" ;
|
$txt = $txt."\n#---------------------------\n" ;
|
||||||
|
|
||||||
|
$index = 0;
|
||||||
foreach($SETTINGS as $setting)
|
foreach($SETTINGS as $setting)
|
||||||
{
|
{
|
||||||
|
$index = $index +1;
|
||||||
if($group == $setting[0])
|
if($group == $setting[0])
|
||||||
{
|
{
|
||||||
|
// if (count($setting) < 3)
|
||||||
|
if ($index == 248)
|
||||||
|
{
|
||||||
|
echo json_encode($index-1);
|
||||||
|
echo json_encode($setting[0]);
|
||||||
|
echo json_encode($setting[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($setting) < 3)
|
||||||
|
// if ($index == 248)
|
||||||
|
{
|
||||||
|
echo "<br>----------------<br>";
|
||||||
|
echo json_encode($index-1);
|
||||||
|
echo json_encode($setting[0]);
|
||||||
|
echo json_encode($setting[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($setting[2] == 'text' or $setting[2] == 'password' or $setting[2] == 'readonly' or $setting[2] == 'text.select')
|
if($setting[2] == 'text' or $setting[2] == 'password' or $setting[2] == 'readonly' or $setting[2] == 'text.select')
|
||||||
{
|
{
|
||||||
$val = encode_single_quotes($setting[3]);
|
$val = encode_single_quotes($setting[3]);
|
||||||
@@ -304,6 +353,9 @@ function saveSettings()
|
|||||||
|
|
||||||
$temp = $temp.']'; // close brackets
|
$temp = $temp.']'; // close brackets
|
||||||
$txt = $txt.$setting[1]."=".$temp."\n" ;
|
$txt = $txt.$setting[1]."=".$temp."\n" ;
|
||||||
|
} elseif($setting[2] == 'json')
|
||||||
|
{
|
||||||
|
$txt = $txt.$setting[1]."=".$setting[3]."\n" ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -425,12 +425,12 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
|||||||
var settingsArray = [];
|
var settingsArray = [];
|
||||||
|
|
||||||
// generate javascript to collect values
|
// generate javascript to collect values
|
||||||
const noConversion = ['text', 'integer', 'password', 'readonly', 'text.select', 'integer.select', 'text.multiselect'];
|
const noConversion = ['text', 'integer', 'string', 'password', 'readonly', 'text.select', 'integer.select', 'text.multiselect'];
|
||||||
|
|
||||||
settingsJSON["data"].forEach(set => {
|
settingsJSON["data"].forEach(set => {
|
||||||
if (noConversion.includes(set['Type'])) {
|
if (noConversion.includes(set['Type'])) {
|
||||||
|
|
||||||
console.log($(set["Code_Name"]).val())
|
console.log($('#'+set["Code_Name"]).val())
|
||||||
console.log(set["Code_Name"])
|
console.log(set["Code_Name"])
|
||||||
|
|
||||||
settingsArray.push([set["Group"], set["Code_Name"], set["Type"], $('#'+set["Code_Name"]).val()]);
|
settingsArray.push([set["Group"], set["Code_Name"], set["Type"], $('#'+set["Code_Name"]).val()]);
|
||||||
@@ -455,13 +455,18 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
settingsArray.push([set["Group"], set["Code_Name"], set["Type"], JSON.stringify(temps)]);
|
settingsArray.push([set["Group"], set["Code_Name"], set["Type"], JSON.stringify(temps)]);
|
||||||
} else if (set['Type'] === 'json') {
|
} else if (set['Type'] === 'json') {
|
||||||
// todo: fix jquery value collection
|
const temps = $('#'+set["Code_Name"]).val();
|
||||||
const temps = $('#'+set["Code_Name"]).val();
|
|
||||||
settingsArray.push([set["Group"], set["Code_Name"], set["Type"], temps]);
|
settingsArray.push([set["Group"], set["Code_Name"], set["Type"], temps]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// todo fix passing values between front end and server
|
||||||
|
console.log("settingsArray");
|
||||||
console.log(settingsArray);
|
console.log(settingsArray);
|
||||||
|
|
||||||
|
sessionStorage.setItem('pia_settingsArray', settingsArray);
|
||||||
|
|
||||||
return settingsArray;
|
return settingsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ def plugin_param_from_glob_set(globalSetting):
|
|||||||
setTyp = globalSetting[3] # setting type
|
setTyp = globalSetting[3] # setting type
|
||||||
|
|
||||||
|
|
||||||
noConversion = ['text', 'integer', 'boolean', 'password', 'readonly', 'integer.select', 'text.select', 'integer.checkbox' ]
|
noConversion = ['text', 'string', 'integer', 'boolean', 'password', 'readonly', 'integer.select', 'text.select', 'integer.checkbox' ]
|
||||||
arrayConversion = ['text.multiselect', 'list']
|
arrayConversion = ['text.multiselect', 'list']
|
||||||
|
|
||||||
if setTyp in noConversion:
|
if setTyp in noConversion:
|
||||||
|
|||||||
Reference in New Issue
Block a user