diff --git a/admin.py b/admin.py
index 86b5f02..29766c5 100644
--- a/admin.py
+++ b/admin.py
@@ -130,9 +130,10 @@ def page_admin():
# Tabelle aufbauen
@ui.refreshable
def timetable():
+ current_user = user(time_user.value)
with ui.card() as calendar_card:
def update_month_and_year():
- current_user = user(time_user.value)
+ #current_user = user(time_user.value)
# Archivstatus
days_with_errors = current_user.archiving_validity_check(int(select_year.value), int(select_month.value))
with ui.grid(columns='auto auto auto 1fr 1fr 1fr 1fr') as table_grid:
@@ -509,10 +510,13 @@ Dies kann nicht rückgängig gemacht werden!''')
def edit_notes(day):
notes = current_user.get_day_notes(select_year.value, select_month.value, day)
def del_note_entry(user):
- del(notes[user])
- username_labels[user].delete()
- note_labels[user].delete()
- del_buttons[user].delete()
+ try:
+ del(notes[user])
+ username_labels[user].delete()
+ note_labels[user].delete()
+ del_buttons[user].delete()
+ except KeyError:
+ ui.notify("Kann nicht gelöscht werden. Eintrag wurde noch nicht gespeichert.")
def save_notes():
if not note_labels["admin"].is_deleted:
@@ -541,6 +545,8 @@ Dies kann nicht rückgängig gemacht werden!''')
username_labels["user"] = ui.markdown(current_user.fullname)
note_labels["user"] = ui.markdown(text)
del_buttons["user"] = ui.button(icon='remove', on_click=lambda user="user": del_note_entry(user))
+ elif name == "admin":
+ note_labels["admin"].value = text
with ui.row():
ui.button("OK", on_click=save_notes)
@@ -616,6 +622,7 @@ Dies kann nicht rückgängig gemacht werden!''')
output_dict["photos_on_touchscreen"] = photo_switch.value
output_dict["picture_height"] = picture_height_input.value
output_dict["button_height"] = button_height_input.value
+ output_dict["user_notes"] = notes_switch.value
output_dict["holidays"] = data["holidays"]
json_dict = json.dumps(output_dict, indent=4)
with open(os.path.join(scriptpath, usersettingsfilename), "w") as outputfile:
@@ -652,8 +659,6 @@ Dies kann nicht rückgängig gemacht werden!''')
old_port = data["port"]
port.value = old_port
-
-
with ui.card():
ui.markdown("**Einstellungen für das Touchscreenterminal:**")
with ui.column():
@@ -688,6 +693,10 @@ Dies kann nicht rückgängig gemacht werden!''')
picture_height_input.on_value_change(button_height_input.validate)
ui.markdown('px')
+ with ui.card():
+ ui.markdown("**Einstellungen für Benutzerfrontend**")
+ notes_switch = ui.switch("Notizfunktion aktiviert", value=data["user_notes"])
+
def holiday_section():
with ui.card():
ui.markdown('**Feiertage:**')
diff --git a/api.py b/api.py
index db2cafd..dbf13c5 100644
--- a/api.py
+++ b/api.py
@@ -109,20 +109,21 @@ def page_overview_month(username: str, year: int, month: int):
day_notes = current_user.get_day_notes(year, month, day)
just_once = True
- if len(day_notes) > 0:
- if len(timestamps_dict[day]) > 0 or day in list(map(int, list(user_absent))):
- booking_text += "
"
- for user_key, notes in day_notes.items():
- if user_key == "admin":
- booking_text += f"Administrator:
{notes}"
- else:
- booking_text += f"{current_user.fullname}:
{notes}"
- if len(day_notes) > 1 and just_once:
- booking_text += "
"
- just_once = False
-
- booking_text_element = ui.markdown(booking_text).classes(f'border px-{pad_x} py-{pad_y} bg-{booking_color} text-{booking_text_color}')
+ with ui.column().classes(f'border px-{pad_x} py-{pad_y} bg-{booking_color} text-{booking_text_color}'):
+ booking_text_element = ui.markdown(booking_text)
+ if len(day_notes) > 0:
+ if len(timestamps_dict[day]) > 0 or day in list(map(int, list(user_absent))):
+ ui.separator()
+ for user_key, notes in day_notes.items():
+ if user_key == "admin":
+ ui.markdown(f"Administrator:
{notes}")
+ else:
+ with ui.element():
+ ui.markdown(f"{current_user.fullname}:
{notes}")
+ if len(day_notes) > 1 and just_once:
+ ui.separator()
+ just_once = False
# Ist-Zeiten berechnen
timestamps_of_this_day = []
diff --git a/definitions.py b/definitions.py
index 4d8d025..44621bd 100644
--- a/definitions.py
+++ b/definitions.py
@@ -31,6 +31,7 @@ standard_adminsettings = { "admin_user": "admin",
"touchscreen": True,
"picure_height": 200,
"button_height": 300,
+ "user_notes": True,
"holidays": { }
}
diff --git a/homepage.py b/homepage.py
index 2636be5..659820b 100644
--- a/homepage.py
+++ b/homepage.py
@@ -65,7 +65,7 @@ def homepage():
in_button = ui.button("Einstempeln", on_click=stamp_and_refresh).classes('bg-green')
out_button = ui.button("Ausstempeln", on_click=stamp_and_refresh).classes('bg-red')
time_toggle = ui.toggle({"day": "Tagesarbeitszeit", "total": "Gesamtzeit"}, value="day",
- on_change=update_timer).classes('w-full justify-center col-span-2')
+ on_change=update_timer).classes('w-full justify-center col-span-2').tooltip("Hier lässt sich die Anzeige oben zwischen heute geleisteter Arbeitszeit und summierter Arbeitszeit umschalten.")
working_timer = ui.timer(1.0, update_timer)
working_timer.active = False
@@ -108,41 +108,82 @@ def homepage():
month_month_select.set_options(month_dict)
month_month_select.enable()
- with ui.grid(columns='1fr auto 1fr').classes('w-full justify-center'):
- ui.space()
- with ui.expansion("Tagesnotiz", icon='o_description'):
- with ui.grid(columns=2):
- status_binder = ValueBinder()
+ if load_adminsettings()["user_notes"]:
+ with ui.grid(columns='1fr auto 1fr').classes('w-full justify-center'):
+ ui.space()
- def button_enabler():
- if daynote.value == "":
- status_binder.value = False
- else:
- status_binder.value = True
- daynote = ui.textarea(on_change=button_enabler).classes('col-span-2')
- try:
- daynote.value = current_user.get_day_notes(today.year, today.month, today.day)["user"]
- except:
- daynote.value = ""
+ with ui.expansion("Tagesnotizen", icon='o_description'):
+ with ui.grid(columns=2):
- def save_note():
- note_dict = { }
- note_dict["user"] = daynote.value
- current_user.write_notes(today.year, today.month, today.day, note_dict)
+ last_selection = 0
+ @ui.refreshable
+ def day_note_ui():
- save_button = ui.button("Speichern", on_click=save_note)
- #save_button.disable()
- def del_text():
- daynote.value = ""
- delete_button = ui.button("Löschen", on_click=del_text).bind_enabled_from(status_binder, 'value')
- #delete_button.disable()
- status_binder.value = False
+ day_notes = { }
+ options = { }
+ options[0] = "Heute"
+ for i in range(1, monthrange(today.year, today.month)[1] + 1):
+ notes_of_i = current_user.get_day_notes(today.year, today.month, i)
+ if len(notes_of_i) > 0:
+ try:
+ day_notes[i] = notes_of_i["user"]
+ options[i] = f"{i}.{today.month}.{today.year}"
+ except KeyError:
+ pass
- notes = current_user.get_day_notes(today.year, today.month, today.day)
- try:
- daynote.value = notes[current_user.username]
- except:
- pass
+ select_value = last_selection
+ try:
+ day_notes[today.day]
+ del(options[0])
+ select_value = today.day
+ except KeyError:
+ select_value = 0
+ day_selector = ui.select(options=options, value=select_value).classes('col-span-2')
+ #except ValueError:
+ # day_selector = ui.select(options=options, value=0).classes('col-span-2')
+ daynote = ui.textarea().classes('col-span-2')
+
+ try:
+ if last_selection == 0:
+ daynote.value = current_user.get_day_notes(today.year, today.month, today.day)["user"]
+ else:
+ daynote.value = day_notes[day_selector.value]
+ except:
+ daynote.value = ""
+
+ def call_note():
+ if day_selector.value == 0:
+ daynote.value = current_user.get_day_notes(today.year, today.month, today.day)["user"]
+ else:
+ daynote.value = day_notes[day_selector.value]
+ day_selector.on_value_change(call_note)
+
+ def save_note():
+ note_dict = { }
+ note_dict["user"] = daynote.value
+ nonlocal last_selection
+ last_selection = day_selector.value
+ print(f"Last selection from save: {last_selection}")
+ if day_selector.value == 0:
+ day_to_write = today.day
+ else:
+ day_to_write = day_selector.value
+ current_user.write_notes(today.year, today.month, day_to_write, note_dict)
+ day_note_ui.refresh()
+
+ save_button = ui.button("Speichern", on_click=save_note)
+
+ def del_text():
+ daynote.value = ""
+ delete_button = ui.button("Löschen", on_click=del_text)
+
+
+ notes = current_user.get_day_notes(today.year, today.month, today.day)
+ try:
+ daynote.value = notes[current_user.username]
+ except:
+ pass
+ day_note_ui()
ui.separator()
diff --git a/settings.json b/settings.json
index b41ac70..2e00471 100644
--- a/settings.json
+++ b/settings.json
@@ -8,6 +8,7 @@
"photos_on_touchscreen": true,
"picture_height": "100",
"button_height": "120",
+ "user_notes": true,
"holidays": {
"2025-01-01": "Neujahr",
"2025-04-18": "Karfreitag",
diff --git a/users.py b/users.py
index 58a7955..dfc3fe6 100644
--- a/users.py
+++ b/users.py
@@ -298,13 +298,16 @@ class user:
return { }
def write_notes(self, year, month, day, note_dict):
+ print(os.path.join(self.userfolder, f"{int(year)}-{int(month)}.json"))
with open(os.path.join(self.userfolder, f"{int(year)}-{int(month)}.json"), "r") as json_file:
json_data = json.load(json_file)
+ print(json_data)
if len(note_dict) == 1:
+ user_info = list(note_dict)[0]
json_data["notes"][str(day)] = { }
- json_data["notes"][str(day)]["user"] = note_dict["user"]
- if json_data["notes"][str(day)]["user"] == "":
- del json_data["notes"][str(day)]["user"]
+ json_data["notes"][str(day)][user_info] = note_dict[user_info]
+ if json_data["notes"][str(day)][user_info] == "":
+ del json_data["notes"][str(day)][user_info]
else:
json_data["notes"][str(day)] = note_dict