Merge claude/1
This commit is contained in:
commit
ff79249fdd
58
containers/libreportal/frontend/features/app-detail/index.js
Normal file
58
containers/libreportal/frontend/features/app-detail/index.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// features/app-detail/index.js — the per-app detail page (/app/<name>[/<tab>]).
|
||||||
|
//
|
||||||
|
// Shares the apps-unified-layout fragment with the App Center grid but renders
|
||||||
|
// via window.appTabbedManager (a system-loader singleton; call .initialize(),
|
||||||
|
// never `new`). Registered AFTER the apps feature so '/apps*' wins the wildcard
|
||||||
|
// match and only true /app* paths land here. mount() mirrors handleAppDetail
|
||||||
|
// exactly, including the legacy ?app= / ?=name parsing and the ?tab=/?config=
|
||||||
|
// → path rewrite. unmount() is a no-op for now (the singleton is shared); the
|
||||||
|
// known unguarded popstate/task-listener re-bind in app-tabbed-manager is
|
||||||
|
// addressed in a follow-up (it predates this migration).
|
||||||
|
LP.features.register({
|
||||||
|
id: 'app-detail',
|
||||||
|
routes: ['/app', '/app*'],
|
||||||
|
|
||||||
|
async mount(ctx) {
|
||||||
|
const url = new URL(window.location);
|
||||||
|
let appName = url.pathname.replace(/^\/app\/?/, '').split('/')[0];
|
||||||
|
appName = appName ? decodeURIComponent(appName) : '';
|
||||||
|
if (!appName) appName = url.searchParams.get('app');
|
||||||
|
|
||||||
|
// Old format ?=appname&tab=tabname
|
||||||
|
if (!appName && url.search.includes('?=')) {
|
||||||
|
const queryPart = url.search.replace('?', '');
|
||||||
|
for (const part of queryPart.split('&')) {
|
||||||
|
if (part.startsWith('=')) { appName = part.substring(1); break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!appName) { return ctx.nav('/apps', false); }
|
||||||
|
|
||||||
|
// Back-compat: rewrite legacy ?tab=/?config= to the canonical path shape
|
||||||
|
// before the page reads URL state (replaceState — no extra history entry).
|
||||||
|
const legacyTab = url.searchParams.get('tab');
|
||||||
|
const legacyConfig = url.searchParams.get('config');
|
||||||
|
if (legacyTab || legacyConfig) {
|
||||||
|
const tab = legacyTab === 'logs' ? 'tasks' : (legacyTab || 'config');
|
||||||
|
const sub = (tab === 'config') ? legacyConfig : null;
|
||||||
|
const taskId = url.searchParams.get('task');
|
||||||
|
const canonical = window.appPath(appName, tab, sub, taskId);
|
||||||
|
if (canonical !== url.pathname + url.search) {
|
||||||
|
window.history.replaceState({ route: canonical }, '', canonical);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const html = await ctx.loadFragment('/html/apps-unified-layout.html');
|
||||||
|
ctx.setContent(html, appName);
|
||||||
|
|
||||||
|
if (!window.appTabbedManager) {
|
||||||
|
throw new Error('AppTabbedManager not initialized by SystemLoader');
|
||||||
|
}
|
||||||
|
await window.appTabbedManager.initialize();
|
||||||
|
},
|
||||||
|
|
||||||
|
async unmount() {
|
||||||
|
// No-op: AppTabbedManager is a shared system-loader singleton. Its
|
||||||
|
// listener-rebind leak is pre-existing and fixed separately.
|
||||||
|
},
|
||||||
|
});
|
||||||
46
containers/libreportal/frontend/features/apps/index.js
Normal file
46
containers/libreportal/frontend/features/apps/index.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// 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('/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.
|
||||||
|
},
|
||||||
|
});
|
||||||
@ -112,6 +112,8 @@
|
|||||||
<!-- Feature modules self-register here (eager, tiny). Their heavy controllers
|
<!-- Feature modules self-register here (eager, tiny). Their heavy controllers
|
||||||
are still lazy-loaded by the module's mount(). -->
|
are still lazy-loaded by the module's mount(). -->
|
||||||
<script src="/features/dashboard/index.js"></script>
|
<script src="/features/dashboard/index.js"></script>
|
||||||
|
<script src="/features/apps/index.js"></script>
|
||||||
|
<script src="/features/app-detail/index.js"></script>
|
||||||
<script src="/features/backup/index.js"></script>
|
<script src="/features/backup/index.js"></script>
|
||||||
<script src="/features/tasks/index.js"></script>
|
<script src="/features/tasks/index.js"></script>
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
@ -36,9 +36,11 @@
|
|||||||
return this.shell.loadContent(html, title);
|
return this.shell.loadContent(html, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SPA navigation (for redirects from within a feature).
|
// SPA navigation (for redirects from within a feature). addToHistory mirrors
|
||||||
nav(path) {
|
// navigate()'s second arg so a feature can do a no-history redirect exactly
|
||||||
return this.shell.navigate(path);
|
// like the legacy handlers (e.g. handleAppDetail's navigate('/apps', false)).
|
||||||
|
nav(path, addToHistory = true) {
|
||||||
|
return this.shell.navigate(path, addToHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// addEventListener bound to this mount's AbortController — auto-removed on
|
// addEventListener bound to this mount's AbortController — auto-removed on
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user