librelad e1794069cb feat(webui): add App Updater feature (versions, CVEs, disaster recovery)
New self-contained feature in features/updater/ (mirrors the backup feature):
- index.js + feature.json (auto-discovered; routes /updater + sub-tabs).
- updater-page.js: 5 tabs — Overview (update/CVE/recovery counts), Updates
  (per-app current->available + Update/Update-all), Security (CVEs by severity,
  links to NVD), Recovery (per-app rollback points; snapshot-before-update),
  History. Reads /data/updater/generated/{updates,cves,history}.json; falls
  back to the installed-apps list so it's useful before the first scan. All
  actions route through services.tasks (updater_check/apply/apply_all/rollback)
  — no new mutating API.
- updater.css (self-contained, teal --page-updater hue) + updater-content.html.
- New topbar 'Updates' nav button (nav-updater) + active-highlighting in
  topbar.js + spa.js. Kernel: setupRoutesFromManifest now allows module-only
  features (no legacy handler) — this is the first such feature.

Backend generator + 'libreportal updater' task land next.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-30 02:45:40 +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: ['/features/updater/updater-page.js'],
async mount(ctx) {
await ctx.loadScripts(this.scripts);
const html = await ctx.loadFragment('/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;
},
});