-
-
Notifications
You must be signed in to change notification settings - Fork 426
Expand file tree
/
Copy pathsettings.php
More file actions
executable file
·741 lines (590 loc) · 27.4 KB
/
Copy pathsettings.php
File metadata and controls
executable file
·741 lines (590 loc) · 27.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
<?php
require 'php/templates/header.php';
//------------------------------------------------------------------------------
// Action selector
//------------------------------------------------------------------------------
// Set maximum execution time to 15 seconds
ini_set ('max_execution_time','30');
// check permissions
// Use environment-aware paths with fallback to legacy locations
$dbFolderPath = rtrim(getenv('NETALERTX_DB') ?: '/data/db', '/');
$configFolderPath = rtrim(getenv('NETALERTX_CONFIG') ?: '/data/config', '/');
$dbPath = $dbFolderPath . '/app.db';
$confPath = $configFolderPath . '/app.conf';
// Fallback to legacy paths if new locations don't exist
if (!file_exists($dbPath) && file_exists('../db/app.db')) {
$dbPath = '../db/app.db';
}
if (!file_exists($confPath) && file_exists('../config/app.conf')) {
$confPath = '../config/app.conf';
}
// get settings from the API json file
// path to your JSON file
$apiRoot = rtrim(getenv('NETALERTX_API') ?: '/tmp/api', '/');
$file = $apiRoot . '/table_settings.json';
// put the content of the file in a variable
$data = file_get_contents($file);
// JSON decode
$settingsJson = json_decode($data);
// get settings from the DB
global $db;
$result = $db->query("SELECT * FROM Settings");
$settings = array();
while ($row = $result -> fetchArray (SQLITE3_ASSOC)) {
// Push row data
$settings[] = array( 'setKey' => $row['setKey'],
'setName' => $row['setName'],
'setDescription' => $row['setDescription'],
'setType' => $row['setType'],
'setOptions' => $row['setOptions'],
'setValue' => $row['setValue'],
'setGroup' => $row['setGroup'],
'setEvents' => $row['setEvents']
);
}
$settingsJSON_DB = json_encode($settings, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
?>
<!-- Page ------------------------------------------------------------------ -->
<!-- ----------------------------------------------------------------------- -->
<script src="lib/crypto/crypto-js.min.js"></script>
<script src="lib/bcrypt/bcrypt.min.js"></script>
<div id="settingsPage" class="content-wrapper">
<?php require 'php/templates/skel_settings.php'; ?>
<!-- Content header--------------------------------------------------------- -->
<section class="content-header">
<div class ="bg-white color-palette box box-solid col-sm-12 panel panel-default panel-title" >
<a data-toggle="collapse" href="#settingsOverview">
<div class ="settings-group col-sm-12 ">
<i class="<?= lang("settings_enabled_icon");?>"></i> <?= lang("settings_enabled");?>
</div>
</a>
<div id="settingsOverview" class="panel-collapse collapse in">
<div class="panel-body"></div>
<div class =" col-sm-12 " id=""></div>
</div>
</section>
<div class="content settingswrap " id="accordion_gen">
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="core_content_header" >
<div class ="settings-group col-sm-12">
<i class="<?= lang("settings_core_icon");?>"></i> <?= lang("settings_core_label");?>
</div>
<div class =" col-sm-12" id="core_content"></div>
</div>
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="system_content_header" >
<div class ="settings-group col-sm-12">
<i class="<?= lang("settings_system_icon");?>"></i> <?= lang("settings_system_label");?>
</div>
<div class =" col-sm-12" id="system_content"></div>
</div>
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="device_scanners_content_header" >
<div class ="settings-group col-sm-12">
<i class="<?= lang("settings_device_scanners_icon");?>"></i> <?= lang("settings_device_scanners_label");?>
</div>
<div class =" col-sm-12" id="device_scanner_content"> <?= lang("settings_device_scanners_info");?> </div>
</div>
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="other_scanners_content_header">
<div class ="settings-group col-sm-12">
<i class="<?= lang("settings_other_scanners_icon");?>"></i> <?= lang("settings_other_scanners_label");?>
</div>
<div class =" col-sm-12" id="other_content"></div>
</div>
<div class ="bg-grey-dark color-palette panel panel-default col-sm-12 box-default box-info" id="publishers_content_header" >
<div class ="settings-group col-sm-12">
<i class="<?= lang("settings_publishers_icon");?>"></i> <?= lang("settings_publishers_label");?>
</div>
<div class =" col-sm-12" id="publisher_content"><?= lang("settings_publishers_info");?></div>
</div>
</div>
<!-- /.content -->
<section class=" padding-bottom col-sm-12">
<!-- needed so the filter & save button don't hide the settings -->
<!-- Settings imported time -->
<div class="col-sm-7 settingsImportedTimestamp" style="display:none" title="<?= lang("settings_imported");?> ">
<div class="settingsImported ">
<?= lang("settings_imported_label");?>:
<span id="lastImportedTime"></span>
</div>
</div>
</section>
<section class=" settings-sticky-bottom-section col-sm-10 col-xs-12">
<div class="col-xs-8 settingsSearchWrap has-success bg-white color-palette ">
<div class ="col-xs-12">
<input type="text" id="settingsSearch" class="form-control input-xs col-xs-12" placeholder="Filter Settings...">
<div class="clear-filter ">
<i class="fa-solid fa-circle-xmark" onclick="$('#settingsSearch').val('');filterRows();$('#settingsSearch').focus()"></i>
</div>
</div>
</div>
<div class="col-xs-4 saveSettingsWrapper">
<button type="button" class=" btn btn-primary btn-default pa-btn bg-green" id="save" onclick="saveSettings()"><?= lang('DevDetail_button_Save');?></button>
</div>
<div id="result"></div>
</section>
</div>
<!-- /.content-wrapper -->
<!-- ----------------------------------------------------------------------- -->
<?php
require 'php/templates/footer.php';
?>
<script>
// -------------------------------------------------------------------
// Get plugin and settings data from API endpoints
function getData(){
console.log("in getData");
// get settings from the secured graphql endpoint
$.ajax({
url: "php/server/query_graphql.php", // Replace with your GraphQL endpoint
method: "POST",
contentType: "application/json",
data: JSON.stringify({
query: `
query {
settings {
settings {
setKey
setName
setDescription
setOptions
setGroup
setType
setValue
setEvents
setOverriddenByEnv
}
count
}
}
`
}),
success: function (response) {
console.log("Response:", response);
// Handle the successful response
if (response && response.data && response.data.settings && response.data.settings.settings) {
const settingsData = response.data.settings.settings;
console.log("Settings:", settingsData);
// Wrong number of settings processing
if(settingsNumberDB != settingsData.length)
{
showModalOk('WARNING', "<?= lang("settings_old")?>");
setTimeout(() => {
clearCache()
}, 3000);
} else
{
$.get('php/server/query_json.php', { file: 'plugins.json', nocache: Date.now() }, function(res) {
pluginsData = res["data"];
// Sort settingsData alphabetically, ensuring "General" is always first
settingsData.sort((a, b) => {
if (a["setGroup"] === "General") {
return -1; // Place "General" first
}
if (b["setGroup"] === "General") {
return 1; // Place "General" first
}
// For other values, sort alphabetically
if (a["setGroup"] < b["setGroup"]) {
return -1;
}
if (a["setGroup"] > b["setGroup"]) {
return 1;
}
return 0;
});
exception_occurred = false;
// check if cache needs to be refreshed
// the getSetting method returns an empty string even if a setting is not found
// however, __metadata needs to be always a JSON object
// let's use that to verify settings were initialized correctly
settingsData.forEach((set) => {
setKey = set['setKey']
try {
const isMetadata = setKey.includes('__metadata');
// if this isn't a metadata entry, get corresponding metadata object from the dummy setting
const setObj = isMetadata ? {} : JSON.parse(getSetting(`${setKey}__metadata`));
} catch (error) {
console.error(`Error getting setting for ${setKey}:`, error);
showModalOk('WARNING', "Outdated cache - refreshing (refresh browser cache if needed)");
setTimeout(() => {
clearCache()
}, 3000);
exception_occurred = true;
}
});
// only proceed if everything was loaded correctly
if(!exception_occurred)
{
initSettingsPage(settingsData, pluginsData);
}
})
}
}
},
error: function (xhr, status, error) {
console.error("Error:", error);
hideSettingsSkeleton();
}
});
}
// -------------------------------------------------------------------
// main initialization function
function initSettingsPage(settingsData, pluginsData){
const settingPluginPrefixes = [];
const enabledDeviceScanners = getPluginsByType(pluginsData, "device_scanner", true);
const enabledOthers = getPluginsByType(pluginsData, "other", true);
const enabledPublishers = getPluginsByType(pluginsData, "publisher", true);
// Loop through the settingsArray and:
// - collect unique settingPluginPrefixes
// - collect enabled plugins
settingsData.forEach((set) => {
// settingPluginPrefixes
if (!settingPluginPrefixes.includes(set.setGroup)) {
settingPluginPrefixes.push(set.setGroup); // = Unique plugin prefix
}
});
// Init the overview section
overviewSections = [
'device_scanners',
'other_scanners',
'publishers'
]
overviewSectionsHtml = [
pluginCards(enabledDeviceScanners,['RUN', 'RUN_SCHD']),
pluginCards(enabledOthers, ['RUN', 'RUN_SCHD']),
pluginCards(enabledPublishers, []),
]
index = 0
overviewSections_html = ''
overviewSections.forEach((section) => {
const sectionHtml = overviewSectionsHtml[index];
if (sectionHtml.trim()) {
overviewSections_html += `<div class="overview-section col-sm-12" id="${section}">
<div class="col-sm-12 " title="${getString("settings_"+section)}">
<a href="#${section}_content_header">
<div class="overview-group col-sm-12 col-xs-12">
<i title="${section}" class="${getString("settings_"+section+"_icon")}"></i>
${getString("settings_"+section+"_label")}
</div>
</a>
</div>
<div class="col-sm-12">
${sectionHtml}
</div>
</div>`
}
index++;
});
$('#settingsOverview .panel-body').append(overviewSections_html);
// Display warning
if(schedulesAreSynchronized(enabledDeviceScanners, pluginsData) == false)
{
$("#device_scanners").append(
`
<small class="label pull-right bg-red pointer" onClick="showModalOk('WARNING', '${getString("Settings_device_Scanners_desync_popup")}')">
${getString('Settings_device_Scanners_desync')}
</small>
`)
}
for (const prefix of settingPluginPrefixes) {
// enabled / disabled icons
enabledHtml = ''
if(getSetting(prefix+"_RUN") != "")
{
// show all enabled plugins
getSetting(prefix+"_RUN") != 'disabled' ? onOff = 'dot-circle' : onOff = 'circle';
enabledHtml = `
<div class="enabled-disabled-icon">
<i class="fa fa-${onOff}"></i>
</div>
`
}
// console.log(pluginsData);
// Start constructing the main settings HTML
let pluginHtml = `
<div class="row table_row docs">
<div class="table_cell bold">
<i class="fa fa-book fa-sm"></i>
${getString(prefix+'_description')}
<a href="https://github.com/netalertx/NetAlertX/tree/main/front/plugins/${getPluginCodeName(pluginsData, prefix)}" target="_blank">
${getString('Gen_ReadDocs')}
</a>
</div>
</div>
`;
// Plugin HEADER
headerHtml = `<div class="box box-solid box-primary panel panel-default" id="${prefix}_header">
<a data-toggle="collapse" data-parent="#accordion_gen" href="#${prefix}">
<div class="panel-heading">
<h4 class="panel-title">
<div class="col-sm-1 col-xs-1">${getString(prefix+"_icon")}</div>
<div class="col-sm-3 col-xs-6">${prefix}</div>
<div class="col-sm-7 hideOnMobile">${getString(prefix+"_display_name")}</div>
<div class="col-sm-1 col-xs-3">${enabledHtml}</div>
</h4>
</div>
</a>
<div id="${prefix}" data-myid="collapsible" class="panel-collapse collapse ${prefix == "General" ? ' in ' : ""}">
<div class="panel-body">
${prefix != "General" ? pluginHtml: ""}
</div>
</div>
</div>
`;
// generate headers/sections
$('#'+getPluginType(pluginsData, prefix) + "_content").append(headerHtml);
}
// generate panel content
for (const prefix of settingPluginPrefixes) {
// go thru all settings and collect settings per settings prefix
settingsData.forEach((set) => {
const valIn = set['setValue'];
const setKey = set['setKey'];
const overriddenByEnv = set['setOverriddenByEnv'] == 1;
const setType = set['setType'];
const isMetadata = setKey.includes('__metadata');
// is this isn't a metadata entry, get corresponding metadata object from the dummy setting
const setObj = isMetadata ? {} : JSON.parse(getSetting(`${setKey}__metadata`));
// not initialized properly, reload
if(isMetadata && valIn == "" )
{
console.warn(`Metadata setting value is empty: ${setKey}`);
clearCache();
}
// constructing final HTML for the setting
setHtml = ""
if(set["setGroup"] == prefix)
{
// hide metadata by default by assigning it a special class
isMetadata ? metadataClass = 'metadata' : metadataClass = '';
isMetadata ? showMetadata = '' : showMetadata = `<i
my-to-toggle="row_${setKey}__metadata"
title="${getString("Settings_Metadata_Toggle")}"
class="fa fa-circle-question pointer hideOnMobile"
onclick="toggleMetadata(this)">
</i>` ;
infoIcon = `<i my-to-show="#row_${setKey} .setting_description"
title="${getString("Settings_Show_Description")}"
class="fa fa-circle-info pointer hideOnBigScreen"
onclick="showDescription(this)">
</i>` ;
// NAME & DESCRIPTION columns
setHtml += `
<div class="row table_row ${metadataClass} " id="row_${setKey}">
<div class="table_cell setting_name bold col-sm-2">
<label>${getString(setKey + '_name', set['setName'])}</label>
<div class="small text-overflow-hidden">
<code>${setKey}</code>${showMetadata}${infoIcon}
</div>
</div>
<div class="table_cell setting_description col-sm-4">
${getString(setKey + '_description', set['setDescription'])}
</div>
<div class="table_cell input-group setting_input ${overriddenByEnv ? "setting_overriden_by_env" : ""} input-group col-xs-12 col-sm-6">
`;
// OVERRIDE (NOT YET IMPLEMENTED)
// surface settings override functionality if the setting is a template that can be overridden with user defined values
// if the setting is a json of the correct structure, handle like a template setting
let overrideHtml = "";
//pre-check if this is a json object that needs value extraction
let overridable = false; // indicates if the setting is overridable
let override = false; // If the setting is set to be overridden by the user or by default
let readonly = ""; // helper variable to make text input readonly
let disabled = ""; // helper variable to make checkbox input readonly
// TODO finish
if ('override_value' in setObj) {
overridable = true;
overrideObj = setObj["override_value"]
override = overrideObj["override"];
console.log(setObj)
console.log(prefix)
}
// prepare override checkbox and HTML
if(overridable)
{
let checked = override ? 'checked' : '';
overrideHtml = `<div class="override col-xs-12">
<div class="override-check col-xs-1">
<input onChange="overrideToggle(this)" my-data-type="${setType}" my-input-toggle-readonly="${setKey}" class="checkbox" id="${setKey}_override" type="checkbox" ${checked} />
</div>
<div class="override-text col-xs-11" title="${getString("Setting_Override_Description")}">
${getString("Setting_Override")}
</div>
</div>`;
}
// INPUT
inputFormHtml = generateFormHtml(settingsData, set, valIn, null, null, false);
// construct final HTML for the setting
setHtml += inputFormHtml + overrideHtml + `
</div>
</div>
`
// generate settings in the correct prefix (group) section
$(`#${prefix} .panel-body`).append(setHtml);
}
});
}
// init finished
setTimeout(() => {
initListInteractionOptions() // init remove and edit listitem click gestures
}, 50);
setupSmoothScrolling();
// try to initialize select2
initSelect2();
initHoverNodeInfo();
hideSpinner();
hideSettingsSkeleton();
}
// ----------------------------------------------------------------
function hideSettingsSkeleton() {
var $skel = $('#settings-skeleton');
if (!$skel.length) return;
$('#settingsPage').removeClass('settings-loading');
$skel.fadeOut(250, function() { $(this).remove(); });
}
// display the name of the first person
// echo $settingsJson[0]->name;
var settingsNumberDB = <?php echo count($settings)?>;
var settingsJSON_DB = <?php echo $settingsJSON_DB ?>;
var settingsNumberJSON = <?php echo count($settingsJson->data)?>;
// Wrong number of settings processing
if(settingsNumberJSON != settingsNumberDB)
{
showModalOk('WARNING', getString("settings_missing"));
}
// ---------------------------------------------------------
function saveSettings() {
if(settingsNumberJSON != settingsNumberDB)
{
console.log(`Error settingsNumberJSON != settingsNumberDB: ${settingsNumberJSON} != ${settingsNumberDB}`);
showModalOk('WARNING', getString("settings_missing_block"));
setTimeout(() => {
clearCache()
}, 1500);
} else {
let settingsArray = [];
// collect values for each of the different input form controls
// get settings to determine setting type to store values appropriately
$.get('php/server/query_json.php', { file: 'table_settings.json', nocache: Date.now() }, function(res) {
// loop through the settings definitions from the json
res["data"].forEach(set => {
prefix = set["setGroup"]
setType = set["setType"]
setCodeName = set["setKey"]
// settingsArray = collectSetting(prefix, setCodeName, setType, settingsArray)
const collectSettingResult = collectSetting(prefix, setCodeName, setType, settingsArray);
settingsArray = collectSettingResult.settingsArray;
if (!collectSettingResult.dataIsValid) {
msg = getString("Gen_Invalid_Value") + ": " + collectSettingResult.failedSettingKey;
console.error(msg);
showMessage (msg, 3000, "modal_red");
// return early
return;
}
});
// sanity check to make sure settings were loaded & collected correctly
if(settingsCollectedCorrectly(settingsArray, settingsJSON_DB))
{
console.log(settingsArray);
console.log(settingsJSON_DB);
console.log( JSON.stringify(settingsArray));
// return; // 🐛 🔺
// trigger a save settings event in the backend
$.ajax({
method: "POST",
url: "php/server/util.php",
data: {
function: 'savesettings',
settings: JSON.stringify(settingsArray) },
success: function(data, textStatus) {
// Parse response: support both legacy "OK" string and new JSON format
let saveSucceeded = false;
let requiresReloadWait = true; // safe default
if (data === "OK") {
saveSucceeded = true;
} else {
let parsed = null;
try { parsed = (typeof data === 'object') ? data : JSON.parse(data); } catch(e) {}
if (parsed && parsed.success === true) {
saveSucceeded = true;
requiresReloadWait = parsed.requiresReloadWait === true;
}
}
if (saveSucceeded) {
// Remove navigation prompt "Are you sure you want to leave..."
window.onbeforeunload = null;
write_notification(`[Settings] Settings saved by the user`, 'info')
if (requiresReloadWait) {
clearCache()
} else {
showMessage(getString("settings_saved_background"), 5000, "modal_green");
}
} else {
// something went wrong
write_notification("[Important] Please take a screenshot of the Console tab in the browser (F12) and next error. Submit it (with the nginx and php error logs) as a new issue here: https://github.com/netalertx/NetAlertX/issues", 'interrupt')
write_notification(data, 'interrupt')
console.log("🔽");
console.log(settingsArray);
console.log(JSON.stringify(settingsArray));
console.log(data);
console.log("🔼");
}
}
});
}
})
}
}
</script>
<!-- INIT THE PAGE -->
<script defer>
function handleLoadingDialog()
{
// Check if app config is read only
const canReadAndWriteConfig = <?php echo (is_readable($confPath) && is_writable($confPath)) ? 'true' : 'false'; ?>;
if(!canReadAndWriteConfig)
{
showMessage (getString("settings_readonly"), 10000, "modal_red");
console.log(`app.conf seems to be read only (canRWConfig: ${canReadAndWriteConfig})`);
hideSettingsSkeleton();
} else
{
// check if config file has been updated
$.get('php/server/query_json.php', { file: 'app_state.json', nocache: Date.now() }, function(appState) {
console.log("Settings: Got app_state.json");
fileModificationTime = <?php echo filemtime($confPath)*1000;?>;
// console.log(appState["settingsImported"]*1000)
importedMiliseconds = parseInt((appState["settingsImported"]*1000));
// check if displayed settings are outdated
if(appState["showSpinner"] || fileModificationTime > importedMiliseconds)
{
showSpinner("settings_old")
setTimeout("handleLoadingDialog()", 1000);
} else
{
checkInitialization();
}
humanReadable = (new Date(importedMiliseconds)).toLocaleString("en-UK", { timeZone: "<?php echo $timeZone?>" });
document.getElementById('lastImportedTime').innerHTML = humanReadable;
})
}
}
function checkInitialization() {
if (isAppInitialized()) {
// App is initialized, hide spinner and proceed with initialization
console.log("App initialized, proceeding...");
getData();
// Reload page if outdated information might be displayed
if (secondsSincePageLoad() > 10) {
console.log("App outdated, reloading...");
clearCache();
}
} else {
console.log("App not initialized, checking again in 1s...");
// Check again after a delay
setTimeout(checkInitialization, 1000);
}
}
showSpinner()
handleLoadingDialog()
// Fallback: hide skeleton after 15s in case of unexpected error
setTimeout(hideSettingsSkeleton, 15000)
</script>