- Query WLED JSON API (/json/info) for device info - Show online/offline status dot, LED count and firmware version - Auto-check all devices on page load - Button to manually check individual or all devices - Fix hostname placeholder to volksheimstaette.de Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
183 lines
8.8 KiB
HTML
183 lines
8.8 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>
|
|
<button class="btn btn-sm btn-outline-secondary" onclick="checkAllDevices()">
|
|
<i class="bi bi-arrow-clockwise"></i> Alle pruefen
|
|
</button>
|
|
</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>
|
|
<span class="status-dot" id="status-{{ device.id }}"
|
|
style="background: #999;" title="Nicht geprueft"></span>
|
|
</td>
|
|
<td>
|
|
<code>{{ device.hostname }}</code>
|
|
</td>
|
|
<td>{{ device.name }}</td>
|
|
<td><span id="leds-{{ device.id }}" class="text-muted">-</span></td>
|
|
<td><span id="version-{{ device.id }}" class="text-muted">-</span></td>
|
|
<td>{{ device.segment_count }}</td>
|
|
<td>
|
|
<button class="btn btn-sm btn-outline-secondary" onclick="checkDevice({{ device.id }})" title="Status pruefen">
|
|
<i class="bi bi-wifi"></i>
|
|
</button>
|
|
<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>
|
|
|
|
<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 %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
const deviceIds = [{% for d in devices %}{{ d.id }}{% if not loop.last %},{% endif %}{% endfor %}];
|
|
|
|
function checkDevice(id) {
|
|
const dot = document.getElementById('status-' + id);
|
|
const leds = document.getElementById('leds-' + id);
|
|
const ver = document.getElementById('version-' + id);
|
|
dot.style.background = '#ffc107';
|
|
dot.title = 'Pruefe...';
|
|
|
|
fetch('/api/devices/' + id + '/status')
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
if (data.online) {
|
|
dot.style.background = '#28a745';
|
|
dot.title = 'Online';
|
|
leds.textContent = data.leds || '-';
|
|
ver.textContent = data.version || '-';
|
|
} else {
|
|
dot.style.background = '#dc3545';
|
|
dot.title = 'Offline';
|
|
leds.textContent = '-';
|
|
ver.textContent = '-';
|
|
}
|
|
})
|
|
.catch(() => {
|
|
dot.style.background = '#dc3545';
|
|
dot.title = 'Fehler';
|
|
});
|
|
}
|
|
|
|
function checkAllDevices() {
|
|
deviceIds.forEach(id => checkDevice(id));
|
|
}
|
|
|
|
// Auto-check on page load
|
|
checkAllDevices();
|
|
</script>
|
|
{% endblock %}
|