feat: dashboard via NiceGUI, refs NOISSUE

This commit is contained in:
2026-04-04 23:15:55 +02:00
parent 9615c50ccb
commit f0ec9169c4
8 changed files with 324 additions and 1118 deletions

View File

@@ -0,0 +1,32 @@
"""Frontend module for NiceGUI with FastAPI integration.
This module provides the NiceGUI frontend that can be initialized with a FastAPI app.
The dashboard shown is from dashboard_ui.py with real-time database data.
"""
from fastapi import FastAPI
from nicegui import app, ui
from dashboard_ui import create_dashboard
def init(fastapi_app: FastAPI, storage_secret: str = 'Secr2t!') -> None:
"""Initialize the NiceGUI frontend with the FastAPI app.
Args:
fastapi_app: The FastAPI application instance.
storage_secret: Optional secret for persistent user storage.
"""
@ui.page('/show')
def show():
create_dashboard()
# NOTE dark mode will be persistent for each user across tabs and server restarts
ui.dark_mode().bind_value(app.storage.user, 'dark_mode')
ui.checkbox('dark mode').bind_value(app.storage.user, 'dark_mode')
ui.run_with(
fastapi_app,
storage_secret=storage_secret, # NOTE setting a secret is optional but allows for persistent storage per user
)