Grundlegende Bearbeitungsfunktionen

Tag muss noch korrigiert werden
This commit is contained in:
Alexander Malzkuhn 2025-04-22 22:39:33 +02:00
parent ca610d4381
commit 15ad2cd495
3 changed files with 39 additions and 4 deletions

View File

@ -138,6 +138,10 @@ class user:
timestamps.sort() timestamps.sort()
return timestamps return timestamps
def write_edited_timestamps(self, timestamps, year, month):
with open(f"{self.userfolder}/{year}-{month}.txt", "w") as file:
file.write(''.join(timestamps))
# Benutzer auflisten # Benutzer auflisten
def list_users(): def list_users():
users = [d for d in os.listdir(userfolder) if os.path.isdir(os.path.join(userfolder, d))] users = [d for d in os.listdir(userfolder) if os.path.isdir(os.path.join(userfolder, d))]

View File

@ -1,10 +1,12 @@
1743965819 1743965819
1743965909 1743965909
1743966000
1743966022 1743966022
1743966045 1743966045
1743966047 1743966047
1743966049 1743966049
1743967346 1743544200
1744659900
1744889948 1744889948
1744889966 1744889966
1744989797 1744989797
@ -20,8 +22,6 @@
1744991291 1744991291
1744991473 1744991473
1744991477 1744991477
1744991770
1744991777
1745181046 1745181046
1745181050 1745181050
1745240760 1745240760

View File

@ -1,4 +1,5 @@
import datetime import datetime
from datetime import datetime
from nicegui import ui, app from nicegui import ui, app
@ -173,13 +174,43 @@ def page_admin():
actual_timestamp = datetime.datetime.fromtimestamp(int(i)) actual_timestamp = datetime.datetime.fromtimestamp(int(i))
timestamp_day = actual_timestamp.strftime('%-d') timestamp_day = actual_timestamp.strftime('%-d')
def edit_entry(t_stamp, day):
with ui.dialog() as edit_dialog, ui.card():
ui.markdown("###Eintrag bearbeiten")
timestamp = datetime.datetime.fromtimestamp(int(t_stamp))
input_time = ui.time().classes('w-full justify-center')
input_time.value = timestamp.strftime('%H:%M')
def save_entry(day):
position = timestamps.index(t_stamp)
new_time_stamp = datetime.datetime(int(select_year.value), int(select_month.value), day, int(input_time.value[:2]), int(input_time.value[-2:]))
print(new_time_stamp)
timestamps[position] = str(int(new_time_stamp.timestamp())) +"\n"
#print(timestamps)
current_user = user(time_user.value)
current_user.write_edited_timestamps(timestamps, select_year.value, select_month.value)
def del_entry():
pass
with ui.row():
ui.button("Speichern", on_click=lambda day=day: save_entry(day))
ui.button("Löschen", on_click=del_entry)
ui.button("Abbrechen", on_click=edit_dialog.close)
edit_dialog.open()
if int(timestamp_day) == int(day): if int(timestamp_day) == int(day):
counter += 1 counter += 1
current_button = ui.button(actual_timestamp.strftime('%H:%m')) print(actual_timestamp)
current_button = ui.button(actual_timestamp.strftime('%H:%M'), on_click=lambda t_stamp=i, day=counter: edit_entry(t_stamp, day))
if counter % 2 == 0: if counter % 2 == 0:
current_button.props('color=red') current_button.props('color=red')
else: else:
current_button.props('color=green') current_button.props('color=green')
ui.markdown("Soll") ui.markdown("Soll")
ui.markdown("Ist") ui.markdown("Ist")
ui.markdown("+/-") ui.markdown("+/-")