admin: Installations-/Aktions-Log für Geräte (Merkmal- + Installationsereignisse)
Neue Route /admin/geraete/{device_id}/log fasst device_merkmal_events
(Auftragskatalog, bereits bestehend) und die neuen
device_installation_events (Migration 0025 in provisioning-server,
Boot-Medium-Meilensteine/Fehlschläge) chronologisch zusammen - eigenes
Template (templates/admin/geraete_log.html), bewusst getrennt von der
Kunden-Seite (templates/geraete_log.html bleibt unverändert), da noch
offen ist, ob/wie umfangreich Installationsereignisse dem Kunden selbst
gezeigt werden sollen.
This commit is contained in:
parent
06ba70d970
commit
adad94b11a
@ -51,6 +51,31 @@ def oe_verschieben(device_id: str, oe_id: str = Form(...), user: dict = Depends(
|
|||||||
return RedirectResponse("/admin/geraete", status_code=303)
|
return RedirectResponse("/admin/geraete", status_code=303)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/{device_id}/log")
|
||||||
|
def log_ansicht(request: Request, device_id: str, user: dict = Depends(require_admin)):
|
||||||
|
device = find_device(device_id)
|
||||||
|
|
||||||
|
if device is None:
|
||||||
|
raise HTTPException(status_code=404, detail="Gerät wurde nicht gefunden.")
|
||||||
|
|
||||||
|
# Merkmal-Anwendungen (Auftragskatalog) UND Installations-Meilensteine/
|
||||||
|
# Fehlschlaege des Boot-Mediums selbst (siehe device_installation_events,
|
||||||
|
# Migration 0025 in provisioning-server) zusammengefuehrt, neueste
|
||||||
|
# zuerst - bewusst nur hier im Admin-Bereich (siehe
|
||||||
|
# templates/admin/geraete_log.html), nicht auf der Kunden-Seite.
|
||||||
|
merkmal_result = anode_request("GET", f"/api/v1/devices/{device_id}/events")
|
||||||
|
merkmal_events = merkmal_result.get("events", []) if merkmal_result.get("success") else []
|
||||||
|
|
||||||
|
installation_result = anode_request("GET", f"/api/v1/devices/{device_id}/installation-events")
|
||||||
|
installation_events = installation_result.get("events", []) if installation_result.get("success") else []
|
||||||
|
|
||||||
|
events = sorted(merkmal_events + installation_events, key=lambda e: e["occurred_at"], reverse=True)
|
||||||
|
|
||||||
|
return templates.TemplateResponse(
|
||||||
|
request, "admin/geraete_log.html", {"user": user, "device": device, "events": events}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{device_id}")
|
@router.get("/{device_id}")
|
||||||
def auftragskatalog_ansicht(request: Request, device_id: str, user: dict = Depends(require_admin)):
|
def auftragskatalog_ansicht(request: Request, device_id: str, user: dict = Depends(require_admin)):
|
||||||
device = find_device(device_id)
|
device = find_device(device_id)
|
||||||
|
|||||||
@ -18,7 +18,10 @@
|
|||||||
<td><code>{{ device.device_fingerprint }}</code></td>
|
<td><code>{{ device.device_fingerprint }}</code></td>
|
||||||
<td>{{ device.oe_name or "—" }}</td>
|
<td>{{ device.oe_name or "—" }}</td>
|
||||||
<td>{{ device.agent_last_checkin or "noch nie" }}{% if device.debug_mode_until %}<br><small>🐞 Debug-Modus aktiv</small>{% endif %}</td>
|
<td>{{ device.agent_last_checkin or "noch nie" }}{% if device.debug_mode_until %}<br><small>🐞 Debug-Modus aktiv</small>{% endif %}</td>
|
||||||
<td><a href="/admin/geraete/{{ device.id }}" role="button" class="outline">Auftragskatalog →</a></td>
|
<td>
|
||||||
|
<a href="/admin/geraete/{{ device.id }}" role="button" class="outline">Auftragskatalog →</a>
|
||||||
|
<a href="/admin/geraete/{{ device.id }}/log" role="button" class="outline">Log →</a>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" action="/admin/geraete/{{ device.id }}/oe">
|
<form method="post" action="/admin/geraete/{{ device.id }}/oe">
|
||||||
<select name="oe_id" aria-label="OE auswählen">
|
<select name="oe_id" aria-label="OE auswählen">
|
||||||
|
|||||||
46
templates/admin/geraete_log.html
Normal file
46
templates/admin/geraete_log.html
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{% extends "admin/layout.html" %}
|
||||||
|
{% block title %}Log {{ device.hostname or device.device_fingerprint }} — Tuxflotte Admin{% endblock %}
|
||||||
|
{% block admin_content %}
|
||||||
|
<p><a href="/admin/geraete">← Alle Geräte</a></p>
|
||||||
|
<h2>Installations-/Aktions-Log: {{ device.hostname or device.device_fingerprint }}</h2>
|
||||||
|
|
||||||
|
<p>Zuletzt gemeldet: {{ device.agent_last_checkin or "noch nie" }}</p>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Zeigt zusaetzlich zu den Merkmal-Anwendungen (Auftragskatalog) auch die
|
||||||
|
Installations-Meilensteine/Fehlschlaege des Boot-Mediums selbst (siehe
|
||||||
|
device_installation_events, Migration 0025 in provisioning-server) -
|
||||||
|
bewusst nur hier im Admin-Bereich, nicht auf der Kunden-Seite
|
||||||
|
(templates/geraete_log.html bleibt unveraendert) - ob/wie umfangreich
|
||||||
|
das dem Kunden selbst gezeigt wird, ist noch offen (01.09.2026).
|
||||||
|
-->
|
||||||
|
{% if not events %}
|
||||||
|
<p>Für dieses Gerät liegen noch keine Einträge vor.</p>
|
||||||
|
{% else %}
|
||||||
|
<figure>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr><th>Zeitpunkt</th><th>Quelle</th><th>Ereignis</th><th>Detail</th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for event in events %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ event.occurred_at }}</td>
|
||||||
|
<td>{{ event.merkmal_name or "Installation" }}</td>
|
||||||
|
<td>
|
||||||
|
{% if event.event_type in ("applied", "selected", "activation_confirmed", "installation_started", "installation_completed") %}
|
||||||
|
<span class="state-present">{{ event.event_type }}</span>
|
||||||
|
{% elif event.event_type in ("apply_failed", "remove_failed", "installation_failed") %}
|
||||||
|
<mark>{{ event.event_type }}</mark>
|
||||||
|
{% else %}
|
||||||
|
<span class="state-absent">{{ event.event_type }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>{% if event.detail %}<details><summary>anzeigen</summary><pre>{{ event.detail }}</pre></details>{% else %}—{% endif %}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</figure>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
Loading…
x
Reference in New Issue
Block a user