Christian Mueller 47210cb068 feat: add per-device check button on WLED devices page
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-23 23:06:39 +02:00

161 lines
8.5 KiB
HTML

{% extends "base.html" %}
{% block title %}WLED-Geraete - Busylight{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h4 class="mb-0">WLED-Geraete</h4>
<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
</button>
</form>
{% if last_check %}
<small class="text-muted ms-2">Letzte Pruefung: {{ last_check }}</small>
{% endif %}
</div>
</div>
<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>Segmente</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for device in devices %}
<tr>
<td>
{% if device.last_check %}
{% if device.online %}
<span class="status-dot" style="background: #28a745;" title="Online"></span>
{% else %}
<span class="status-dot" style="background: #dc3545;" title="Offline"></span>
{% endif %}
{% else %}
<span class="status-dot" style="background: #999;" title="Noch 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>
<td>{{ device.segment_count }}</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"
data-bs-target="#edit-{{ device.id }}">
<i class="bi bi-pencil"></i>
</button>
<form method="post" action="/api/devices/{{ device.id }}/delete"
class="d-inline"
onsubmit="return confirm('Geraet wirklich loeschen?')">
<button type="submit" class="btn btn-sm btn-outline-danger">
<i class="bi bi-trash"></i>
</button>
</form>
</td>
</tr>
<!-- Edit Modal -->
<div class="modal fade" id="edit-{{ device.id }}" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="/api/devices/{{ device.id }}/update">
<div class="modal-header">
<h5 class="modal-title">Geraet bearbeiten</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label">Hostname / IP</label>
<input type="text" name="hostname" class="form-control"
value="{{ device.hostname }}" required>
</div>
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" name="name" class="form-control"
value="{{ device.name }}">
</div>
<div class="mb-3">
<label class="form-label">Anzahl Segmente</label>
<input type="number" name="segment_count" class="form-control"
value="{{ device.segment_count }}" min="1" max="10">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
<button type="submit" class="btn btn-primary">Speichern</button>
</div>
</form>
</div>
</div>
</div>
{% endfor %}
{% if not devices %}
<tr>
<td colspan="7" class="text-center text-muted py-4">
Noch keine Geraete vorhanden.
</td>
</tr>
{% endif %}
</tbody>
</table>
</div>
</div>
</div>
<div class="mt-2 text-muted">
<small>{{ devices|length }} Geraete | Status wird alle 4 Minuten automatisch geprueft</small>
</div>
</div>
<div class="col-lg-4">
<div class="card">
<div class="card-header">
<h6 class="mb-0"><i class="bi bi-plus-circle"></i> Neues Geraet</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"
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>
<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>
<button type="submit" class="btn btn-primary w-100">
<i class="bi bi-plus"></i> Hinzufuegen
</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}