33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
/*
|
|
* Admin entry point — bootstraps the admin console.
|
|
*
|
|
* Opens the shared IndexedDB, loads cached image rules, then hands control to
|
|
* the admin module which manages navigation, CRUD, and rendering for every
|
|
* admin category (Settings, Users, Sites, Check Lists, Reports).
|
|
*/
|
|
|
|
import { state } from './js/state.js';
|
|
import { openDatabase, dbGet } from './js/db.js';
|
|
import { STORE_CONFIG } from './js/constants.js';
|
|
import { initAdmin } from './js/admin.js';
|
|
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
/* Open the shared IndexedDB so image-policy read/write keeps working. */
|
|
state.db = await openDatabase();
|
|
|
|
/* Load cached image rules (may be null on first visit). */
|
|
const configRow = await dbGet(STORE_CONFIG, 'imageRules');
|
|
|
|
/* Hand off to the admin module for all further initialization. */
|
|
await initAdmin({ imageRules: configRow?.value || null });
|
|
});
|
|
|
|
/* Re-init when navigating back (fixes stale localStorage after bfcache) */
|
|
window.addEventListener('pageshow', async (e) => {
|
|
if (e.persisted) {
|
|
state.db = await openDatabase();
|
|
const configRow = await dbGet(STORE_CONFIG, 'imageRules');
|
|
await initAdmin({ imageRules: configRow?.value || null });
|
|
}
|
|
});
|