settings rewrite to JS

This commit is contained in:
Jokob-sk
2023-07-31 08:14:50 +10:00
parent 55d7cb0fec
commit 6fd750e4e1
6 changed files with 25 additions and 24 deletions

View File

@@ -164,6 +164,12 @@ $db->close();
<div class="version" id="version" data-build-time="<?php echo file_get_contents( "buildtimestamp.txt");?>"><?php echo '<span id="new-version-text" class="myhidden">' .lang('Maintenance_new_version').'</span>'.'<span id="current-version-text" class="myhidden">' .lang('Maintenance_current_version').'</span>';?></div>
</div>
</div>
<div class="db_info_table_row">
<div class="db_info_table_cell" style="min-width: 140px"><?= lang('Maintenance_built_on');?></div>
<div class="db_info_table_cell">
<?php echo date("Y-m-d", ((int)file_get_contents( "buildtimestamp.txt")));?>
</div>
</div>
<div class="db_info_table_row">
<div class="db_info_table_cell" style="min-width: 140px"><?= lang('Maintenance_database_path');?></div>
<div class="db_info_table_cell">

View File

@@ -297,6 +297,13 @@ function saveSettings()
} elseif ($settingType == 'text.multiselect' || $settingType == 'subnets' || $settingType == 'list') {
$temp = '[';
echo $settingType.'<br>';
echo $settingKey.'<br>';
echo json_encode($settingValue).'<br>';
// echo json_decode($settingValue).'<br>';
// json_decode($settingValue) todo
if (count($setting) > 3 && is_array($settingValue) == true) {
foreach ($settingValue as $val) {
$temp .= "'" . encode_single_quotes($val) . "',";
@@ -323,7 +330,7 @@ function saveSettings()
$txt = $txt."#-------------------IMPORTANT INFO-------------------#\n";
// open new file and write the new configuration
$newConfig = fopen($fullConfPath, "w") or die("Unable to open file!");
$newConfig = fopen($fullConfPath.'_debug', "w") or die("Unable to open file!"); // todo
fwrite($newConfig, $txt);
fclose($newConfig);

View File

@@ -13,22 +13,14 @@
<!-- &copy; 2020 Puche -->
<span style="display:inline-block; transform: rotate(180deg)">&copy;</span>
2020 Puche (2022+ <a href="mailto:jokob@duck.com?subject=PiAlert">jokob-sk</a>) | <b>Built on: </b>
2020 Puche (2022+ <a href="mailto:jokob@duck.com?subject=PiAlert">jokob-sk</a>) | <b><?= lang('Maintenance_built_on');?>: </b>
<?php
echo date("Y-m-d", ((int)file_get_contents( "buildtimestamp.txt")));
?>
<?php echo date("Y-m-d", ((int)file_get_contents( "buildtimestamp.txt")));?>
| <b> Version: </b>
<?php
$filename = "/.VERSION";
<?php $filename = "/.VERSION";
if(file_exists($filename))
{

View File

@@ -216,9 +216,10 @@
"BackDevDetail_Copy_Title" : "Copy details",
"BackDevDetail_Copy_Ask" : "Copy details from device from the dropdown list (Everything on this page will be overwritten)?",
"Maintenance_Title" : "Maintenance tools",
"Maintenance_version" : "App updates",
"Maintenance_version" : "App updates",
"Maintenance_new_version" : "🆕 A new version is available. Check out the <a href=\"https://github.com/jokob-sk/Pi.Alert/releases\" target=\"_blank\">release notes</a>.",
"Maintenance_current_version" : "You are up-to-date. Check out what <a href=\"https://github.com/jokob-sk/Pi.Alert/issues/138\" target=\"_blank\">I am working on</a>.",
"Maintenance_built_on" : "Built on",
"Maintenance_database_path" : "Database-Path",
"Maintenance_database_size" : "Database-Size",
"Maintenance_database_rows" : "Table (Rows)",

View File

@@ -439,14 +439,8 @@ while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
const temp = $(`#${set["Code_Name"]}`).is(':checked') ? 1 : 0;
settingsArray.push([set["Group"], set["Code_Name"], set["Type"], temp]);
} else if (set['Code_Name'] === 'SCAN_SUBNETS') {
const temps = [];
$('#SCAN_SUBNETS option').each(function (i, selected) {
temps.push($(selected).val());
});
settingsArray.push([set["Group"], set["Code_Name"], set["Type"], JSON.stringify(temps)]);
} else if (set['Type'] === 'list') {
} else if (set['Type'] === 'list' || set['Type'] === 'subnets') {
const temps = [];
$(`#${set["Code_Name"]} option`).each(function (i, selected) {
const vl = $(selected).val();

View File

@@ -248,9 +248,6 @@ def importConfigs (db):
sql.executemany ("""INSERT INTO Settings ("Code_Name", "Display_Name", "Description", "Type", "Options",
"RegEx", "Value", "Group", "Events" ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""", conf.mySettingsSQLsafe)
# Used to determine the next import
conf.lastTimeImported = time.time()
# Is used to display a message in the UI when old (outdated) settings are loaded
initOrSetParam(db, "Back_Settings_Imported",(round(time.time() * 1000),) )
@@ -259,6 +256,10 @@ def importConfigs (db):
# update only the settings datasource
update_api(db, False, ["settings"])
# Used to determine the next import
conf.lastTimeImported = time.time()
#TO DO this creates a circular reference between API and HELPER !
mylog('info', '[Config] Imported new config')