feat: add version check with message in app window
This commit is contained in:
1 parent
d027bedcb8
commit
c12b15e021
2 files changed
+111
-1
No files matched your search
+62
-1
@@ -29,6 +29,7 @@ from src.models import AppConfig
|
||||
from src.parser import parse_input_file, group_by_employee, get_unique_antragsnummern, get_unique_employees
|
||||
from src.validator import validate_input_file, validate_template
|
||||
from src.writer import generate_activity_reports
|
||||
from version_check import UPDATE_DIR, get_latest_version
|
||||
|
||||
|
||||
def set_active_employee(employee_name: str):
|
||||
@@ -76,6 +77,60 @@ except Exception as e:
|
||||
st.error(f"Fehler beim Laden der Konfiguration: {e}")
|
||||
st.stop()
|
||||
|
||||
# --- Versionsinformation für die dezente Anzeige am Seitenende ---
|
||||
current_version_text = ""
|
||||
try:
|
||||
local_version, latest_version = get_latest_version()
|
||||
current_version_text = f"v{'.'.join(map(str, local_version))}"
|
||||
if latest_version:
|
||||
available_version, _ = latest_version
|
||||
version_text = ".".join(map(str, available_version))
|
||||
st.html(
|
||||
f'''<style>
|
||||
.update-notice {{
|
||||
position: fixed; top: 4rem; right: 1rem; z-index: 10000;
|
||||
width: 290px; padding: 8px 12px; color: #5f4700;
|
||||
background: #fff8e1; border: 1px solid #e0b84c; border-radius: 8px;
|
||||
box-shadow: 0 3px 12px rgba(0, 0, 0, .18); font-size: .85rem;
|
||||
}}
|
||||
#update-notice-dismiss {{ display:none; }}
|
||||
#update-notice-dismiss:checked + .update-notice {{ display:none; }}
|
||||
body:has(#update-notice-dismiss:checked) div.st-key-update_notice_open {{ display:none!important; }}
|
||||
.update-notice__actions {{ display:flex; justify-content:flex-end; gap:8px; margin-top:8px; }}
|
||||
.update-notice__actions--footer {{ min-height:26px; }}
|
||||
.update-notice__button {{
|
||||
display:inline-flex; align-items:center; justify-content:center;
|
||||
width:26px; height:26px; color:#5f4700; background:#fffdf3;
|
||||
border:1px solid #d9bd66; border-radius:5px; text-decoration:none;
|
||||
font-size:1rem; line-height:1;
|
||||
}}
|
||||
.update-notice__button:hover {{ background:#f6e7b2; }}
|
||||
div.st-key-update_notice_open {{
|
||||
position:fixed; top:8.5rem; right:3.75rem; z-index:10001; width:26px;
|
||||
}}
|
||||
div.st-key-update_notice_open div[data-testid="stButton"] {{ margin:0; }}
|
||||
div.st-key-update_notice_open div[data-testid="stButton"] button {{
|
||||
min-width:200px; min-height:26px; height:26px; padding:0; color:#5f4700;
|
||||
background:#fffdf3; border:1px solid #d9bd66; border-radius:5px;
|
||||
}}
|
||||
</style>
|
||||
<input id="update-notice-dismiss" type="checkbox">
|
||||
<aside class="update-notice" role="status">
|
||||
<div class="update-notice__actions">
|
||||
<label class="update-notice__button" for="update-notice-dismiss" title="Hinweis schließen">×</label>
|
||||
</div>
|
||||
<strong>Neue Version v{version_text} verfügbar</strong>
|
||||
<div class="update-notice__actions update-notice__actions--footer">
|
||||
</div>
|
||||
</aside>'''
|
||||
)
|
||||
with st.container(key="update_notice_open"):
|
||||
if st.button("Update Ordner öffnen 📁", key="open_update_directory", help="Update-Ordner öffnen"):
|
||||
if sys.platform == "win32":
|
||||
os.startfile(str(UPDATE_DIR))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# --- Session State initialisieren ---
|
||||
if "parsed_records" not in st.session_state:
|
||||
st.session_state.parsed_records = []
|
||||
@@ -94,7 +149,6 @@ if "cached_tpl_result" not in st.session_state:
|
||||
st.session_state.cached_tpl_result = None
|
||||
if "employee_months" not in st.session_state:
|
||||
st.session_state.employee_months = {}
|
||||
|
||||
# --- Layout: zwei Spalten ---
|
||||
col1, col2 = st.columns(2)
|
||||
|
||||
@@ -433,3 +487,10 @@ if "generated_files" in st.session_state and st.session_state.generated_files:
|
||||
help="Ordner im Finder öffnen",
|
||||
use_container_width=True,
|
||||
)
|
||||
|
||||
if current_version_text:
|
||||
st.markdown(
|
||||
f'<div style="text-align:right; color:#888; font-size:0.8em; margin-top:2em;">'
|
||||
f'Programmversion {current_version_text}</div>',
|
||||
unsafe_allow_html=True,
|
||||
)
|
||||
@@ -0,0 +1,49 @@
|
||||
"""Prüft auf neuere Programmversionen im zentralen SMB-Verzeichnis."""
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
UPDATE_DIR = Path(r"j:\Fachbereiche\BO\Produktionsschule\Maßnahmeunterlagen\20_Personal\05_Tätigkeitsnachweise ESF\Nachweise-automatisiert-generieren")
|
||||
VERSION_PATTERN = re.compile(r"Tätigkeitsnachweis-Generator v(\d+)\.(\d+)\.(\d+)(?:\.\d+)?\.(zip|exe)$", re.IGNORECASE)
|
||||
CHANGELOG_PATTERN = re.compile(r"^## \[(\d+)\.(\d+)(?:\.(\d+))?\]", re.MULTILINE)
|
||||
|
||||
|
||||
def get_latest_version():
|
||||
match = CHANGELOG_PATTERN.search(Path(__file__).with_name("CHANGELOG.md").read_text(encoding="utf-8"))
|
||||
current = tuple(int(part or 0) for part in match.groups()) if match else (0, 0, 0)
|
||||
try:
|
||||
available = UPDATE_DIR.exists()
|
||||
except OSError:
|
||||
available = False
|
||||
if not available:
|
||||
return current, None
|
||||
newer = []
|
||||
try:
|
||||
paths = UPDATE_DIR.iterdir()
|
||||
for path in paths:
|
||||
found = VERSION_PATTERN.fullmatch(path.name)
|
||||
if found:
|
||||
version = tuple(int(found.group(i)) for i in range(1, 4))
|
||||
if version > current:
|
||||
newer.append((version, path))
|
||||
except OSError:
|
||||
return current, None
|
||||
if newer:
|
||||
return current, max(newer)
|
||||
return current, None
|
||||
|
||||
|
||||
def main() -> int:
|
||||
current, latest = get_latest_version()
|
||||
print(f"[INFO] Lokale Version: v{'.'.join(map(str, current))}")
|
||||
if latest:
|
||||
version, path = latest
|
||||
print(f"[HINWEIS] Neuere Version verfügbar: v{'.'.join(map(str, version))}")
|
||||
print(f"[HINWEIS] Datei: {path}")
|
||||
else:
|
||||
print("[INFO] Keine neuere Version gefunden oder Update-Verzeichnis nicht erreichbar.")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in new issue
Block a user