Refactor network API calls to use centralized authentication context and improve cache handling

- Removed redundant getApiToken function and replaced its usage with getAuthContext in network-api.js, network-events.js, and network-init.js.
- Updated cache handling in network-events.js and network-init.js to use CACHE_KEYS constants for better maintainability.
- Introduced cache.js for centralized cache management functions and constants, including cache initialization and retrieval.
- Added app-init.js for application lifecycle management, including cache orchestration and initialization checks.
- Created app_config.php to securely fetch API token and GraphQL port from configuration.
- Improved error handling and logging throughout the codebase for better debugging and maintenance.
This commit is contained in:
Jokob @NetAlertX
2026-02-26 04:21:29 +00:00
parent 00042ab594
commit 63cef590d6
12 changed files with 915 additions and 682 deletions

View File

@@ -84,12 +84,12 @@ $(window).on('resize', function () {
*/
$(document).ready(function () {
// Restore cached values on load
const cachedOffline = getCache('showOffline');
const cachedOffline = getCache(CACHE_KEYS.SHOW_OFFLINE);
if (cachedOffline !== null) {
$('input[name="showOffline"]').prop('checked', cachedOffline === 'true');
}
const cachedArchived = getCache('showArchived');
const cachedArchived = getCache(CACHE_KEYS.SHOW_ARCHIVED);
if (cachedArchived !== null) {
$('input[name="showArchived"]').prop('checked', cachedArchived === 'true');
}
@@ -102,7 +102,7 @@ $(document).ready(function () {
if (!isOfflineChecked) {
archivedToggle.prop('checked', false);
archivedToggle.prop('disabled', true);
setCache('showArchived', false);
setCache(CACHE_KEYS.SHOW_ARCHIVED, false);
} else {
archivedToggle.prop('disabled', false);
}
@@ -115,6 +115,8 @@ $(document).ready(function () {
$('input[name="showOffline"], input[name="showArchived"]').on('change', function () {
const name = $(this).attr('name');
const value = $(this).is(':checked');
// setCache(name, value) works because CACHE_KEYS.SHOW_OFFLINE === 'showOffline'
// and CACHE_KEYS.SHOW_ARCHIVED === 'showArchived' — matches the DOM input name attr.
setCache(name, value);
// Update state of showArchived if showOffline changed