feat: add per-device check button on WLED devices page
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e88ab3ab08
commit
47210cb068
21
app.py
21
app.py
@ -256,6 +256,27 @@ async def check_all_devices():
|
|||||||
return RedirectResponse("/devices", status_code=303)
|
return RedirectResponse("/devices", status_code=303)
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/api/devices/{device_id}/check")
|
||||||
|
async def check_single_device(device_id: int):
|
||||||
|
from wled_client import get_wled_info
|
||||||
|
conn = database.get_db()
|
||||||
|
dev = conn.execute("SELECT hostname FROM wled_devices WHERE id=?", (device_id,)).fetchone()
|
||||||
|
if dev:
|
||||||
|
from datetime import datetime
|
||||||
|
info = get_wled_info(dev["hostname"])
|
||||||
|
conn.execute("""
|
||||||
|
UPDATE wled_devices SET online=?, leds=?, version=?, last_check=? WHERE id=?
|
||||||
|
""", (
|
||||||
|
1 if info.get("online") else 0,
|
||||||
|
info.get("leds", 0) if info.get("online") else 0,
|
||||||
|
info.get("version", "") if info.get("online") else "",
|
||||||
|
datetime.now(), device_id,
|
||||||
|
))
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
return RedirectResponse("/devices", status_code=303)
|
||||||
|
|
||||||
|
|
||||||
# ── Assignments ────────────────────────────────────────────────────────────
|
# ── Assignments ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@app.get("/assignments", response_class=HTMLResponse)
|
@app.get("/assignments", response_class=HTMLResponse)
|
||||||
|
|||||||
@ -55,6 +55,11 @@
|
|||||||
<td>{{ device.version if device.version else '-' }}</td>
|
<td>{{ device.version if device.version else '-' }}</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">
|
||||||
|
<button type="submit" class="btn btn-sm btn-outline-secondary" title="Jetzt pruefen">
|
||||||
|
<i class="bi bi-wifi"></i>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
<button class="btn btn-sm btn-outline-primary" data-bs-toggle="modal"
|
<button class="btn btn-sm btn-outline-primary" data-bs-toggle="modal"
|
||||||
data-bs-target="#edit-{{ device.id }}">
|
data-bs-target="#edit-{{ device.id }}">
|
||||||
<i class="bi bi-pencil"></i>
|
<i class="bi bi-pencil"></i>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user