ui: redesign Tuerschilder page as card grid with all device info

- Card per device showing: hostname, MAC, version, LEDs, segments
- Segment assignments displayed per card
- Last activity timestamp
- Online/offline dot in card header
- Action buttons in card footer
- Add device + firmware upload side by side at bottom

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Christian Mueller 2026-04-24 14:02:24 +02:00
parent 14b6352d7e
commit 10d90a3739
2 changed files with 208 additions and 185 deletions

8
app.py
View File

@ -335,6 +335,14 @@ async def devices_page(request: Request):
""", (dev["hostname"],)).fetchone()
d = dict(dev)
d["last_activity"] = last_act["la"] if last_act and last_act["la"] else None
# Segment assignments for this device
d["segments"] = conn.execute("""
SELECT a.segment, u.display_name
FROM assignments a
JOIN users u ON u.azure_id = a.user_azure_id
WHERE a.wled_device_id = ?
ORDER BY a.segment
""", (dev["id"],)).fetchall()
devices.append(d)
last_check_row = conn.execute(
"SELECT MAX(last_check) as lc FROM wled_devices WHERE last_check IS NOT NULL"

View File

@ -7,7 +7,7 @@
<div>
<form method="post" action="/api/devices/check-all" class="d-inline">
<button type="submit" class="btn btn-sm btn-outline-secondary">
<i class="bi bi-arrow-clockwise"></i> Alle jetzt pruefen
<i class="bi bi-arrow-clockwise"></i> Alle pruefen
</button>
</form>
{% if last_check %}
@ -39,29 +39,14 @@
</div>
{% endif %}
<div class="row g-4">
<div class="col-lg-8">
<div class="card">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead>
<tr>
<th>Status</th>
<th>Hostname / IP</th>
<th>Name</th>
<th>LEDs</th>
<th>Version</th>
<th>MAC</th>
<th>Letzte Aktivitaet</th>
<th>Segmente</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
<!-- Device Cards -->
<div class="row g-3 mb-4">
{% for device in devices %}
<tr>
<td>
<div class="col-md-6 col-lg-4 col-xl-3">
<div class="card busylight-card h-100">
<div class="card-header bg-white border-0 pb-0">
<div class="d-flex justify-content-between align-items-center">
<strong>{{ device.name or device.hostname }}</strong>
{% if device.last_check %}
{% if device.online %}
<span class="status-dot" style="background: #28a745;" title="Online"></span>
@ -69,19 +54,54 @@
<span class="status-dot" style="background: #dc3545;" title="Offline"></span>
{% endif %}
{% else %}
<span class="status-dot" style="background: #999;" title="Noch nicht geprueft"></span>
<span class="status-dot" style="background: #999;" title="Nicht geprueft"></span>
{% endif %}
</td>
<td>
<code>{{ device.hostname }}</code>
</td>
<td>{{ device.name }}</td>
<td>{{ device.leds if device.leds else '-' }}</td>
<td>{{ device.version if device.version else '-' }}</td>
</div>
</div>
<div class="card-body pt-2">
<table class="table table-sm table-borderless mb-2" style="font-size: 0.8rem;">
<tr>
<td class="text-muted" style="width:70px">Host</td>
<td><code class="small">{{ device.hostname }}</code></td>
</tr>
<tr>
<td class="text-muted">MAC</td>
<td><small class="font-monospace">{{ device.mac if device.mac else '-' }}</small></td>
<td><small>{{ device.last_activity or '-' }}</small></td>
</tr>
<tr>
<td class="text-muted">Version</td>
<td>{{ device.version if device.version else '-' }}</td>
</tr>
<tr>
<td class="text-muted">LEDs</td>
<td>{{ device.leds if device.leds else '-' }}</td>
</tr>
<tr>
<td class="text-muted">Segmente</td>
<td>{{ device.segment_count }}</td>
<td>
</tr>
</table>
<!-- Segment Zuordnungen -->
{% if device.segments %}
<div class="border-top pt-2">
{% for seg in device.segments %}
<div class="d-flex align-items-center mb-1">
<span class="badge bg-primary me-2" style="font-size:0.65rem">Seg {{ seg.segment }}</span>
<small>{{ seg.display_name }}</small>
</div>
{% endfor %}
</div>
{% endif %}
{% if device.last_activity %}
<div class="border-top pt-2 mt-2">
<small class="text-muted"><i class="bi bi-clock"></i> {{ device.last_activity }}</small>
</div>
{% endif %}
</div>
<div class="card-footer bg-white border-0 pt-0">
<div class="d-flex gap-1">
<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>
@ -95,25 +115,26 @@
{% endif %}
{% endfor %}
{% if needs_update %}
<button class="btn btn-sm btn-outline-warning" title="Firmware Update verfuegbar"
<button class="btn btn-sm btn-outline-warning" title="Firmware Update"
data-bs-toggle="modal" data-bs-target="#ota-{{ device.id }}">
<i class="bi bi-cloud-arrow-up"></i>
</button>
{% endif %}
{% endif %}
<button class="btn btn-sm btn-outline-primary" data-bs-toggle="modal"
data-bs-target="#edit-{{ device.id }}">
data-bs-target="#edit-{{ device.id }}" title="Bearbeiten">
<i class="bi bi-pencil"></i>
</button>
<form method="post" action="/api/devices/{{ device.id }}/delete"
class="d-inline"
<form method="post" action="/api/devices/{{ device.id }}/delete" class="d-inline"
onsubmit="return confirm('Tuerschild wirklich loeschen?')">
<button type="submit" class="btn btn-sm btn-outline-danger">
<button type="submit" class="btn btn-sm btn-outline-danger" title="Loeschen">
<i class="bi bi-trash"></i>
</button>
</form>
</td>
</tr>
</div>
</div>
</div>
</div>
<!-- Edit Modal -->
<div class="modal fade" id="edit-{{ device.id }}" tabindex="-1">
@ -171,7 +192,7 @@
</select>
</div>
<div class="alert alert-info mb-0">
<small><i class="bi bi-info-circle"></i> Die Config wird vor dem Update automatisch gesichert. Das Tuerschild startet nach dem Update neu.</small>
<small><i class="bi bi-info-circle"></i> Config wird vor dem Update automatisch gesichert.</small>
</div>
</div>
<div class="modal-footer">
@ -186,69 +207,63 @@
{% endfor %}
{% if not devices %}
<tr>
<td colspan="9" class="text-center text-muted py-4">
Noch keine Tuerschilder vorhanden.
</td>
</tr>
<div class="col-12">
<div class="text-center text-muted py-4">Noch keine Tuerschilder vorhanden.</div>
</div>
{% endif %}
</tbody>
</table>
</div>
</div>
</div>
<div class="mt-2 text-muted">
<small>{{ devices|length }} Tuerschilder | Status wird alle 4 Minuten automatisch geprueft</small>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="text-muted mb-3">
<small>{{ devices|length }} Tuerschilder | Status wird alle 4 Minuten automatisch geprueft</small>
</div>
<!-- Add Device + Firmware -->
<div class="row g-3">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h6 class="mb-0"><i class="bi bi-plus-circle"></i> Neues Tuerschild</h6>
</div>
<div class="card-body">
<form method="post" action="/api/devices">
<div class="mb-3">
<label class="form-label">Hostname / IP</label>
<input type="text" name="hostname" class="form-control"
<div class="row g-2">
<div class="col-12">
<input type="text" name="hostname" class="form-control form-control-sm"
placeholder="doorlight0027.intra.volksheimstaette.de" required>
</div>
<div class="mb-3">
<label class="form-label">Name (optional)</label>
<input type="text" name="name" class="form-control"
placeholder="Buero 027">
<div class="col-8">
<input type="text" name="name" class="form-control form-control-sm"
placeholder="Name (optional)">
</div>
<div class="mb-3">
<label class="form-label">Anzahl Segmente</label>
<input type="number" name="segment_count" class="form-control"
value="2" min="1" max="10">
<div class="col-4">
<input type="number" name="segment_count" class="form-control form-control-sm"
value="2" min="1" max="10" title="Segmente">
</div>
<button type="submit" class="btn btn-primary w-100">
<div class="col-12">
<button type="submit" class="btn btn-primary btn-sm w-100">
<i class="bi bi-plus"></i> Hinzufuegen
</button>
</div>
</div>
</form>
</div>
</div>
<!-- Firmware Upload -->
<div class="card mt-3">
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h6 class="mb-0"><i class="bi bi-cloud-arrow-up"></i> Firmware</h6>
</div>
<div class="card-body">
<form method="post" action="/api/firmware/upload" enctype="multipart/form-data">
<div class="mb-3">
<label class="form-label">WLED Firmware (.bin)</label>
<form method="post" action="/api/firmware/upload" enctype="multipart/form-data" class="mb-2">
<div class="d-flex gap-2">
<input type="file" name="firmware" class="form-control form-control-sm" accept=".bin" required>
</div>
<button type="submit" class="btn btn-outline-primary btn-sm w-100">
<i class="bi bi-upload"></i> Hochladen
<button type="submit" class="btn btn-outline-primary btn-sm">
<i class="bi bi-upload"></i>
</button>
</div>
</form>
{% if firmwares %}
<hr>
<small class="text-muted d-block mb-2">Verfuegbare Firmwares:</small>
{% for fw in firmwares %}
<div class="d-flex justify-content-between align-items-center mb-1">
<small class="font-monospace">{{ fw.name }} <span class="text-muted">({{ fw.size }})</span></small>