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

+3 -1
View File
@@ -11,7 +11,7 @@ from typing import Any
MAX_WIDGET_CONFIG_JSON_BYTES = 1024
WIDGETS_ALLOWING_CONFIG: frozenset[str] = frozenset({"body_overview", "activity_overview"})
WIDGETS_ALLOWING_CONFIG: frozenset[str] = frozenset({"body_overview", "activity_overview", "kpi_board"})
def _config_json_size_bytes(config: dict[str, Any]) -> int:
@@ -35,6 +35,8 @@ def validate_widget_entry_config(widget_id: str, raw: Any) -> dict[str, Any]:
return _validate_chart_days_only(raw, label="body_overview")
if widget_id == "activity_overview":
return _validate_chart_days_only(raw, label="activity_overview")
if widget_id == "kpi_board":
return _validate_chart_days_only(raw, label="kpi_board")
raise ValueError(f"Widget {widget_id}: keine Konfiguration unterstützt")
+10 -3
View File
@@ -14,7 +14,7 @@ def test_body_chart_days_bounds():
validate_widget_entry_config("body_overview", {"chart_days": 91})
def test_welcome_config_rejected():
def test_welcome_config_rejected_unknown_key():
with pytest.raises(ValueError):
validate_widget_entry_config("welcome", {"x": 1})
@@ -30,9 +30,16 @@ def test_activity_chart_days():
validate_widget_entry_config("activity_overview", {"chart_days": 5})
def test_kpi_config_rejected():
def test_kpi_board_chart_days():
assert validate_widget_entry_config("kpi_board", {}) == {}
assert validate_widget_entry_config("kpi_board", {"chart_days": 14}) == {"chart_days": 14}
with pytest.raises(ValueError):
validate_widget_entry_config("kpi_board", {"chart_days": 30})
validate_widget_entry_config("kpi_board", {"chart_days": 5})
def test_welcome_still_rejects_config():
with pytest.raises(ValueError):
validate_widget_entry_config("welcome", {"chart_days": 30})
def test_layout_payload_with_chart_days_roundtrip():
+1 -1
View File
@@ -30,7 +30,7 @@ MODULE_VERSIONS = {
"importdata": "1.0.0",
"membership": "2.1.0",
"workflow": "0.6.0", # Phase 4: End Node Template Engine
"app_dashboard": "1.3.0", # activity_overview.chart_days + WidgetErrorBoundary
"app_dashboard": "1.4.0", # kpi_board.config.chart_days (Ø-Kalorien Fenster)
}
CHANGELOG = [
+1 -1
View File
@@ -30,7 +30,7 @@ WIDGET_CATALOG: list[WidgetCatalogEntry] = [
{
"id": "kpi_board",
"title": "KPI-Kacheln",
"description": "Referenzwerte, KF%, Kalorien",
"description": "Referenzwerte, KF%, Ø-Kalorien (optional: chart_days 7–90 für Ernährungsfenster)",
},
{
"id": "body_overview",