mitai-jinkendo/frontend/src/widgetSystem/registerPilotLabWidgets.js
Lars de99856a28
Some checks failed
Deploy Development / deploy (push) Failing after 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
feat: Extend widget configuration for KPI board and enhance validation
- Added support for the "kpi_board" widget in the dashboard configuration, allowing for chart_days validation.
- Updated the widget catalog description to reflect the new configuration options for KPI tiles.
- Enhanced the DashboardLabPage to manage chart_days input for the KPI board, improving user experience.
- Introduced normalization functions for KPI kcal window days to maintain consistent behavior.
- Bumped app_dashboard version to 1.4.0 to reflect these enhancements.
2026-04-07 12:37:04 +02:00

58 lines
1.8 KiB
JavaScript

/**
* Pilot/Lab-Widgets registrieren. IDs müssen zu backend/widget_catalog.WIDGET_CATALOG passen.
*/
import PilotWelcome from '../components/pilot/PilotWelcome'
import PilotQuickCapture from '../components/pilot/PilotQuickCapture'
import PilotKpiBoard from '../components/pilot/PilotKpiBoard'
import PilotBodySection from '../components/pilot/PilotBodySection'
import PilotActivitySection from '../components/pilot/PilotActivitySection'
import { normalizeBodyChartDays, normalizeKpiKcalWindowDays } from './bodyChartDays'
import { registerDashboardWidget } from './dashboardWidgetRegistry'
let _registered = false
export function ensurePilotLabWidgetsRegistered() {
if (_registered) return
_registered = true
registerDashboardWidget({
id: 'welcome',
Component: PilotWelcome,
mapProps: () => ({}),
})
registerDashboardWidget({
id: 'quick_capture',
Component: PilotQuickCapture,
mapProps: (ctx) => ({ onSaved: ctx.requestRefresh }),
})
registerDashboardWidget({
id: 'kpi_board',
Component: PilotKpiBoard,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
kcalWindowDays: normalizeKpiKcalWindowDays(ctx.layoutEntry?.config?.chart_days),
}),
})
registerDashboardWidget({
id: 'body_overview',
Component: PilotBodySection,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
chartDays: normalizeBodyChartDays(ctx.layoutEntry?.config?.chart_days),
}),
})
registerDashboardWidget({
id: 'activity_overview',
Component: PilotActivitySection,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
chartDays: normalizeBodyChartDays(ctx.layoutEntry?.config?.chart_days),
}),
})
}
/** @internal Nur für Tests */
export function __resetPilotLabRegistrationForTests() {
_registered = false
}