72 lines
2.5 KiB
Python
72 lines
2.5 KiB
Python
from nicegui import ui
|
|
from datetime import datetime
|
|
import database
|
|
|
|
|
|
def build_ui():
|
|
ui.colors(primary='#ce2029') #Firetruck Red
|
|
with ui.card().classes("w-full h-25"):
|
|
dark = ui.dark_mode(True)
|
|
ui.switch('Dark mode').bind_value(dark)
|
|
ui.image('gui/logo.png').classes('absolute top-4 right-4 w-55')
|
|
with ui.row().classes("w-full"):
|
|
with ui.card():
|
|
# ATS Träger Dropdown Menü
|
|
ui.label("ATS Träger eintragen")
|
|
traeger = database.get_ats_names()
|
|
input_name = ui.select(label="ATS Träger Name", options=traeger, with_input=True).classes('w-full')
|
|
|
|
# Einsatzname
|
|
input_location = ui.input(label='Einsatzort', placeholder='Adresse, oder Beschreibung').classes("w-full")
|
|
|
|
with ui.row().classes('gap-10'):
|
|
|
|
# --- 3. Der DATUMS-PICKER (Pop-Up) ---
|
|
today = datetime.now().strftime("%Y-%m-%d")
|
|
|
|
with ui.input('Datum', value=today).classes('flex-1') as date_input:
|
|
# Das Icon im Eingabefeld (zum Klicken)
|
|
with date_input.add_slot('append'):
|
|
ui.icon('event').classes('cursor-pointer') \
|
|
.on('click', lambda: menu.open()) # Öffnet das Menü
|
|
# Das Pop-Up Menü mit dem Kalender
|
|
with ui.menu() as menu:
|
|
input_date = ui.date().bind_value(date_input)
|
|
|
|
input_time = ui.number(label="Dauer (Min)", value=0).classes('flex-1')
|
|
|
|
def InputDataToTable():
|
|
name = input_name.value
|
|
location = input_location.value
|
|
date = input_date.value
|
|
time = input_time.value
|
|
database.add_data_to_einsaetze(name, location, date, time)
|
|
print (name, location, date, time)
|
|
ui.notify("Eintrag in Datenbank erstellt.")
|
|
|
|
def ClearForm():
|
|
input_name.value = ""
|
|
input_location.value = ""
|
|
input_date.value = ""
|
|
input_time.value = 1
|
|
ui.notify("Gelöscht.")
|
|
|
|
ui.separator()
|
|
with ui.row().classes('w-full'):
|
|
ui.button(text="Leeren", on_click=ClearForm)
|
|
ui.space()
|
|
ui.button(text="Eintragen", on_click=InputDataToTable)
|
|
|
|
|
|
with ui.card().classes('flex-1 h-[85vh] p-0'):
|
|
ui.label("PLACEHOLDER ##### Datenbankeinträge aus Alten Einsätzen.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|