feat: Update widget catalog and enhance dashboard layout features
- Added new "Dashboard-Lab-Widgets" entry to the documentation for better guidance on widget configuration. - Updated the app_dashboard version to 1.8.0 to reflect the introduction of widget catalog features and layout entitlements. - Enhanced widget catalog entries to include optional feature requirements for better visibility and access control. - Improved the DashboardLabPage to manage widget visibility based on feature entitlements, ensuring a more tailored user experience.
This commit is contained in:
1 parent
bc91396885
commit
9bc0cf70da
8 files changed
+242
-32
No files matched your search
@@ -10,18 +10,23 @@ from psycopg2.extras import Json
|
||||
|
||||
from auth import require_auth
|
||||
from dashboard_layout_schema import DashboardLayoutPayload, coalesce_effective_layout, default_layout_dict
|
||||
from dashboard_widget_entitlements import apply_entitlements_to_layout_dict, widgets_catalog_payload
|
||||
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)."""
|
||||
def get_widgets_catalog(
|
||||
x_profile_id: Optional[str] = Header(default=None),
|
||||
session: dict = Depends(require_auth),
|
||||
) -> dict[str, Any]:
|
||||
"""Katalog inkl. allowed pro Widget (Feature / Subscription, effektiver Tier)."""
|
||||
_ = session
|
||||
return catalog_response()
|
||||
pid = get_pid(x_profile_id)
|
||||
with get_db() as conn:
|
||||
return widgets_catalog_payload(pid, conn)
|
||||
|
||||
|
||||
@router.get("/dashboard-layout")
|
||||
@@ -40,10 +45,13 @@ def get_dashboard_layout(
|
||||
row = cur.fetchone()
|
||||
raw = row["dashboard_layout"] if row else None
|
||||
custom, effective = coalesce_effective_layout(raw)
|
||||
with get_db() as conn:
|
||||
effective = apply_entitlements_to_layout_dict(effective, pid, conn)
|
||||
default_adj = apply_entitlements_to_layout_dict(default_layout_dict(), pid, conn)
|
||||
return {
|
||||
"custom": custom,
|
||||
"layout": effective,
|
||||
"default_layout": default_layout_dict(),
|
||||
"default_layout": default_adj,
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +67,12 @@ def put_dashboard_layout(
|
||||
payload = DashboardLayoutPayload.model_validate(body)
|
||||
except Exception as e:
|
||||
raise HTTPException(422, str(e)) from e
|
||||
with get_db() as conn:
|
||||
adjusted = apply_entitlements_to_layout_dict(payload.to_stored_dict(), pid, conn)
|
||||
try:
|
||||
payload = DashboardLayoutPayload.model_validate(adjusted)
|
||||
except Exception as e:
|
||||
raise HTTPException(422, str(e)) from e
|
||||
stored = payload.to_stored_dict()
|
||||
with get_db() as conn:
|
||||
cur = get_cursor(conn)
|
||||
|
||||
Reference in new issue
Block a user