- Added support for the "activity_overview" widget in the dashboard configuration, allowing for chart_days validation. - Refactored validation logic to streamline error handling for both "body_overview" and "activity_overview" widgets. - Updated the widget catalog description to reflect the new configuration options. - Enhanced the DashboardLabPage to manage chart_days input for both widgets, improving user experience. - Bumped app_dashboard version to 1.3.0 to reflect these enhancements.
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
"""
|
||
Ö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 (optional: config chart_days 7–90)",
|
||
},
|
||
{
|
||
"id": "activity_overview",
|
||
"title": "Aktivität",
|
||
"description": "Training & Konsistenz (optional: config chart_days 7–90)",
|
||
},
|
||
]
|
||
|
||
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),
|
||
}
|