Touchscreen einstellbar
This commit is contained in:
parent
4def6c50fa
commit
78c8aab781
18
admin.py
18
admin.py
@ -611,8 +611,11 @@ Dies kann nicht rückgängig gemacht werden!''')
|
||||
output_dict["admin_password"] = data["admin_password"]
|
||||
output_dict["port"] = port.value
|
||||
output_dict["secret"] = secret
|
||||
output_dict["touchscreen"] = touchscreen_switch.value
|
||||
output_dict["times_on_touchscreen"] = timestamp_switch.value
|
||||
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["holidays"] = data["holidays"]
|
||||
json_dict = json.dumps(output_dict, indent=4)
|
||||
with open(os.path.join(scriptpath, usersettingsfilename), "w") as outputfile:
|
||||
@ -652,12 +655,14 @@ Dies kann nicht rückgängig gemacht werden!''')
|
||||
|
||||
|
||||
with ui.card():
|
||||
ui.markdown("**Einstellungen für das Stempelterminal:**")
|
||||
ui.markdown("**Einstellungen für das Touchscreenterminal:**")
|
||||
with ui.column():
|
||||
timestamp_switch = ui.switch("Stempelzeiten anzeigen")
|
||||
photo_switch = ui.switch("Fotos anzeigen")
|
||||
touchscreen_switch = ui.switch("Touchscreenterminal aktivieren")
|
||||
touchscreen_switch.value = data["touchscreen"]
|
||||
timestamp_switch = ui.switch("Stempelzeiten anzeigen").bind_visibility_from(touchscreen_switch, 'value')
|
||||
photo_switch = ui.switch("Fotos anzeigen").bind_visibility_from(touchscreen_switch, 'value')
|
||||
timestamp_switch.value = bool(data["times_on_touchscreen"])
|
||||
with ui.row():
|
||||
with ui.row().bind_visibility_from(touchscreen_switch, 'value'):
|
||||
photo_switch.value = bool(data["photos_on_touchscreen"])
|
||||
with ui.row().bind_visibility_from(photo_switch, 'value'):
|
||||
ui.markdown("Maximale Bilderöhe")
|
||||
@ -665,8 +670,8 @@ Dies kann nicht rückgängig gemacht werden!''')
|
||||
"Größe muss größer 0 sein": lambda value: int(value)>0}).props('size=5')
|
||||
picture_height_input.value = data["picture_height"]
|
||||
ui.markdown('px')
|
||||
with ui.row():
|
||||
ui.markdown("Maximale Buttonhöhe")
|
||||
with ui.row().bind_visibility_from(touchscreen_switch, 'value'):
|
||||
ui.markdown("Minimale Buttonhöhe")
|
||||
def compare_button_height(height):
|
||||
if not photo_switch.value:
|
||||
return True
|
||||
@ -680,6 +685,7 @@ Dies kann nicht rückgängig gemacht werden!''')
|
||||
"Buttons dürfen nicht kleiner als die Fotos sein": lambda value: compare_button_height(value)}).props('size=5')
|
||||
button_height_input.value = data["button_height"]
|
||||
photo_switch.on_value_change(button_height_input.validate)
|
||||
picture_height_input.on_value_change(button_height_input.validate)
|
||||
ui.markdown('px')
|
||||
|
||||
def holiday_section():
|
||||
|
@ -28,6 +28,7 @@ standard_adminsettings = { "admin_user": "admin",
|
||||
"secret": "ftgzuhjikg,mt5jn46uzer8sfi9okrmtzjhndfierko5zltjhdgise",
|
||||
"times_on_touchscreen": True,
|
||||
"photos_on_touchscreen": True,
|
||||
"touchscreen": True,
|
||||
"picure_height": 200,
|
||||
"button_height": 300,
|
||||
"holidays": { }
|
||||
|
@ -3,10 +3,11 @@
|
||||
"admin_password": "8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918",
|
||||
"port": "8090",
|
||||
"secret": "ftgzuhjikg,mt5jn46uzer8sfi9okrmtzjhndfierko5zltjhdgise",
|
||||
"touchscreen": true,
|
||||
"times_on_touchscreen": true,
|
||||
"photos_on_touchscreen": true,
|
||||
"picture_height": 200,
|
||||
"button_height": 300,
|
||||
"picture_height": "100",
|
||||
"button_height": "120",
|
||||
"holidays": {
|
||||
"2025-01-01": "Neujahr",
|
||||
"2025-04-18": "Karfreitag",
|
||||
|
123
touchscreen.py
123
touchscreen.py
@ -14,67 +14,72 @@ import locale
|
||||
@ui.page('/touchscreen')
|
||||
def page_touchscreen():
|
||||
|
||||
def button_click(name):
|
||||
#nonlocal buttons
|
||||
current_user = user(name)
|
||||
current_user.timestamp()
|
||||
#if current_user.stamp_status() == status_in:
|
||||
# buttons[name].props('color=green')
|
||||
# ui.notify(status_in)
|
||||
#else:
|
||||
# buttons[name].props('color=red')
|
||||
# ui.notify(status_out)
|
||||
user_buttons.refresh()
|
||||
if load_adminsettings()["touchscreen"]:
|
||||
|
||||
pageheader("Stempeluhr")
|
||||
ui.page_title("Stempeluhr")
|
||||
def button_click(name):
|
||||
#nonlocal buttons
|
||||
current_user = user(name)
|
||||
current_user.timestamp()
|
||||
#if current_user.stamp_status() == status_in:
|
||||
# buttons[name].props('color=green')
|
||||
# ui.notify(status_in)
|
||||
#else:
|
||||
# buttons[name].props('color=red')
|
||||
# ui.notify(status_out)
|
||||
user_buttons.refresh()
|
||||
|
||||
admin_settings = load_adminsettings()
|
||||
userlist = list_users()
|
||||
number_of_users = len(userlist)
|
||||
buttons = { }
|
||||
pageheader("Stempeluhr")
|
||||
ui.page_title("Stempeluhr")
|
||||
|
||||
@ui.refreshable
|
||||
def user_buttons():
|
||||
if number_of_users > 5:
|
||||
number_of_columns = 5
|
||||
else:
|
||||
number_of_columns = number_of_users
|
||||
admin_settings = load_adminsettings()
|
||||
userlist = list_users()
|
||||
number_of_users = len(userlist)
|
||||
buttons = { }
|
||||
|
||||
with ui.grid(columns=number_of_columns).classes('w-full center'):
|
||||
for name in userlist:
|
||||
current_user = user(name)
|
||||
current_button = ui.button(on_click=lambda name=name: button_click(name)).classes('w-md h-full min-h-[250px]')
|
||||
with current_button:
|
||||
if admin_settings["photos_on_touchscreen"]:
|
||||
try:
|
||||
with open(current_user.photofile, 'r') as file:
|
||||
@ui.refreshable
|
||||
def user_buttons():
|
||||
if number_of_users > 5:
|
||||
number_of_columns = 5
|
||||
else:
|
||||
number_of_columns = number_of_users
|
||||
|
||||
with ui.grid(columns=number_of_columns).classes('w-full center'):
|
||||
for name in userlist:
|
||||
current_user = user(name)
|
||||
current_button = ui.button(on_click=lambda name=name: button_click(name)).classes(f'w-md h-full min-h-[{admin_settings["button_height"]}px]')
|
||||
with current_button:
|
||||
if admin_settings["photos_on_touchscreen"]:
|
||||
try:
|
||||
with open(current_user.photofile, 'r') as file:
|
||||
pass
|
||||
file.close()
|
||||
ui.image(current_user.photofile).classes(f'max-h-[{admin_settings["picture_height"]}px]').props('fit=scale-down')
|
||||
except:
|
||||
pass
|
||||
file.close()
|
||||
ui.image(current_user.photofile).classes('max-h-[200px]').props('fit=scale-down')
|
||||
except:
|
||||
pass
|
||||
column_classes = "w-full items-center"
|
||||
if admin_settings["times_on_touchscreen"] or admin_settings["photos_on_touchscreen"]:
|
||||
column_classes += " self-end"
|
||||
with ui.column().classes(column_classes):
|
||||
if admin_settings["times_on_touchscreen"]:
|
||||
todays_timestamps = current_user.get_day_timestamps()
|
||||
# Wenn wir Einträge haben
|
||||
if len(todays_timestamps) > 0 and admin_settings["times_on_touchscreen"]:
|
||||
table_string = ""
|
||||
for i in range(0, len(todays_timestamps), 2):
|
||||
try:
|
||||
table_string += f"{datetime.datetime.fromtimestamp(todays_timestamps[i]).strftime('%H:%M')} - {datetime.datetime.fromtimestamp(todays_timestamps[i+1]).strftime('%H:%M')}"
|
||||
except IndexError:
|
||||
table_string += f"{datetime.datetime.fromtimestamp(todays_timestamps[i]).strftime('%H:%M')} -"
|
||||
if i < len(todays_timestamps) - 2:
|
||||
table_string += ", "
|
||||
ui.markdown(table_string)
|
||||
ui.label(current_user.fullname).classes('text-center')
|
||||
if current_user.stamp_status() == status_in:
|
||||
current_button.props('color=green')
|
||||
else:
|
||||
current_button.props('color=red')
|
||||
buttons[name] = current_button
|
||||
user_buttons()
|
||||
column_classes = "w-full items-center"
|
||||
if admin_settings["times_on_touchscreen"] or admin_settings["photos_on_touchscreen"]:
|
||||
column_classes += " self-end"
|
||||
with ui.column().classes(column_classes):
|
||||
if admin_settings["times_on_touchscreen"]:
|
||||
todays_timestamps = current_user.get_day_timestamps()
|
||||
# Wenn wir Einträge haben
|
||||
if len(todays_timestamps) > 0 and admin_settings["times_on_touchscreen"]:
|
||||
table_string = ""
|
||||
for i in range(0, len(todays_timestamps), 2):
|
||||
try:
|
||||
table_string += f"{datetime.datetime.fromtimestamp(todays_timestamps[i]).strftime('%H:%M')} - {datetime.datetime.fromtimestamp(todays_timestamps[i+1]).strftime('%H:%M')}"
|
||||
except IndexError:
|
||||
table_string += f"{datetime.datetime.fromtimestamp(todays_timestamps[i]).strftime('%H:%M')} -"
|
||||
if i < len(todays_timestamps) - 2:
|
||||
table_string += ", "
|
||||
ui.markdown(table_string)
|
||||
ui.label(current_user.fullname).classes('text-center')
|
||||
if current_user.stamp_status() == status_in:
|
||||
current_button.props('color=green')
|
||||
else:
|
||||
current_button.props('color=red')
|
||||
buttons[name] = current_button
|
||||
user_buttons()
|
||||
|
||||
else:
|
||||
pageheader("Interface deaktiviert")
|
Loading…
x
Reference in New Issue
Block a user