f15b035b88
Replaces monolithic AdminDashboard/ClientDashboard with a per-user configurable widget grid. 15 widget types: ProductionStats, QueueStatus, RecentRenders, CostOverview, WorkerStatus, KPISummary, OrderThroughput, Revenue, ItemStatus, ProcessingTimes, RenderTimeByOutputType, OutputTypeUsage, TopProducts, OrdersByUser, RenderBackendStats. DashboardTimeframeContext provides shared timeframe state. Dashboard config persisted in DB via GET/PUT /api/dashboard/config. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
67 lines
1.4 KiB
TypeScript
67 lines
1.4 KiB
TypeScript
import api from './client'
|
|
|
|
export type WidgetType =
|
|
| 'ProductionStats'
|
|
| 'QueueStatus'
|
|
| 'RecentRenders'
|
|
| 'CostOverview'
|
|
| 'WorkerStatus'
|
|
| 'KPISummary'
|
|
| 'OrderThroughput'
|
|
| 'RevenueChart'
|
|
| 'ItemStatus'
|
|
| 'ProcessingTimes'
|
|
| 'RenderTimeByOutputType'
|
|
| 'OutputTypeUsage'
|
|
| 'TopProducts'
|
|
| 'OrdersByUser'
|
|
| 'RenderBackendStats'
|
|
|
|
export interface WidgetPosition {
|
|
col: number
|
|
row: number
|
|
w: number
|
|
h: number
|
|
}
|
|
|
|
export interface WidgetConfig {
|
|
widget_type: WidgetType
|
|
position: WidgetPosition
|
|
config?: Record<string, unknown>
|
|
}
|
|
|
|
interface DashboardConfigResponse {
|
|
widgets: WidgetConfig[]
|
|
}
|
|
|
|
export async function getDashboardConfig(): Promise<WidgetConfig[]> {
|
|
const { data } = await api.get<DashboardConfigResponse>('/dashboard/config')
|
|
return data.widgets
|
|
}
|
|
|
|
export async function updateDashboardConfig(
|
|
widgets: WidgetConfig[]
|
|
): Promise<WidgetConfig[]> {
|
|
const { data } = await api.put<DashboardConfigResponse>('/dashboard/config', {
|
|
widgets,
|
|
})
|
|
return data.widgets
|
|
}
|
|
|
|
export async function getTenantDefaultDashboard(): Promise<WidgetConfig[]> {
|
|
const { data } = await api.get<DashboardConfigResponse>(
|
|
'/dashboard/tenant-default'
|
|
)
|
|
return data.widgets
|
|
}
|
|
|
|
export async function updateTenantDefaultDashboard(
|
|
widgets: WidgetConfig[]
|
|
): Promise<WidgetConfig[]> {
|
|
const { data } = await api.put<DashboardConfigResponse>(
|
|
'/dashboard/tenant-default',
|
|
{ widgets }
|
|
)
|
|
return data.widgets
|
|
}
|