Einsatz Liste wird angezeigt. Einträge können eingegeben werden.

This commit is contained in:
Daniel Nagel 2026-01-24 22:11:54 +01:00
parent 06b7287e20
commit b649652d25
5 changed files with 18 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View File

@ -40,7 +40,7 @@ def add_data_to_einsaetze(name, location, date, time):
connection = sqlite3.connect(DB_NAME)
cursor = connection.cursor()
sql_query = "INSERT INTO einsaetze (name, ort, datum, zeit) VALUES (?, ?, ?, ?)"
sql_query = "INSERT INTO einsaetze (name, location, date, time) VALUES (?, ?, ?, ?)"
data = (name, location, date, time)
cursor.execute(sql_query, data)
@ -62,14 +62,13 @@ def get_ats_names():
def get_einsaetze():
connection = sqlite3.connect(DB_NAME)
cursor = connection.cursor()
#Get Data an Row Names
connection.row_factory = sqlite3.Row
cursor = connection.cursor()
cursor.execute("SELECT * FROM einsaetze ORDER BY id DESC")
data = cursor.fetchall()
connection.commit()
connection.close()
return [dict(row) for row in data]

View File

@ -42,6 +42,10 @@ def build_ui():
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():
@ -59,7 +63,17 @@ def build_ui():
with ui.card().classes('flex-1 h-[85vh] p-0'):
ui.label("PLACEHOLDER ##### Datenbankeinträge aus Alten Einsätzen.")
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")