48 lines
1.1 KiB
Python
Executable File
48 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
from nicegui import app, ui
|
|
|
|
from api import router as api_router
|
|
from table import router as table_router
|
|
|
|
from auth.login import router as login_router
|
|
from auth.logout import logout
|
|
from auth.mw import AuthMiddleware
|
|
from auth.secret import get_secret
|
|
|
|
|
|
app.include_router(login_router)
|
|
app.add_middleware(AuthMiddleware)
|
|
|
|
|
|
@ui.page("/")
|
|
def main():
|
|
with ui.column().classes("absolute-center items-center"):
|
|
username = app.storage.user.get("username", "unknown user")
|
|
ui.label(f"Hello {username}!").classes("text-2xl")
|
|
ui.button("log out", icon="logout", on_click=logout)
|
|
|
|
pgroups = app.storage.user.get("pgroups", set())
|
|
ui.select(
|
|
label="pgroup",
|
|
options=sorted(pgroups),
|
|
with_input=True,
|
|
on_change=lambda e: ui.navigate.to(f"/tables/{e.value}")
|
|
)
|
|
|
|
|
|
app.include_router(api_router)
|
|
app.include_router(table_router)
|
|
|
|
ui.run(
|
|
title="stand",
|
|
favicon="assets/favicon.png",
|
|
storage_secret=get_secret(),
|
|
fastapi_docs=True,
|
|
dark=True,
|
|
show=False
|
|
)
|
|
|
|
|
|
|