feat: Enhance Dashboard-Lab with widget catalog integration and layout updates
Deploy Development / deploy (push) Successful in 46s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s

- Integrated a new API endpoint for fetching the widget catalog in the Dashboard-Lab.
- Updated the dashboard layout schema to utilize the widget catalog for dynamic widget management.
- Refactored DashboardLabPage and PilotVizPage to leverage the new widget rendering system.
- Removed deprecated widget metadata from the frontend, streamlining the widget management process.
- Bumped app_dashboard version to 1.1.0 to reflect the new features and improvements.
This commit is contained in:
Lars committed 2026-04-07 11:47:16 +02:00
1 parent e5f6e6c10d
commit f6c5f96768
13 files changed
+275 -99

No files matched your search

+12 -17
View File
@@ -1,7 +1,7 @@
"""
Dashboard-Layout v1 (Nutzer-Lab): Validierung und Standard-Layout.
Single Source für erlaubte Widget-IDs (sync mit Frontend widgetRegistry).
Erlaubte Widget-IDs und Standard-Reihenfolge: widget_catalog.WIDGET_CATALOG
"""
from __future__ import annotations
@@ -9,27 +9,22 @@ from typing import Any, Literal
from pydantic import BaseModel, Field, model_validator
ALLOWED_WIDGET_IDS: frozenset[str] = frozenset(
{
"welcome",
"quick_capture",
"kpi_board",
"body_overview",
"activity_overview",
}
)
from widget_catalog import ALLOWED_WIDGET_IDS, WIDGET_CATALOG
# Abwärtskompatibel (Tests importieren weiterhin aus diesem Modul)
__all__ = [
"ALLOWED_WIDGET_IDS",
"DashboardLayoutPayload",
"DashboardWidgetEntry",
"coalesce_effective_layout",
"default_layout_dict",
]
def default_layout_dict() -> dict[str, Any]:
return {
"version": 1,
"widgets": [
{"id": "welcome", "enabled": True},
{"id": "quick_capture", "enabled": True},
{"id": "kpi_board", "enabled": True},
{"id": "body_overview", "enabled": True},
{"id": "activity_overview", "enabled": True},
],
"widgets": [{"id": e["id"], "enabled": True} for e in WIDGET_CATALOG],
}
+8
View File
@@ -12,10 +12,18 @@ from auth import require_auth
from dashboard_layout_schema import DashboardLayoutPayload, coalesce_effective_layout, default_layout_dict
from db import get_cursor, get_db
from routers.profiles import get_pid
from widget_catalog import catalog_response
router = APIRouter(prefix="/api/app", tags=["app-dashboard-lab"])
@router.get("/widgets/catalog")
def get_widgets_catalog(session: dict = Depends(require_auth)) -> dict[str, Any]:
"""Metadaten aller registrierbaren Dashboard-Widgets (IDs, Titel)."""
_ = session
return catalog_response()
@router.get("/dashboard-layout")
def get_dashboard_layout(
x_profile_id: Optional[str] = Header(default=None),
+25
View File
@@ -0,0 +1,25 @@
"""Widget-Katalog: Konsistenz (IDs, Default-Layout, Katalog-Response)."""
from dashboard_layout_schema import default_layout_dict
from widget_catalog import ALLOWED_WIDGET_IDS, WIDGET_CATALOG, catalog_response
def test_catalog_ids_unique_and_match_allowed():
ids = [e["id"] for e in WIDGET_CATALOG]
assert len(ids) == len(set(ids))
assert frozenset(ids) == ALLOWED_WIDGET_IDS
def test_default_layout_follows_catalog_order():
d = default_layout_dict()
assert d["version"] == 1
got = [w["id"] for w in d["widgets"]]
assert got == [e["id"] for e in WIDGET_CATALOG]
assert all(w["enabled"] is True for w in d["widgets"])
def test_catalog_response_shape():
r = catalog_response()
assert r["catalog_version"] == 1
assert len(r["widgets"]) == len(WIDGET_CATALOG)
assert {w["id"] for w in r["widgets"]} == ALLOWED_WIDGET_IDS
+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.0.0", # Dashboard-Lab Layout API (/api/app)
"app_dashboard": "1.1.0", # Dashboard-Lab + GET /widgets/catalog (Widget-System Iteration 1)
}
CHANGELOG = [
+55
View File
@@ -0,0 +1,55 @@
"""
Öffentlicher Widget-Katalog (Dashboard-Lab / später Produkt-Dashboard).
Single Source für: erlaubte IDs, Standard-Reihenfolge, Anzeige-Metadaten für API/GUI.
Frontend-Komponenten registrieren dieselben IDs lokal (siehe widgetSystem/registerPilotLabWidgets).
"""
from __future__ import annotations
from typing import Any, TypedDict
class WidgetCatalogEntry(TypedDict):
id: str
title: str
description: str
# Reihenfolge in der Liste = Standard-Layout (alle default_enabled: True im Default-Layout)
WIDGET_CATALOG: list[WidgetCatalogEntry] = [
{
"id": "welcome",
"title": "Willkommen",
"description": "Begrüßung und Kurzkontext",
},
{
"id": "quick_capture",
"title": "Schnelleingabe",
"description": "Gewicht und Vitalwerte erfassen",
},
{
"id": "kpi_board",
"title": "KPI-Kacheln",
"description": "Referenzwerte, KF%, Kalorien",
},
{
"id": "body_overview",
"title": "Körper (Chart)",
"description": "Gewicht & Kennzahlen",
},
{
"id": "activity_overview",
"title": "Aktivität",
"description": "Training & Konsistenz",
},
]
ALLOWED_WIDGET_IDS: frozenset[str] = frozenset(e["id"] for e in WIDGET_CATALOG)
def catalog_response() -> dict[str, Any]:
"""Payload für GET /api/app/widgets/catalog."""
return {
"catalog_version": 1,
"widgets": list(WIDGET_CATALOG),
}