86 lines
3.1 KiB
Python
86 lines
3.1 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)
|
|
|
|
einsaetze_table.rows = database.get_einsaetze()
|
|
einsaetze_table.update()
|
|
|
|
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'):
|
|
collums = [
|
|
{'name': 'date', 'label': 'Datum', 'field': 'date', 'sortable': True, 'align': 'left'},
|
|
{'name': 'name', 'label': 'Name', 'field': 'name', 'sortable': True, 'align': 'left'},
|
|
{'name': 'location', 'label': 'Ort', 'field': 'location', 'align': 'left'},
|
|
{'name': 'time', 'label': 'Dauer', 'field': 'time'},
|
|
]
|
|
einsaetze_table = ui.table(
|
|
columns = collums,
|
|
rows = database.get_einsaetze(),
|
|
row_key = "id"
|
|
).classes("w-full h-full")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|