feat: show last activity timestamp per device on Tuerschilder page
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ae6feacf6a
commit
77ae7b357d
13
app.py
13
app.py
@ -202,9 +202,20 @@ async def toggle_user(azure_id: str):
|
|||||||
@app.get("/devices", response_class=HTMLResponse)
|
@app.get("/devices", response_class=HTMLResponse)
|
||||||
async def devices_page(request: Request):
|
async def devices_page(request: Request):
|
||||||
conn = database.get_db()
|
conn = database.get_db()
|
||||||
devices = conn.execute(
|
devices_raw = conn.execute(
|
||||||
"SELECT * FROM wled_devices ORDER BY name, hostname"
|
"SELECT * FROM wled_devices ORDER BY name, hostname"
|
||||||
).fetchall()
|
).fetchall()
|
||||||
|
# Letzte Aktivitaet pro Device aus activity_log
|
||||||
|
devices = []
|
||||||
|
for dev in devices_raw:
|
||||||
|
last_act = conn.execute("""
|
||||||
|
SELECT MAX(l.timestamp) as la
|
||||||
|
FROM activity_log l
|
||||||
|
WHERE l.wled_url LIKE '%' || ? || '%'
|
||||||
|
""", (dev["hostname"],)).fetchone()
|
||||||
|
d = dict(dev)
|
||||||
|
d["last_activity"] = last_act["la"] if last_act and last_act["la"] else None
|
||||||
|
devices.append(d)
|
||||||
last_check_row = conn.execute(
|
last_check_row = conn.execute(
|
||||||
"SELECT MAX(last_check) as lc FROM wled_devices WHERE last_check IS NOT NULL"
|
"SELECT MAX(last_check) as lc FROM wled_devices WHERE last_check IS NOT NULL"
|
||||||
).fetchone()
|
).fetchone()
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>LEDs</th>
|
<th>LEDs</th>
|
||||||
<th>Version</th>
|
<th>Version</th>
|
||||||
|
<th>Letzte Aktivitaet</th>
|
||||||
<th>Segmente</th>
|
<th>Segmente</th>
|
||||||
<th>Aktionen</th>
|
<th>Aktionen</th>
|
||||||
</tr>
|
</tr>
|
||||||
@ -53,6 +54,7 @@
|
|||||||
<td>{{ device.name }}</td>
|
<td>{{ device.name }}</td>
|
||||||
<td>{{ device.leds if device.leds else '-' }}</td>
|
<td>{{ device.leds if device.leds else '-' }}</td>
|
||||||
<td>{{ device.version if device.version else '-' }}</td>
|
<td>{{ device.version if device.version else '-' }}</td>
|
||||||
|
<td><small>{{ device.last_activity or '-' }}</small></td>
|
||||||
<td>{{ device.segment_count }}</td>
|
<td>{{ device.segment_count }}</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" action="/api/devices/{{ device.id }}/check" class="d-inline">
|
<form method="post" action="/api/devices/{{ device.id }}/check" class="d-inline">
|
||||||
@ -112,7 +114,7 @@
|
|||||||
|
|
||||||
{% if not devices %}
|
{% if not devices %}
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="7" class="text-center text-muted py-4">
|
<td colspan="8" class="text-center text-muted py-4">
|
||||||
Noch keine Tuerschilder vorhanden.
|
Noch keine Tuerschilder vorhanden.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user