Dockercheck eingefügt
This commit is contained in:
parent
e54a210d69
commit
c3996c83e4
@ -4,6 +4,7 @@ RUN apt install python3 python3-pip python3.11-venv locales -y
|
|||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
RUN mkdir /.venv
|
RUN mkdir /.venv
|
||||||
RUN mkdir /backup
|
RUN mkdir /backup
|
||||||
|
RUN mkdir /settings
|
||||||
RUN python3 -m venv /.venv
|
RUN python3 -m venv /.venv
|
||||||
RUN /.venv/bin/pip install nicegui
|
RUN /.venv/bin/pip install nicegui
|
||||||
RUN /.venv/bin/pip install segno
|
RUN /.venv/bin/pip install segno
|
||||||
@ -19,5 +20,5 @@ COPY main.py /app/main.py
|
|||||||
COPY favicon.svg /app/favicon.svg
|
COPY favicon.svg /app/favicon.svg
|
||||||
COPY lib /app/lib/
|
COPY lib /app/lib/
|
||||||
EXPOSE 8090
|
EXPOSE 8090
|
||||||
ENTRYPOINT ["/.venv/bin/python", "/app/main.py", "--docker"]
|
ENTRYPOINT ["/.venv/bin/python", "/app/main.py"]
|
||||||
#ENTRYPOINT exec /app/.venv/bin/python /app/main.py --docker
|
#ENTRYPOINT exec /app/.venv/bin/python /app/main.py --docker
|
@ -5,6 +5,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 8090:8090
|
- 8090:8090
|
||||||
volumes:
|
volumes:
|
||||||
- /home/alexander/Dokumente/Python/Zeiterfassung:/app
|
#- /home/alexander/Dokumente/Python/Zeiterfassung:/app
|
||||||
- /home/alexander/Dokumente/Python/Zeiterfassung/users-docker:/users
|
- /home/alexander/Dokumente/Python/Zeiterfassung/users-docker:/users
|
||||||
- /home/alexander/Dokumente/Python/Zeiterfassung/backup:/backup
|
- /home/alexander/Dokumente/Python/Zeiterfassung/backup:/backup
|
||||||
|
- /home/alexander/Dokumente/Python/Zeiterfassung/settings:/settings
|
19
lib/admin.py
19
lib/admin.py
@ -44,8 +44,13 @@ def page_admin():
|
|||||||
updates_available = ValueBinder()
|
updates_available = ValueBinder()
|
||||||
updates_available.value = False
|
updates_available.value = False
|
||||||
|
|
||||||
is_docker = ValueBinder
|
enabled_because_not_docker = ValueBinder
|
||||||
print(docker)
|
if is_docker():
|
||||||
|
enabled_because_not_docker.value = False
|
||||||
|
scriptpath = "/app"
|
||||||
|
backupfolder = "/backup"
|
||||||
|
else:
|
||||||
|
enabled_because_not_docker.value = True
|
||||||
|
|
||||||
with ui.tabs() as tabs:
|
with ui.tabs() as tabs:
|
||||||
|
|
||||||
@ -762,7 +767,9 @@ Dies kann nicht rückgängig gemacht werden!''')
|
|||||||
|
|
||||||
ui.markdown("Port:")
|
ui.markdown("Port:")
|
||||||
port = ui.input(validation={"Nur ganzzahlige Portnummern erlaubt": lambda value: check_is_number(value),
|
port = ui.input(validation={"Nur ganzzahlige Portnummern erlaubt": lambda value: check_is_number(value),
|
||||||
"Portnummer zu klein": lambda value: len(value)>=2}).tooltip("Geben Sie hier die Portnummer ein, unter der die Zeiterfassung erreichbar ist.").props('size=5')
|
"Portnummer zu klein": lambda value: len(value)>=2}).tooltip("Geben Sie hier die Portnummer ein, unter der die Zeiterfassung erreichbar ist.").props('size=5').bind_enabled_from(enabled_because_not_docker, 'value')
|
||||||
|
if is_docker():
|
||||||
|
port.tooltip("Diese Einstellung ist beim Einsatz von Docker deaktiviert.")
|
||||||
old_port = data["port"]
|
old_port = data["port"]
|
||||||
port.value = old_port
|
port.value = old_port
|
||||||
|
|
||||||
@ -1398,7 +1405,7 @@ Dies kann nicht rückgängig gemacht werden!''')
|
|||||||
ui.label("Backupeinstellungen").classes('font-bold')
|
ui.label("Backupeinstellungen").classes('font-bold')
|
||||||
with ui.grid(columns='auto auto auto'):
|
with ui.grid(columns='auto auto auto'):
|
||||||
ui.markdown("Backupordner:")
|
ui.markdown("Backupordner:")
|
||||||
backupfolder_input = ui.input(value=backupfolder).props(f"size={len(backupfolder)}")
|
backupfolder_input = ui.input(value=backupfolder).props(f"size={len(backupfolder)}").bind_enabled_from(enabled_because_not_docker, 'value')
|
||||||
def save_new_folder_name():
|
def save_new_folder_name():
|
||||||
if os.path.exists(backupfolder_input.value):
|
if os.path.exists(backupfolder_input.value):
|
||||||
write_adminsetting("backup_folder", backupfolder_input.value)
|
write_adminsetting("backup_folder", backupfolder_input.value)
|
||||||
@ -1410,7 +1417,9 @@ Dies kann nicht rückgängig gemacht werden!''')
|
|||||||
ui.label("exisitiert nicht und kann daher nicht verwendet werden.")
|
ui.label("exisitiert nicht und kann daher nicht verwendet werden.")
|
||||||
ui.button("OK", on_click=dialog.close)
|
ui.button("OK", on_click=dialog.close)
|
||||||
dialog.open()
|
dialog.open()
|
||||||
ui.button("Speichern", on_click=save_new_folder_name).tooltip("Hiermit können Sie das Backupverzeichnis ändeern")
|
save_backup_folder_button = ui.button("Speichern", on_click=save_new_folder_name).tooltip("Hiermit können Sie das Backupverzeichnis ändeern").bind_enabled_from(enabled_because_not_docker, 'value')
|
||||||
|
if is_docker():
|
||||||
|
save_backup_folder_button.tooltip("Diese Einstellung ist beim Einsatz von Docker deaktiviert.")
|
||||||
|
|
||||||
ui.markdown("API-Schlüssel:")
|
ui.markdown("API-Schlüssel:")
|
||||||
backup_api_key_input = ui.input(value=api_key).tooltip("Hier den API-Schlüssel eintragen, der für Backuperzeugung mittels API-Aufruf verwendet werden soll.")
|
backup_api_key_input = ui.input(value=api_key).tooltip("Hier den API-Schlüssel eintragen, der für Backuperzeugung mittels API-Aufruf verwendet werden soll.")
|
||||||
|
@ -3,18 +3,21 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from lib.web_ui import is_docker
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
app_title = "Zeiterfassung"
|
app_title = "Zeiterfassung"
|
||||||
app_version = "0.0.0"
|
app_version = "0.0.0"
|
||||||
|
|
||||||
docker = False
|
|
||||||
|
|
||||||
# Standardpfade
|
# Standardpfade
|
||||||
|
|
||||||
scriptpath = str(Path(os.path.dirname(os.path.abspath(__file__))).parent.absolute())
|
if is_docker():
|
||||||
|
scriptpath = "/settings"
|
||||||
|
backupfolder = "/backup"
|
||||||
|
else:
|
||||||
|
scriptpath = str(Path(os.path.dirname(os.path.abspath(__file__))).parent.absolute())
|
||||||
|
backupfolder = str(os.path.join(scriptpath, "backup"))
|
||||||
userfolder = "users"
|
userfolder = "users"
|
||||||
backupfolder = str(os.path.join(scriptpath, "backup"))
|
|
||||||
|
|
||||||
# Dateinamen
|
# Dateinamen
|
||||||
|
|
||||||
|
@ -14,14 +14,15 @@ import shutil
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from lib.definitions import userfolder, scriptpath, usersettingsfilename, photofilename, status_in, status_out, \
|
from lib.definitions import userfolder, scriptpath, usersettingsfilename, photofilename, status_in, status_out, \
|
||||||
standard_adminsettings, standard_usersettings, va_file, docker
|
standard_adminsettings, standard_usersettings, va_file
|
||||||
|
|
||||||
|
from web_ui import is_docker
|
||||||
|
|
||||||
# Benutzerklasse
|
# Benutzerklasse
|
||||||
|
|
||||||
class user:
|
class user:
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
if not scriptpath == "/app":
|
if not is_docker():
|
||||||
self.userfolder = os.path.join(scriptpath, userfolder, name)
|
self.userfolder = os.path.join(scriptpath, userfolder, name)
|
||||||
else:
|
else:
|
||||||
self.userfolder = os.path.join("/users", name)
|
self.userfolder = os.path.join("/users", name)
|
||||||
@ -32,7 +33,6 @@ class user:
|
|||||||
#try:
|
#try:
|
||||||
with open(self.settingsfile) as json_file:
|
with open(self.settingsfile) as json_file:
|
||||||
data = json.load(json_file)
|
data = json.load(json_file)
|
||||||
print(data)
|
|
||||||
#except:
|
#except:
|
||||||
# print("Fehler beim Erstellen des Datenarrays.")
|
# print("Fehler beim Erstellen des Datenarrays.")
|
||||||
# #TODO Hier muss noch Fehlerbehandlungcode hin
|
# #TODO Hier muss noch Fehlerbehandlungcode hin
|
||||||
@ -304,10 +304,8 @@ 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]
|
user_info = list(note_dict)[0]
|
||||||
json_data["notes"][str(day)] = { }
|
json_data["notes"][str(day)] = { }
|
||||||
@ -537,7 +535,6 @@ def new_user(username: str):
|
|||||||
def load_adminsettings():
|
def load_adminsettings():
|
||||||
# Settingsdatei einlesen
|
# Settingsdatei einlesen
|
||||||
settings_filename = os.path.join(scriptpath, usersettingsfilename)
|
settings_filename = os.path.join(scriptpath, usersettingsfilename)
|
||||||
print(settings_filename)
|
|
||||||
if not os.path.exists(settings_filename):
|
if not os.path.exists(settings_filename):
|
||||||
print("Keine Einstellungsdatei gefunden. Lege Standarddatei an.")
|
print("Keine Einstellungsdatei gefunden. Lege Standarddatei an.")
|
||||||
with open(settings_filename, 'w') as json_file:
|
with open(settings_filename, 'w') as json_file:
|
||||||
|
@ -118,4 +118,8 @@ def login_is_valid(user = -1):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_docker():
|
||||||
|
cgroup = Path('/proc/self/cgroup')
|
||||||
|
return Path('/.dockerenv').is_file() or (cgroup.is_file() and 'docker' in cgroup.read_text())
|
@ -59,6 +59,11 @@ if __name__ in ("__main__", "__mp_main__"):
|
|||||||
parser = argparse.ArgumentParser(description=f'{app_title} {app_version}')
|
parser = argparse.ArgumentParser(description=f'{app_title} {app_version}')
|
||||||
parser.add_argument('--admin-access', help='Zugangsdaten für Administrator einstellen', action="store_true")
|
parser.add_argument('--admin-access', help='Zugangsdaten für Administrator einstellen', action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if is_docker():
|
||||||
|
scriptpath = "/app"
|
||||||
|
backupfolder = "/backup"
|
||||||
|
|
||||||
if args.admin_access:
|
if args.admin_access:
|
||||||
Commandline_Header()
|
Commandline_Header()
|
||||||
print("Lade Administrationseinstellungen")
|
print("Lade Administrationseinstellungen")
|
Loading…
x
Reference in New Issue
Block a user