feat: Extend widget configuration for KPI board and enhance validation
Deploy Development / deploy (push) Failing after 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s

- 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.
This commit is contained in:
Lars committed 2026-04-07 12:37:04 +02:00
1 parent 97f9aa696e
commit de99856a28
8 files changed
+65 -24

No files matched your search

+9 -1
View File
@@ -1,4 +1,4 @@
/** Körper-Chart: gültiger Bereich (sync mit backend dashboard_widget_config body_overview). */
/** Körper-/Aktivitäts-Chart: gültiger Bereich (sync mit backend dashboard_widget_config). */
export const BODY_CHART_DAYS_MIN = 7
export const BODY_CHART_DAYS_MAX = 90
export const BODY_CHART_DAYS_DEFAULT = 30
@@ -8,3 +8,11 @@ export function normalizeBodyChartDays(raw) {
if (!Number.isFinite(n)) return BODY_CHART_DAYS_DEFAULT
return Math.min(BODY_CHART_DAYS_MAX, Math.max(BODY_CHART_DAYS_MIN, Math.round(n)))
}
/** KPI-Board Ø-Kalorien: gleiche Grenzen, Default 7 Tage (bisheriges Verhalten ohne config). */
export const KPI_KCAL_WINDOW_DEFAULT = 7
export function normalizeKpiKcalWindowDays(raw) {
if (raw == null || raw === '') return KPI_KCAL_WINDOW_DEFAULT
return normalizeBodyChartDays(raw)
}
@@ -6,7 +6,7 @@ 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 } from './bodyChartDays'
import { normalizeBodyChartDays, normalizeKpiKcalWindowDays } from './bodyChartDays'
import { registerDashboardWidget } from './dashboardWidgetRegistry'
let _registered = false
@@ -28,7 +28,10 @@ export function ensurePilotLabWidgetsRegistered() {
registerDashboardWidget({
id: 'kpi_board',
Component: PilotKpiBoard,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
kcalWindowDays: normalizeKpiKcalWindowDays(ctx.layoutEntry?.config?.chart_days),
}),
})
registerDashboardWidget({
id: 'body_overview',