feat: add configurable view-aware dashboards

This commit is contained in:
2026-07-29 14:32:54 +02:00
parent b28229c003
commit f0732bead2
24 changed files with 3169 additions and 146 deletions

View File

@@ -0,0 +1,53 @@
import {
apiFetch,
apiPath,
type ApiSettings,
type DashboardWidgetConfiguration,
type DashboardWidgetSize
} from "@govoplan/core-webui";
export type DashboardWidgetPlacementResponse = {
instance_id: string;
widget_id: string;
size: DashboardWidgetSize;
configuration: DashboardWidgetConfiguration;
};
export type DashboardLayoutResponse = {
exists: boolean;
view_id: string | null;
layout_version: number;
revision: number;
placements: DashboardWidgetPlacementResponse[];
known_widget_ids: string[];
updated_at: string | null;
};
export type DashboardLayoutUpdate = {
expected_revision: number | null;
layout_version: 1;
placements: DashboardWidgetPlacementResponse[];
known_widget_ids: string[];
};
function layoutPath(viewId: string | null): string {
return apiPath("/api/v1/dashboard/layout", { view_id: viewId });
}
export function fetchDashboardLayout(
settings: ApiSettings,
viewId: string | null
): Promise<DashboardLayoutResponse> {
return apiFetch<DashboardLayoutResponse>(settings, layoutPath(viewId));
}
export function saveDashboardLayout(
settings: ApiSettings,
viewId: string | null,
payload: DashboardLayoutUpdate
): Promise<DashboardLayoutResponse> {
return apiFetch<DashboardLayoutResponse>(settings, layoutPath(viewId), {
method: "PUT",
body: JSON.stringify(payload)
});
}