52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { dimensionLabDashboardFixture } from "$lib/model/fixtures/dimensionlab";
|
|
import {
|
|
createDashboardStore,
|
|
type DashboardStore,
|
|
} from "$lib/server/db/dashboard-store";
|
|
|
|
export type PlaceholderStatus = "ready" | "building";
|
|
|
|
export interface PlaceholderDashboard {
|
|
title: string;
|
|
subtitle: string;
|
|
status: PlaceholderStatus;
|
|
message: string;
|
|
schemaVersion?: string;
|
|
currentRevisionId?: string;
|
|
}
|
|
|
|
export function loadPlaceholderDashboard(): PlaceholderDashboard {
|
|
return {
|
|
title: "System Overview",
|
|
subtitle: "Dashboard runtime scaffold",
|
|
status: "building",
|
|
message:
|
|
"SvelteKit is running. Later issues will replace this placeholder with the validated dashboard model.",
|
|
};
|
|
}
|
|
|
|
export function loadDashboardRuntime(store?: DashboardStore): PlaceholderDashboard {
|
|
const dashboardStore = store || createDashboardStore();
|
|
|
|
try {
|
|
const seeded = dashboardStore.seedDashboardIfEmpty(dimensionLabDashboardFixture, {
|
|
actor: "dimensionlab-seed",
|
|
message: "load initial dashboard seed",
|
|
});
|
|
const active = dashboardStore.getActiveDashboard();
|
|
const document = active?.document || seeded.document;
|
|
const currentRevisionId = active?.currentRevisionId || seeded.id;
|
|
|
|
return {
|
|
title: document.metadata.title,
|
|
subtitle: document.metadata.subtitle || "",
|
|
status: "building",
|
|
message:
|
|
"Active dashboard document loaded from SQLite. Later issues will replace this placeholder with model-driven rendering.",
|
|
schemaVersion: document.schemaVersion,
|
|
currentRevisionId,
|
|
};
|
|
} finally {
|
|
if (!store) dashboardStore.close();
|
|
}
|
|
}
|