mitai-jinkendo/frontend/src/widgetSystem/registerPilotLabWidgets.js
Lars d22e0ba0a7
All checks were successful
Deploy Development / deploy (push) Successful in 51s
Build Test / pytest-backend (push) Successful in 5s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 18s
feat: add fitness_history_viz widget and enhance configuration handling
- Introduced the `fitness_history_viz` widget to the dashboard, enabling users to visualize fitness history data.
- Updated widget configuration to include `fitness_history_viz` in the allowed widgets and added validation for its configuration.
- Enhanced the widget catalog with details for the new `fitness_history_viz` entry.
- Implemented default values and validation logic for the widget's configuration, ensuring proper handling of user inputs.
- Added tests to ensure proper validation of the `fitness_history_viz` widget configuration.
- Bumped application version to reflect the addition of the new widget.
2026-04-22 10:13:21 +02:00

179 lines
6.5 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 DashboardGreetingWidget from '../components/dashboard-widgets/DashboardGreetingWidget'
import QuickWeightTodayWidget from '../components/dashboard-widgets/QuickWeightTodayWidget'
import BodyStatStripWidget from '../components/dashboard-widgets/BodyStatStripWidget'
import StatusPillsWidget from '../components/dashboard-widgets/StatusPillsWidget'
import ProfileGoalsProgressWidget from '../components/dashboard-widgets/ProfileGoalsProgressWidget'
import TrendKcalWeightWidget from '../components/dashboard-widgets/TrendKcalWeightWidget'
import NutritionActivitySummaryWidget from '../components/dashboard-widgets/NutritionActivitySummaryWidget'
import NutritionDetailChartsWidget from '../components/dashboard-widgets/NutritionDetailChartsWidget'
import BodyHistoryVizWidget from '../components/dashboard-widgets/BodyHistoryVizWidget'
import NutritionHistoryVizWidget from '../components/dashboard-widgets/NutritionHistoryVizWidget'
import FitnessHistoryVizWidget from '../components/dashboard-widgets/FitnessHistoryVizWidget'
import { normalizeBodyHistoryVizConfig } from './bodyHistoryVizConfig'
import { normalizeNutritionHistoryVizConfig } from './nutritionHistoryVizConfig'
import { normalizeFitnessHistoryVizConfig } from './fitnessHistoryVizConfig'
import RecoveryChartsPanelWidget from '../components/dashboard-widgets/RecoveryChartsPanelWidget'
import ProgressPhotosWidget from '../components/dashboard-widgets/ProgressPhotosWidget'
import RecoverySleepRestWidget from '../components/dashboard-widgets/RecoverySleepRestWidget'
import GoalsFocusTeaserWidget from '../components/dashboard-widgets/GoalsFocusTeaserWidget'
import AiPipelineInsightWidget from '../components/dashboard-widgets/AiPipelineInsightWidget'
import { normalizeBodyChartDays } 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,
captureConfig: ctx.layoutEntry?.config || {},
}),
})
registerDashboardWidget({
id: 'kpi_board',
Component: PilotKpiBoard,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
kpiConfig: ctx.layoutEntry?.config || {},
}),
})
registerDashboardWidget({
id: 'body_overview',
Component: PilotBodySection,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
chartDays: normalizeBodyChartDays(ctx.layoutEntry?.config?.chart_days),
}),
})
registerDashboardWidget({
id: 'body_history_viz',
Component: BodyHistoryVizWidget,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
bodyHistoryVizConfig: normalizeBodyHistoryVizConfig(ctx.layoutEntry?.config),
}),
})
registerDashboardWidget({
id: 'activity_overview',
Component: PilotActivitySection,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
chartDays: normalizeBodyChartDays(ctx.layoutEntry?.config?.chart_days),
}),
})
registerDashboardWidget({
id: 'dashboard_greeting',
Component: DashboardGreetingWidget,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
})
registerDashboardWidget({
id: 'quick_weight_today',
Component: QuickWeightTodayWidget,
mapProps: (ctx) => ({ onSaved: ctx.requestRefresh }),
})
registerDashboardWidget({
id: 'body_stat_strip',
Component: BodyStatStripWidget,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
})
registerDashboardWidget({
id: 'status_pills',
Component: StatusPillsWidget,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
})
registerDashboardWidget({
id: 'profile_goals_progress',
Component: ProfileGoalsProgressWidget,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
})
registerDashboardWidget({
id: 'trend_kcal_weight',
Component: TrendKcalWeightWidget,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
chartDays: ctx.layoutEntry?.config?.chart_days,
}),
})
registerDashboardWidget({
id: 'nutrition_activity_summary',
Component: NutritionActivitySummaryWidget,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
})
registerDashboardWidget({
id: 'nutrition_detail_charts',
Component: NutritionDetailChartsWidget,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
chartDays: ctx.layoutEntry?.config?.chart_days,
}),
})
registerDashboardWidget({
id: 'nutrition_history_viz',
Component: NutritionHistoryVizWidget,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
nutritionHistoryVizConfig: normalizeNutritionHistoryVizConfig(ctx.layoutEntry?.config),
}),
})
registerDashboardWidget({
id: 'fitness_history_viz',
Component: FitnessHistoryVizWidget,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
fitnessHistoryVizConfig: normalizeFitnessHistoryVizConfig(ctx.layoutEntry?.config),
}),
})
registerDashboardWidget({
id: 'recovery_charts_panel',
Component: RecoveryChartsPanelWidget,
mapProps: (ctx) => ({
refreshTick: ctx.refreshTick,
chartDays: ctx.layoutEntry?.config?.chart_days,
}),
})
registerDashboardWidget({
id: 'progress_photos',
Component: ProgressPhotosWidget,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
})
registerDashboardWidget({
id: 'recovery_sleep_rest',
Component: RecoverySleepRestWidget,
mapProps: () => ({}),
})
registerDashboardWidget({
id: 'goals_focus_teaser',
Component: GoalsFocusTeaserWidget,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
})
registerDashboardWidget({
id: 'ai_pipeline_insight',
Component: AiPipelineInsightWidget,
mapProps: (ctx) => ({ refreshTick: ctx.refreshTick }),
})
}
/** @internal Nur für Tests */
export function __resetPilotLabRegistrationForTests() {
_registered = false
}