Halbes Admin Panel. Login.

This commit is contained in:
Daniel Nagel 2026-01-27 15:17:53 +00:00
parent 2c0ce2b016
commit 7a4fe740a5
3 changed files with 68 additions and 46 deletions

Binary file not shown.

View File

@ -24,59 +24,81 @@ def build_ui():
# 'overflow-hidden' verhindert, dass das ganze Fenster scrollt -> wir wollen nur die Tabelle scrollen. # 'overflow-hidden' verhindert, dass das ganze Fenster scrollt -> wir wollen nur die Tabelle scrollen.
with ui.row().classes("w-full flex-1 p-4 gap-4 no-wrap overflow-hidden"): with ui.row().classes("w-full flex-1 p-4 gap-4 no-wrap overflow-hidden"):
# --- Linke Karte: Eingabemaske --- with ui.column():
# 'overflow-y-auto': Falls das Formular zu lang für kleine Bildschirme wird, bekommt nur diese Karte einen Scrollbalken. # --- Linke Karte: Eingabemaske ---
with ui.card().classes('overflow-y-auto'): # 'overflow-y-auto': Falls das Formular zu lang für kleine Bildschirme wird, bekommt nur diese Karte einen Scrollbalken.
with ui.card().classes('overflow-y-auto'):
traeger = database.get_ats_names() traeger = database.get_ats_names()
input_name = ui.select(label="ATS Träger Name", options=traeger, with_input=True).classes('w-full') input_name = ui.select(label="ATS Träger Name", options=traeger, with_input=True).classes('w-full')
input_location = ui.input(label='Einsatzort', placeholder='Adresse, oder Beschreibung').classes("w-full") input_location = ui.input(label='Einsatzort', placeholder='Adresse, oder Beschreibung').classes("w-full")
with ui.row().classes('gap-10'): with ui.row().classes('gap-10'):
today = datetime.now().strftime("%Y-%m-%d") today = datetime.now().strftime("%Y-%m-%d")
with ui.input('Datum', value=today).classes('flex-1') as date_input: with ui.input('Datum', value=today).classes('flex-1') as date_input:
with date_input.add_slot('append'): with date_input.add_slot('append'):
ui.icon('event').classes('cursor-pointer') \ ui.icon('event').classes('cursor-pointer') \
.on('click', lambda: menu.open()) .on('click', lambda: menu.open())
with ui.menu() as menu: with ui.menu() as menu:
input_date = ui.date().bind_value(date_input) input_date = ui.date().bind_value(date_input)
input_time = ui.number(label="Dauer (Min)", value=0).classes('flex-1') input_time = ui.number(label="Dauer (Min)", value=0).classes('flex-1')
with ui.row().classes("gap-10 w-full items-center"): with ui.row().classes("gap-10 w-full items-center"):
input_type = ui.toggle(["Einsatz", "Übung"]).classes('flex-1 center') input_type = ui.toggle(["Einsatz", "Übung"]).classes('flex-1 center')
input_device = ui.select(["ATS Gerät 1", "ATS Gerät 2"], label="ATS Gerät auswählen").classes('flex-1') input_device = ui.select(["ATS Gerät 1", "ATS Gerät 2"], label="ATS Gerät auswählen").classes('flex-1')
def InputDataToTable(): def InputDataToTable():
name = input_name.value name = input_name.value
location = input_location.value location = input_location.value
date = input_date.value date = input_date.value
time = input_time.value time = input_time.value
etype = input_type.value etype = input_type.value
device = input_device.value device = input_device.value
# Hinweis: database Aufruf ist hier korrekt, sofern importiert # Hinweis: database Aufruf ist hier korrekt, sofern importiert
database.add_data_to_einsaetze(name, location, date, time, etype, device) database.add_data_to_einsaetze(name, location, date, time, etype, device)
einsaetze_table.rows = database.get_einsaetze() einsaetze_table.rows = database.get_einsaetze()
einsaetze_table.update() einsaetze_table.update()
ui.notify("Eintrag in Datenbank erstellt.") ui.notify("Eintrag in Datenbank erstellt.")
def ClearForm(): def ClearForm():
input_name.value = "" input_name.value = ""
input_location.value = "" input_location.value = ""
input_date.value = today input_date.value = today
input_time.value = 0 input_time.value = 0
input_type.value = "Einsatz" # Achtung: Value sollte zum Toggle passen (String, nicht 0) input_type.value = "Einsatz" # Achtung: Value sollte zum Toggle passen (String, nicht 0)
input_device.value = None # Select resetten input_device.value = None # Select resetten
ui.notify("Gelöscht.") ui.notify("Gelöscht.")
ui.notify(admin_login.value)
ui.separator() ui.separator()
ui.space() # Drückt die Buttons nach unten (innerhalb der Formular-Karte) ui.space() # Drückt die Buttons nach unten (innerhalb der Formular-Karte)
with ui.row().classes('w-full'): with ui.row().classes('w-full'):
ui.button(text="Leeren", on_click=ClearForm) ui.button(text="Leeren", on_click=ClearForm)
ui.space() ui.space()
ui.button(text="Eintragen", on_click=InputDataToTable) ui.button(text="Eintragen", on_click=InputDataToTable)
admin_container = ui.column().classes("w-full")
with ui.card().classes("w-full"):
admin_login = ui.input(placeholder="Admin Passwort", password=True).props("clearable")
admin_loginbutton = ui.button(text="Login")
def check_login():
print("geändert")
admin_container.clear()
print ("CHEEEECK!")
if admin_login.value == "1234":
with admin_container:
ui.separator()
admin_loginbutton.on_click(check_login)
# --- Rechte Karte: Tabelle --- # --- Rechte Karte: Tabelle ---
# 'flex-1': Diese Karte nimmt die restliche Breite der Reihe ein. # 'flex-1': Diese Karte nimmt die restliche Breite der Reihe ein.
@ -87,8 +109,8 @@ def build_ui():
{'name': 'name', 'label': 'Name', 'field': 'name', 'sortable': True, 'align': 'left'}, {'name': 'name', 'label': 'Name', 'field': 'name', 'sortable': True, 'align': 'left'},
{'name': 'location', 'label': 'Ort', 'field': 'location', 'align': 'left'}, {'name': 'location', 'label': 'Ort', 'field': 'location', 'align': 'left'},
{'name': 'time', 'label': 'Dauer', 'field': 'time'}, {'name': 'time', 'label': 'Dauer', 'field': 'time'},
{'name': 'etype', 'label': 'Art', 'field': 'etype'}, {'name': 'etype', 'label': 'Art', 'field': 'etype', "sortable": True},
{'name': 'device', 'label': 'Gerät', 'field': 'device'}, {'name': 'device', 'label': 'Gerät', 'field': 'device', "sortable": True},
] ]
# Die Tabelle selbst bekommt auch h-full, damit sie die Karte ausfüllt # Die Tabelle selbst bekommt auch h-full, damit sie die Karte ausfüllt
einsaetze_table = ui.table( einsaetze_table = ui.table(