diff --git a/routers/admin_geraete.py b/routers/admin_geraete.py index 381355c..8dfe7a8 100644 --- a/routers/admin_geraete.py +++ b/routers/admin_geraete.py @@ -114,3 +114,23 @@ def auftrag_deselect(device_id: str, merkmal_key: str, user: dict = Depends(requ ) return RedirectResponse(f"/admin/geraete/{device_id}", status_code=303) + + +@router.post("/{device_id}/debug-modus/aktivieren") +def debug_modus_aktivieren(device_id: str, user: dict = Depends(require_admin)): + if find_device(device_id) is None: + raise HTTPException(status_code=404, detail="Gerät wurde nicht gefunden.") + + anode_request("POST", f"/api/v1/devices/{device_id}/debug-mode") + + return RedirectResponse(f"/admin/geraete/{device_id}", status_code=303) + + +@router.post("/{device_id}/debug-modus/deaktivieren") +def debug_modus_deaktivieren(device_id: str, user: dict = Depends(require_admin)): + if find_device(device_id) is None: + raise HTTPException(status_code=404, detail="Gerät wurde nicht gefunden.") + + anode_request("DELETE", f"/api/v1/devices/{device_id}/debug-mode") + + return RedirectResponse(f"/admin/geraete/{device_id}", status_code=303) diff --git a/routers/geraete.py b/routers/geraete.py index 6ceb877..5d6e567 100644 --- a/routers/geraete.py +++ b/routers/geraete.py @@ -203,6 +203,26 @@ def auftrag_deselect(device_id: str, merkmal_key: str, user: dict = Depends(get_ return RedirectResponse(f"/geraete/{device_id}", status_code=303) +@router.post("/geraete/{device_id}/debug-modus/aktivieren") +def debug_modus_aktivieren(device_id: str, user: dict = Depends(get_current_user)): + if find_device_in_organization(device_id, user.organization_id) is None: + raise HTTPException(status_code=404, detail="Gerät wurde nicht gefunden.") + + anode_request("POST", f"/api/v1/devices/{device_id}/debug-mode") + + return RedirectResponse(f"/geraete/{device_id}", status_code=303) + + +@router.post("/geraete/{device_id}/debug-modus/deaktivieren") +def debug_modus_deaktivieren(device_id: str, user: dict = Depends(get_current_user)): + if find_device_in_organization(device_id, user.organization_id) is None: + raise HTTPException(status_code=404, detail="Gerät wurde nicht gefunden.") + + anode_request("DELETE", f"/api/v1/devices/{device_id}/debug-mode") + + return RedirectResponse(f"/geraete/{device_id}", status_code=303) + + @router.get("/geraete/{device_id}/hardware") def hardware_ansicht(request: Request, device_id: str, user: dict = Depends(get_current_user)): device = find_device_in_organization(device_id, user.organization_id) diff --git a/templates/admin/geraete_liste.html b/templates/admin/geraete_liste.html index b337dc7..eb068e9 100644 --- a/templates/admin/geraete_liste.html +++ b/templates/admin/geraete_liste.html @@ -17,7 +17,7 @@ {{ device.hostname or "—" }} {{ device.device_fingerprint }} {{ device.oe_name or "—" }} - {{ device.agent_last_checkin or "noch nie" }} + {{ device.agent_last_checkin or "noch nie" }}{% if device.debug_mode_until %}
🐞 Debug-Modus aktiv{% endif %} Auftragskatalog →
diff --git a/templates/auftragskatalog.html b/templates/auftragskatalog.html index 79e6932..e6dc943 100644 --- a/templates/auftragskatalog.html +++ b/templates/auftragskatalog.html @@ -4,6 +4,20 @@

← Geräteliste

Auftragskatalog: {{ device.hostname or device.device_fingerprint }}

+
+

Debug-Modus

+ {% if device.debug_mode_until %} +

Aktiv bis {{ device.debug_mode_until }} (kurzes Poll-Intervall, fällt danach automatisch auf den Standard zurück).

+ + + + {% else %} +
+ +
+ {% endif %} +
+ {% if fehler %}

{{ fehler }}

{% else %} diff --git a/templates/geraete_hardware.html b/templates/geraete_hardware.html index df26ed8..730462d 100644 --- a/templates/geraete_hardware.html +++ b/templates/geraete_hardware.html @@ -4,6 +4,23 @@

← Geräteliste

Hardware-Informationen: {{ device.hostname or device.device_fingerprint }}

+{% if device.health %} +
+

Aktueller Zustand (letzter Checkin)

+
+ + + + + + + + +
Diskbelegung (/){{ device.health.disk_used_percent ~ "%" if device.health.disk_used_percent is not none else "—" }}
RAM-Auslastung{{ device.health.ram_used_percent ~ "%" if device.health.ram_used_percent is not none else "—" }}
Uptime{{ (device.health.uptime_seconds / 3600) | round(1) ~ " h" if device.health.uptime_seconds is not none else "—" }}
Load Average (1/5/15 Min){{ device.health.load_1m ~ " / " ~ device.health.load_5m ~ " / " ~ device.health.load_15m if device.health.load_1m is not none else "—" }}
Stand{{ device.health.collected_at }}
+
+
+{% endif %} + {% if fehler %}

{{ fehler }}

{% elif not hardware %} diff --git a/templates/geraete_liste.html b/templates/geraete_liste.html index 162479c..11f820f 100644 --- a/templates/geraete_liste.html +++ b/templates/geraete_liste.html @@ -24,6 +24,7 @@ {% else %} aktiv {% endif %} + {% if device.debug_mode_until %}
🐞 Debug-Modus aktiv{% endif %} Auftragskatalog → diff --git a/templates/geraete_log.html b/templates/geraete_log.html index 2cfa98e..9335db5 100644 --- a/templates/geraete_log.html +++ b/templates/geraete_log.html @@ -4,6 +4,8 @@

← Geräteliste

Installations-/Aktions-Log: {{ device.hostname or device.device_fingerprint }}

+

Zuletzt gemeldet: {{ device.agent_last_checkin or "noch nie" }}

+ {% if not events %}

Für dieses Gerät liegen noch keine Einträge vor.

{% else %}