mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Settings app.conf RW check + VNDRPDT plugin
This commit is contained in:
@@ -1312,9 +1312,12 @@ async function isGraphQLServerRunning() {
|
||||
// -----------------------------------------------------------------------------
|
||||
// Check if the code has been executed before by checking sessionStorage
|
||||
function isAppInitialized() {
|
||||
const completedCallsCount_final = getLangCode() == 'en_us' ? 3 : 4;
|
||||
|
||||
completedCalls = parseInt(getCache("completedCallsCount"));
|
||||
shouldBeCompletedCalls = getLangCode() == 'en_us' ? 3 : 4;
|
||||
|
||||
return (
|
||||
parseInt(getCache("completedCallsCount")) >= completedCallsCount_final
|
||||
completedCalls >= shouldBeCompletedCalls
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1325,6 +1328,8 @@ async function executeOnce() {
|
||||
|
||||
if (!isAppInitialized()) {
|
||||
try {
|
||||
console.log("HERE");
|
||||
|
||||
await waitForGraphQLServer(); // Wait for the server to start
|
||||
|
||||
await cacheDevices();
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "",
|
||||
"settings_publishers_info": "",
|
||||
"settings_publishers_label": "",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "",
|
||||
"settings_system_icon": "",
|
||||
"settings_system_label": "",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "",
|
||||
"settings_publishers_info": "",
|
||||
"settings_publishers_label": "",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "",
|
||||
"settings_system_icon": "",
|
||||
"settings_system_label": "",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "",
|
||||
"settings_publishers_info": "",
|
||||
"settings_publishers_label": "",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "",
|
||||
"settings_system_icon": "",
|
||||
"settings_system_label": "",
|
||||
|
||||
@@ -792,6 +792,7 @@
|
||||
"settings_publishers_icon": "",
|
||||
"settings_publishers_info": "Lade mehr Veröffentlicher mit den <a href=\"/settings.php#LOADED_PLUGINS\">geladene Plugins</a>-Einstellungen",
|
||||
"settings_publishers_label": "Veröffentlicher",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "<br/>Einstellungen gespeichert. <br/> Wird geladen... <br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "",
|
||||
"settings_system_label": "System",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "Load more Publishers with the <a href=\"/settings.php#LOADED_PLUGINS\">LOADED_PLUGINS</a> setting",
|
||||
"settings_publishers_label": "Publishers",
|
||||
"settings_readonly": "Can't READ or WRITE <code>app.conf</code>. Try restarting the container and read the <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/FILE_PERMISSIONS.md\" target=\"_blank\">file permissions documentation</a>",
|
||||
"settings_saved": "<br/>Settings saved. <br/> Reloading... <br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "System",
|
||||
|
||||
@@ -790,6 +790,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "Cargue más editor@s con el ajuste <a href=\"/settings.php#LOADED_PLUGINS\">LOADED_PLUGINS</a>",
|
||||
"settings_publishers_label": "Editores",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "<br/>Ajustes guardados. <br/><br/> Recargando... <br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "Sistema",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "Charger plus de passerelles de publication avec le paramètre <a href=\"/settings.php#LOADED_PLUGINS\">LOADED_PLUGINS</a>",
|
||||
"settings_publishers_label": "Passerelles de publication",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "<br/>Paramètres enregistrés. <br/> Rechargement... <br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "Système",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "Carica più editori con l'impostazione <a href=\"/settings.php#LOADED_PLUGINS\">LOADED_PLUGINS</a>",
|
||||
"settings_publishers_label": "Editori",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "<br/>Impostazioni salvate. <br/> Aggiornamento in corso... <br/> <i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "Sistema",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "",
|
||||
"settings_publishers_label": "Utgivere",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "<br/>Innstillinger lagret. <br/> Laster inn på nytt... <br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i><br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "System",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "",
|
||||
"settings_publishers_label": "Wydawcy",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "<br/>Ustawienia zapisane.<br/>Przeładowanie...<br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i><br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "System",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "",
|
||||
"settings_publishers_info": "",
|
||||
"settings_publishers_label": "",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "",
|
||||
"settings_system_icon": "",
|
||||
"settings_system_label": "",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "fa-solid fa-paper-plane",
|
||||
"settings_publishers_info": "Загрузите больше нотификаторов с помощью настройки <a href=\"/settings.php#LOADED_PLUGINS\">LOADED_PLUGINS</a>",
|
||||
"settings_publishers_label": "Уведомления",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "<br/>Настройки сохранены. <br/> Перезагрузка... <br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "fa-solid fa-gear",
|
||||
"settings_system_label": "Система",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "",
|
||||
"settings_publishers_info": "",
|
||||
"settings_publishers_label": "",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "",
|
||||
"settings_system_icon": "",
|
||||
"settings_system_label": "Sistem",
|
||||
|
||||
@@ -711,6 +711,7 @@
|
||||
"settings_publishers_icon": "",
|
||||
"settings_publishers_info": "使用 <a href=\"/settings.php#LOADED_PLUGINS\">LOADED_PLUGINS</a> 设置加载更多发布商",
|
||||
"settings_publishers_label": "出版商",
|
||||
"settings_readonly": "",
|
||||
"settings_saved": "<br/>设置已保存。<br/> 正在加载...<br/><i class=\"ion ion-ios-loop-strong fa-spin fa-2x fa-fw\"></i> <br/>",
|
||||
"settings_system_icon": "",
|
||||
"settings_system_label": "系统",
|
||||
|
||||
@@ -91,6 +91,7 @@ def update_vendors (dbPath, plugin_objects):
|
||||
devVendor
|
||||
FROM Devices
|
||||
WHERE devVendor = '(unknown)'
|
||||
OR devVendor = '(Unknown)'
|
||||
OR devVendor = ''
|
||||
OR devVendor IS NULL
|
||||
""")
|
||||
|
||||
@@ -176,6 +176,8 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
||||
// Get plugin and settings data from API endpoints
|
||||
function getData(){
|
||||
|
||||
console.log("in getData");
|
||||
|
||||
$.get('api/table_settings.json?nocache=' + Date.now(), function(res) {
|
||||
|
||||
settingsData = res["data"];
|
||||
@@ -819,8 +821,6 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -829,41 +829,46 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
||||
|
||||
function handleLoadingDialog()
|
||||
{
|
||||
// Check if app config is read only
|
||||
const canReadAndWriteConfig = <?php echo (is_readable($confPath) && is_writable($confPath)) ? 'true' : 'false'; ?>;
|
||||
|
||||
// check if config file has been updated
|
||||
$.get('api/app_state.json?nocache=' + Date.now(), function(appState) {
|
||||
if(!canReadAndWriteConfig)
|
||||
{
|
||||
showMessage (getString("settings_readonly"), 10000, "modal_red");
|
||||
console.log(`app.conf seems to be read only (canRWConfig: ${canReadAndWriteConfig}`);
|
||||
} else
|
||||
{
|
||||
// check if config file has been updated
|
||||
$.get('api/app_state.json?nocache=' + Date.now(), function(appState) {
|
||||
|
||||
fileModificationTime = <?php echo filemtime($confPath)*1000;?>;
|
||||
|
||||
fileModificationTime = <?php echo filemtime($confPath)*1000;?>;
|
||||
// console.log(appState["settingsImported"]*1000)
|
||||
importedMiliseconds = parseInt((appState["settingsImported"]*1000));
|
||||
humanReadable = (new Date(importedMiliseconds)).toLocaleString("en-UK", { timeZone: "<?php echo $timeZone?>" });
|
||||
|
||||
// console.log(appState["settingsImported"]*1000)
|
||||
importedMiliseconds = parseInt((appState["settingsImported"]*1000));
|
||||
// check if displayed settings are outdated
|
||||
if(appState["showSpinner"] || fileModificationTime > importedMiliseconds)
|
||||
{
|
||||
showSpinner("settings_old")
|
||||
|
||||
humanReadable = (new Date(importedMiliseconds)).toLocaleString("en-UK", { timeZone: "<?php echo $timeZone?>" });
|
||||
setTimeout("handleLoadingDialog()", 1000);
|
||||
|
||||
// console.log(humanReadable.replaceAll('"', ''))
|
||||
} else
|
||||
{
|
||||
checkInitialization();
|
||||
}
|
||||
|
||||
// check if displayed settings are outdated
|
||||
|
||||
if(appState["showSpinner"] || fileModificationTime > importedMiliseconds)
|
||||
{
|
||||
|
||||
showSpinner("settings_old")
|
||||
document.getElementById('lastImportedTime').innerHTML = humanReadable;
|
||||
})
|
||||
|
||||
setTimeout("handleLoadingDialog()", 1000);
|
||||
|
||||
} else
|
||||
{
|
||||
checkInitialization();
|
||||
}
|
||||
|
||||
|
||||
document.getElementById('lastImportedTime').innerHTML = humanReadable;
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function checkInitialization() {
|
||||
|
||||
if (isAppInitialized()) {
|
||||
// App is initialized, hide spinner and proceed with initialization
|
||||
console.log("App initialized, proceeding...");
|
||||
@@ -880,7 +885,7 @@ $settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX
|
||||
// Check again after a delay
|
||||
setTimeout(checkInitialization, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
showSpinner()
|
||||
|
||||
Reference in New Issue
Block a user