219 lines
6.6 KiB
Python
219 lines
6.6 KiB
Python
#!/usr/bin/env python3
|
|
# Zeiterfassung
|
|
|
|
from lib.web_ui import *
|
|
from lib.admin import *
|
|
from lib.login import *
|
|
from lib.users import *
|
|
from lib.touchscreen import *
|
|
from lib.definitions import *
|
|
from lib.api import *
|
|
from lib.homepage import *
|
|
|
|
import json
|
|
import argparse
|
|
|
|
from lib.web_ui import hash_password
|
|
|
|
def commandline_header():
|
|
message_string = f"{app_title} {app_version}"
|
|
underline = ""
|
|
for i in range(len(message_string)):
|
|
underline += "-"
|
|
print(message_string)
|
|
print(underline)
|
|
|
|
def main():
|
|
|
|
# Einstellungen einlesen
|
|
data = load_adminsettings()
|
|
port = int(data["port"])
|
|
secret = data["secret"]
|
|
|
|
list_users()
|
|
|
|
homepage()
|
|
|
|
def startup_message():
|
|
|
|
commandline_header()
|
|
url_string = ""
|
|
for i in list(app.urls):
|
|
url_string += f"{i}, "
|
|
url_string = url_string[0:-2]
|
|
print("Oberfläche erreichbar unter: " + url_string)
|
|
|
|
app.on_startup(startup_message)
|
|
|
|
# Styling:
|
|
ui.button.default_classes('normal-case')
|
|
ui.button.default_props('rounded')
|
|
ui.tab.default_classes('normal-case')
|
|
ui.toggle.default_classes('normal-case')
|
|
ui.toggle.default_props('rounded')
|
|
ui.row.default_classes('items-baseline')
|
|
|
|
favicon = '''<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
<svg
|
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
xmlns:ns1="http://sozi.baierouge.fr"
|
|
xmlns:cc="http://web.resource.org/cc/"
|
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
id="svg1"
|
|
sodipodi:docname="timeedit.svg"
|
|
viewBox="0 0 60 60"
|
|
sodipodi:version="0.32"
|
|
_SVGFile__filename="oldscale/actions/todo.svg"
|
|
version="1.0"
|
|
y="0"
|
|
x="0"
|
|
inkscape:version="0.40"
|
|
sodipodi:docbase="/home/danny/work/flat/SVG/mono/EXTRA/kexi"
|
|
>
|
|
<sodipodi:namedview
|
|
id="base"
|
|
bordercolor="#666666"
|
|
inkscape:pageshadow="2"
|
|
inkscape:window-y="0"
|
|
pagecolor="#ffffff"
|
|
inkscape:window-height="698"
|
|
inkscape:zoom="5.5342875"
|
|
inkscape:window-x="0"
|
|
borderopacity="1.0"
|
|
inkscape:current-layer="svg1"
|
|
inkscape:cx="36.490405"
|
|
inkscape:cy="19.560172"
|
|
inkscape:window-width="1024"
|
|
inkscape:pageopacity="0.0"
|
|
/>
|
|
<g
|
|
id="g1113"
|
|
transform="matrix(1.8141 0 0 1.8141 -24.352 -32.241)"
|
|
>
|
|
<path
|
|
id="path1894"
|
|
style="stroke-linejoin:round;stroke:#ffffff;stroke-linecap:round;stroke-width:5.5124;fill:none"
|
|
d="m43.399 34.31c0 7.418-6.02 13.438-13.438 13.438s-13.438-6.02-13.438-13.438 6.02-13.438 13.438-13.438 13.438 6.02 13.438 13.438z"
|
|
/>
|
|
<path
|
|
id="path741"
|
|
style="stroke-linejoin:round;fill-rule:evenodd;stroke:#000000;stroke-linecap:round;stroke-width:2.7562;fill:#ffffff"
|
|
d="m43.399 34.31c0 7.418-6.02 13.438-13.438 13.438s-13.438-6.02-13.438-13.438 6.02-13.438 13.438-13.438 13.438 6.02 13.438 13.438z"
|
|
/>
|
|
<path
|
|
id="path743"
|
|
sodipodi:nodetypes="cc"
|
|
style="stroke-linejoin:round;stroke:#000000;stroke-linecap:round;stroke-width:2.7562;fill:none"
|
|
d="m29.961 34.169v-8.723"
|
|
/>
|
|
<path
|
|
id="path744"
|
|
style="stroke-linejoin:round;stroke:#000000;stroke-linecap:round;stroke-width:2.7562;fill:none"
|
|
d="m30.185 34.066l5.869 3.388"
|
|
/>
|
|
<path
|
|
id="path742"
|
|
style="stroke-linejoin:round;fill-rule:evenodd;stroke:#000000;stroke-linecap:round;stroke-width:1.7226;fill:#000000"
|
|
d="m31.178 34.31c0 0.672-0.545 1.217-1.217 1.217s-1.217-0.545-1.217-1.217 0.545-1.218 1.217-1.218 1.217 0.546 1.217 1.218z"
|
|
/>
|
|
</g
|
|
>
|
|
<metadata
|
|
>
|
|
<rdf:RDF
|
|
>
|
|
<cc:Work
|
|
>
|
|
<dc:format
|
|
>image/svg+xml</dc:format
|
|
>
|
|
<dc:type
|
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage"
|
|
/>
|
|
<cc:license
|
|
rdf:resource="http://creativecommons.org/licenses/publicdomain/"
|
|
/>
|
|
<dc:publisher
|
|
>
|
|
<cc:Agent
|
|
rdf:about="http://openclipart.org/"
|
|
>
|
|
<dc:title
|
|
>Openclipart</dc:title
|
|
>
|
|
</cc:Agent
|
|
>
|
|
</dc:publisher
|
|
>
|
|
</cc:Work
|
|
>
|
|
<cc:License
|
|
rdf:about="http://creativecommons.org/licenses/publicdomain/"
|
|
>
|
|
<cc:permits
|
|
rdf:resource="http://creativecommons.org/ns#Reproduction"
|
|
/>
|
|
<cc:permits
|
|
rdf:resource="http://creativecommons.org/ns#Distribution"
|
|
/>
|
|
<cc:permits
|
|
rdf:resource="http://creativecommons.org/ns#DerivativeWorks"
|
|
/>
|
|
</cc:License
|
|
>
|
|
</rdf:RDF
|
|
>
|
|
</metadata
|
|
>
|
|
</svg
|
|
>
|
|
'''
|
|
|
|
ui.run(favicon=favicon, port=port, storage_secret=secret, language='de-DE', show_welcome_message=False)
|
|
|
|
if __name__ in ("__main__", "__mp_main__"):
|
|
parser = argparse.ArgumentParser(description=f'{app_title} {app_version}')
|
|
parser.add_argument('--admin-access', help='Zugangsdaten für Administrator einstellen', action="store_true")
|
|
args = parser.parse_args()
|
|
|
|
if is_docker():
|
|
scriptpath = "/app"
|
|
backupfolder = "/backup"
|
|
|
|
if args.admin_access:
|
|
commandline_header()
|
|
print("Lade Administrationseinstellungen")
|
|
admin_settings = load_adminsettings()
|
|
print("Geben Sie den neuen Benutzernamen für den Administrationsbenutzer an:")
|
|
admin_user = input()
|
|
if admin_user == "":
|
|
print("Ungültiger Benutzername. Breche ab.")
|
|
quit()
|
|
print("Geben Sie das neue Passwort für den Administrationsbenutzer ein:")
|
|
admin_password = input()
|
|
if admin_password == "":
|
|
print("Ungültiges Passwort. Breche ab.")
|
|
quit()
|
|
print("Sie haben folgende Informationen eingegeben.")
|
|
print(f"Benutzername: {admin_user}")
|
|
print(f"Passwort: {admin_password}")
|
|
print("Sollen diese Einstellungen übernommen werden? j=Ja")
|
|
question = input()
|
|
if question == "j":
|
|
admin_settings["admin_user"] = admin_user
|
|
admin_settings["admin_password"] = hash_password(admin_password)
|
|
json_dict = json.dumps(admin_settings, indent=4)
|
|
with open(os.path.join(scriptpath, usersettingsfilename), "w") as outputfile:
|
|
outputfile.write(json_dict)
|
|
print("Daten geschrieben")
|
|
quit()
|
|
else:
|
|
print("Breche ab.")
|
|
quit()
|
|
|
|
main()
|