Extract dashboard overview route

This commit is contained in:
ejclaw
2026-04-28 19:08:58 +09:00
parent 036b80b106
commit 0d8682b2da
3 changed files with 232 additions and 19 deletions

View File

@@ -38,7 +38,7 @@ import type {
RegisteredGroup,
ScheduledTask,
} from './types.js';
import { buildWebDashboardOverview } from './web-dashboard-data.js';
import { handleOverviewRoute } from './web-dashboard-overview-routes.js';
import {
handleRoomTimelineRoute,
startRoomsTimelineCacheRefresh,
@@ -822,24 +822,18 @@ export function createWebDashboardHandler(
});
if (simpleGetRoute) return simpleGetRoute;
if (url.pathname === '/api/overview') {
const snapshots = readSnapshots(statusMaxAgeMs);
const tasks = loadTasks();
const pairedTasks = loadPairedTasks();
const overview = buildWebDashboardOverview({
now: opts.now?.(),
snapshots,
tasks,
pairedTasks,
});
return jsonResponse({
...overview,
operations: {
serviceRestarts: recentServiceRestarts,
},
inbox: overview.inbox.filter((item) => !isInboxItemDismissed(item)),
});
}
const overviewRoute = handleOverviewRoute({
url,
jsonResponse,
isInboxItemDismissed,
loadPairedTasks,
loadTasks,
readSnapshots,
recentServiceRestarts,
statusMaxAgeMs,
now: opts.now,
});
if (overviewRoute) return overviewRoute;
if (url.pathname.startsWith('/api/')) {
return jsonResponse({ error: 'Not found' }, { status: 404 });