librelad 2ef4cc00e1 refactor(webui): granular sub-system folders per component
De-clutter each component into sub-system folders (apps: core/ port-manager/
services/ tools/ routing/; admin: config/ overview/ system/ ssh/ peers/) with
the standard js/ css/ html/ icons/ layout inside; single-page components
(backup/dashboard/tasks/updater) get js/ css/ html/. Single-feature icon sets
moved into their sub-system (vpn -> apps/core/icons, config/cpu/os ->
admin/{config,system}/icons); shared app + category icons stay in core/icons.
feature.json + index.js stay at each component root (the scanned descriptor +
entry). Every controller/CSS/fragment/icon path reference rewritten; verified
no stale refs, all JS valid.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-30 12:42:35 +01:00

33 lines
1.4 KiB
JavaScript

// features/updater/index.js — App Updater feature module.
//
// Per-app version tracking + CVE/security scanning + disaster-recovery
// (snapshot-before-update and rollback). Built in the same shape as the backup
// feature: a self-registering module whose mount() lazy-loads the controller,
// renders a fragment, and news the page object; unmount() releases its
// task-refresh registration. All state-changing actions go through the task
// system (libreportal updater …), never a new mutating API.
LP.features.register({
id: 'updater',
routes: ['/updater', '/updater*'],
scripts: ['/components/updater/js/updater-page.js'],
async mount(ctx) {
await ctx.loadScripts(this.scripts);
const html = await ctx.loadFragment('/components/updater/html/updater-content.html');
ctx.setContent(html, 'Updates');
if (typeof UpdaterPage === 'undefined') {
throw new Error('UpdaterPage controller failed to load');
}
window.updaterPage = new UpdaterPage(ctx.services);
await window.updaterPage.init();
},
async unmount(ctx) {
// Drop the task-refresh registration so a finished update/rollback task
// doesn't repaint a torn-down page. The page self-guards via
// (window.updaterPage === this); nulling it neutralises any pending work.
try { ctx.services.tasks.refresh && ctx.services.tasks.refresh.unregister('updater'); } catch (_) {}
window.updaterPage = null;
},
});