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

47 lines
1.9 KiB
JavaScript

// features/apps/index.js — the App Center grid (/apps, /apps/<category>).
//
// window.appsManager is a system-loader singleton (created by
// initializeComponents); mount() calls .initialize(), never `new`. Routes
// '/apps' and '/apps*' are registered BEFORE the app-detail feature's '/app*'
// so findRouteHandler's longest-prefix wildcard match resolves /apps* here
// (the manifest order guarantees this). unmount() is a no-op: the singleton and
// its constructor-time taskRefresh registrations are shared with app-detail and
// the dashboard and must outlive this view.
LP.features.register({
id: 'apps',
routes: ['/apps', '/apps*'],
async mount(ctx) {
// Category from the path (/apps/<category>), else legacy ?=<cat> / ?apps=.
const seg = window.location.pathname.replace(/^\/apps\/?/, '').split('/')[0];
if (seg) {
window.appsCategory = decodeURIComponent(seg);
} else {
const search = window.location.search || '';
if (search.includes('?=')) {
window.appsCategory = (window.location.pathname + search).split('?=')[1] || 'all';
} else {
window.appsCategory = new URLSearchParams(search).get('apps') || 'all';
}
}
// Load the unified layout only if it isn't already present — preserves grid
// state when moving between categories / back from app-detail (legacy behaviour).
if (!document.querySelector('.apps-layout')) {
const html = await ctx.loadFragment('/components/apps/core/html/apps-unified-layout.html');
ctx.setContent(html, 'Applications');
}
if (!window.appsManager) {
throw new Error('AppsManager not initialized by SystemLoader');
}
await window.appsManager.initialize();
},
async unmount() {
// Nothing to release — AppsManager is a shared system-loader singleton.
// The dirty-config nav guard (window.__appConfigNavGuard) fires in
// navigate() BEFORE unmount and is owned by AppsManager, so we leave it.
},
});