feat: Enhance dashboard widget configuration and introduce new widgets
Deploy Development / deploy (push) Successful in 48s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 16s

- Updated the dashboard layout schema to include new widgets: DashboardGreeting, QuickWeightToday, BodyStatStrip, StatusPills, ProfileGoalsProgress, TrendKcalWeight, NutritionActivitySummary, RecoverySleepRest, and TrainingTypeDistribution.
- Improved widget configuration validation to support new features, including chart days for trend and distribution widgets.
- Refactored the default lab layout to align with the updated widget catalog and ensure proper default activation.
- Bumped app_dashboard version to 1.6.0 to reflect the addition of new widgets and configuration enhancements.
This commit is contained in:
Lars committed 2026-04-07 14:19:45 +02:00
1 parent c0c512e942
commit 3d498d03c1
28 files changed
+1487 -243

No files matched your search

+25 -1
View File
@@ -12,7 +12,13 @@ from typing import Any
MAX_WIDGET_CONFIG_JSON_BYTES = 3072
WIDGETS_ALLOWING_CONFIG: frozenset[str] = frozenset({"body_overview", "activity_overview", "kpi_board"})
WIDGETS_ALLOWING_CONFIG: frozenset[str] = frozenset({
"body_overview",
"activity_overview",
"kpi_board",
"trend_kcal_weight",
"training_type_distribution",
})
_KPI_TILE_FIXED: frozenset[str] = frozenset({"body_fat", "avg_kcal"})
_KPI_REF_TILE_RE = re.compile(r"^ref:[a-z0-9_]{1,64}$")
@@ -41,6 +47,10 @@ def validate_widget_entry_config(widget_id: str, raw: Any) -> dict[str, Any]:
return _validate_chart_days_only(raw, label="activity_overview")
if widget_id == "kpi_board":
return _validate_kpi_board_config(raw)
if widget_id == "trend_kcal_weight":
return _validate_chart_days_only(raw, label="trend_kcal_weight")
if widget_id == "training_type_distribution":
return _validate_distribution_days_only(raw)
raise ValueError(f"Widget {widget_id}: keine Konfiguration unterstützt")
@@ -118,3 +128,17 @@ def _validate_chart_days_only(raw: dict[str, Any], *, label: str) -> dict[str, A
if v < 7 or v > 90:
raise ValueError(f"{label}: chart_days muss zwischen 7 und 90 liegen")
return {"chart_days": v}
def _validate_distribution_days_only(raw: dict[str, Any]) -> dict[str, Any]:
label = "training_type_distribution"
allowed = frozenset({"distribution_days"})
unknown = set(raw) - allowed
if unknown:
raise ValueError(f"{label}: unbekannte config-Felder: {sorted(unknown)}")
if "distribution_days" not in raw:
return {}
v = _parse_chart_days(raw["distribution_days"], label)
if v < 7 or v > 120:
raise ValueError(f"{label}: distribution_days muss zwischen 7 und 120 liegen")
return {"distribution_days": v}