Merge branch 'user_notes_editing' into web_ui
This commit is contained in:
commit
e71f423c81
15
admin.py
15
admin.py
@ -130,9 +130,10 @@ def page_admin():
|
|||||||
# Tabelle aufbauen
|
# Tabelle aufbauen
|
||||||
@ui.refreshable
|
@ui.refreshable
|
||||||
def timetable():
|
def timetable():
|
||||||
|
current_user = user(time_user.value)
|
||||||
with ui.card() as calendar_card:
|
with ui.card() as calendar_card:
|
||||||
def update_month_and_year():
|
def update_month_and_year():
|
||||||
current_user = user(time_user.value)
|
#current_user = user(time_user.value)
|
||||||
# Archivstatus
|
# Archivstatus
|
||||||
days_with_errors = current_user.archiving_validity_check(int(select_year.value), int(select_month.value))
|
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:
|
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):
|
def edit_notes(day):
|
||||||
notes = current_user.get_day_notes(select_year.value, select_month.value, day)
|
notes = current_user.get_day_notes(select_year.value, select_month.value, day)
|
||||||
def del_note_entry(user):
|
def del_note_entry(user):
|
||||||
|
try:
|
||||||
del(notes[user])
|
del(notes[user])
|
||||||
username_labels[user].delete()
|
username_labels[user].delete()
|
||||||
note_labels[user].delete()
|
note_labels[user].delete()
|
||||||
del_buttons[user].delete()
|
del_buttons[user].delete()
|
||||||
|
except KeyError:
|
||||||
|
ui.notify("Kann nicht gelöscht werden. Eintrag wurde noch nicht gespeichert.")
|
||||||
|
|
||||||
def save_notes():
|
def save_notes():
|
||||||
if not note_labels["admin"].is_deleted:
|
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)
|
username_labels["user"] = ui.markdown(current_user.fullname)
|
||||||
note_labels["user"] = ui.markdown(text)
|
note_labels["user"] = ui.markdown(text)
|
||||||
del_buttons["user"] = ui.button(icon='remove', on_click=lambda user="user": del_note_entry(user))
|
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():
|
with ui.row():
|
||||||
ui.button("OK", on_click=save_notes)
|
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["photos_on_touchscreen"] = photo_switch.value
|
||||||
output_dict["picture_height"] = picture_height_input.value
|
output_dict["picture_height"] = picture_height_input.value
|
||||||
output_dict["button_height"] = button_height_input.value
|
output_dict["button_height"] = button_height_input.value
|
||||||
|
output_dict["user_notes"] = notes_switch.value
|
||||||
output_dict["holidays"] = data["holidays"]
|
output_dict["holidays"] = data["holidays"]
|
||||||
json_dict = json.dumps(output_dict, indent=4)
|
json_dict = json.dumps(output_dict, indent=4)
|
||||||
with open(os.path.join(scriptpath, usersettingsfilename), "w") as outputfile:
|
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"]
|
old_port = data["port"]
|
||||||
port.value = old_port
|
port.value = old_port
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
with ui.card():
|
with ui.card():
|
||||||
ui.markdown("**Einstellungen für das Touchscreenterminal:**")
|
ui.markdown("**Einstellungen für das Touchscreenterminal:**")
|
||||||
with ui.column():
|
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)
|
picture_height_input.on_value_change(button_height_input.validate)
|
||||||
ui.markdown('px')
|
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():
|
def holiday_section():
|
||||||
with ui.card():
|
with ui.card():
|
||||||
ui.markdown('**Feiertage:**')
|
ui.markdown('**Feiertage:**')
|
||||||
|
15
api.py
15
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)
|
day_notes = current_user.get_day_notes(year, month, day)
|
||||||
just_once = True
|
just_once = True
|
||||||
|
|
||||||
|
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(day_notes) > 0:
|
||||||
if len(timestamps_dict[day]) > 0 or day in list(map(int, list(user_absent))):
|
if len(timestamps_dict[day]) > 0 or day in list(map(int, list(user_absent))):
|
||||||
booking_text += "<hr>"
|
ui.separator()
|
||||||
for user_key, notes in day_notes.items():
|
for user_key, notes in day_notes.items():
|
||||||
if user_key == "admin":
|
if user_key == "admin":
|
||||||
booking_text += f"Administrator:<br>{notes}"
|
ui.markdown(f"Administrator:<br>{notes}")
|
||||||
else:
|
else:
|
||||||
booking_text += f"{current_user.fullname}:<br>{notes}"
|
with ui.element():
|
||||||
|
ui.markdown(f"{current_user.fullname}:<br>{notes}")
|
||||||
if len(day_notes) > 1 and just_once:
|
if len(day_notes) > 1 and just_once:
|
||||||
booking_text += "<hr>"
|
ui.separator()
|
||||||
just_once = False
|
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}')
|
|
||||||
|
|
||||||
# Ist-Zeiten berechnen
|
# Ist-Zeiten berechnen
|
||||||
timestamps_of_this_day = []
|
timestamps_of_this_day = []
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ standard_adminsettings = { "admin_user": "admin",
|
|||||||
"touchscreen": True,
|
"touchscreen": True,
|
||||||
"picure_height": 200,
|
"picure_height": 200,
|
||||||
"button_height": 300,
|
"button_height": 300,
|
||||||
|
"user_notes": True,
|
||||||
"holidays": { }
|
"holidays": { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
71
homepage.py
71
homepage.py
@ -65,7 +65,7 @@ def homepage():
|
|||||||
in_button = ui.button("Einstempeln", on_click=stamp_and_refresh).classes('bg-green')
|
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')
|
out_button = ui.button("Ausstempeln", on_click=stamp_and_refresh).classes('bg-red')
|
||||||
time_toggle = ui.toggle({"day": "Tagesarbeitszeit", "total": "Gesamtzeit"}, value="day",
|
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 = ui.timer(1.0, update_timer)
|
||||||
working_timer.active = False
|
working_timer.active = False
|
||||||
@ -108,41 +108,82 @@ def homepage():
|
|||||||
month_month_select.set_options(month_dict)
|
month_month_select.set_options(month_dict)
|
||||||
month_month_select.enable()
|
month_month_select.enable()
|
||||||
|
|
||||||
|
if load_adminsettings()["user_notes"]:
|
||||||
with ui.grid(columns='1fr auto 1fr').classes('w-full justify-center'):
|
with ui.grid(columns='1fr auto 1fr').classes('w-full justify-center'):
|
||||||
ui.space()
|
ui.space()
|
||||||
with ui.expansion("Tagesnotiz", icon='o_description'):
|
|
||||||
with ui.grid(columns=2):
|
|
||||||
status_binder = ValueBinder()
|
|
||||||
|
|
||||||
def button_enabler():
|
with ui.expansion("Tagesnotizen", icon='o_description'):
|
||||||
if daynote.value == "":
|
with ui.grid(columns=2):
|
||||||
status_binder.value = False
|
|
||||||
else:
|
last_selection = 0
|
||||||
status_binder.value = True
|
@ui.refreshable
|
||||||
daynote = ui.textarea(on_change=button_enabler).classes('col-span-2')
|
def day_note_ui():
|
||||||
|
|
||||||
|
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:
|
try:
|
||||||
|
day_notes[i] = notes_of_i["user"]
|
||||||
|
options[i] = f"{i}.{today.month}.{today.year}"
|
||||||
|
except KeyError:
|
||||||
|
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"]
|
daynote.value = current_user.get_day_notes(today.year, today.month, today.day)["user"]
|
||||||
|
else:
|
||||||
|
daynote.value = day_notes[day_selector.value]
|
||||||
except:
|
except:
|
||||||
daynote.value = ""
|
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():
|
def save_note():
|
||||||
note_dict = { }
|
note_dict = { }
|
||||||
note_dict["user"] = daynote.value
|
note_dict["user"] = daynote.value
|
||||||
current_user.write_notes(today.year, today.month, today.day, note_dict)
|
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)
|
save_button = ui.button("Speichern", on_click=save_note)
|
||||||
#save_button.disable()
|
|
||||||
def del_text():
|
def del_text():
|
||||||
daynote.value = ""
|
daynote.value = ""
|
||||||
delete_button = ui.button("Löschen", on_click=del_text).bind_enabled_from(status_binder, 'value')
|
delete_button = ui.button("Löschen", on_click=del_text)
|
||||||
#delete_button.disable()
|
|
||||||
status_binder.value = False
|
|
||||||
|
|
||||||
notes = current_user.get_day_notes(today.year, today.month, today.day)
|
notes = current_user.get_day_notes(today.year, today.month, today.day)
|
||||||
try:
|
try:
|
||||||
daynote.value = notes[current_user.username]
|
daynote.value = notes[current_user.username]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
day_note_ui()
|
||||||
|
|
||||||
ui.separator()
|
ui.separator()
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
"photos_on_touchscreen": true,
|
"photos_on_touchscreen": true,
|
||||||
"picture_height": "100",
|
"picture_height": "100",
|
||||||
"button_height": "120",
|
"button_height": "120",
|
||||||
|
"user_notes": true,
|
||||||
"holidays": {
|
"holidays": {
|
||||||
"2025-01-01": "Neujahr",
|
"2025-01-01": "Neujahr",
|
||||||
"2025-04-18": "Karfreitag",
|
"2025-04-18": "Karfreitag",
|
||||||
|
9
users.py
9
users.py
@ -298,13 +298,16 @@ class user:
|
|||||||
return { }
|
return { }
|
||||||
|
|
||||||
def write_notes(self, year, month, day, note_dict):
|
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:
|
with open(os.path.join(self.userfolder, f"{int(year)}-{int(month)}.json"), "r") as json_file:
|
||||||
json_data = json.load(json_file)
|
json_data = json.load(json_file)
|
||||||
|
print(json_data)
|
||||||
if len(note_dict) == 1:
|
if len(note_dict) == 1:
|
||||||
|
user_info = list(note_dict)[0]
|
||||||
json_data["notes"][str(day)] = { }
|
json_data["notes"][str(day)] = { }
|
||||||
json_data["notes"][str(day)]["user"] = note_dict["user"]
|
json_data["notes"][str(day)][user_info] = note_dict[user_info]
|
||||||
if json_data["notes"][str(day)]["user"] == "":
|
if json_data["notes"][str(day)][user_info] == "":
|
||||||
del json_data["notes"][str(day)]["user"]
|
del json_data["notes"][str(day)][user_info]
|
||||||
else:
|
else:
|
||||||
json_data["notes"][str(day)] = note_dict
|
json_data["notes"][str(day)] = note_dict
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user