269 lines
15 KiB
HTML
269 lines
15 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}Tuerschilder - Busylight{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h4 class="mb-0">Tuerschilder</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>
|
|
|
|
{% if request.query_params.get('fw_uploaded') %}
|
|
<div class="alert alert-success alert-dismissible fade show">
|
|
<i class="bi bi-check-circle"></i> Firmware hochgeladen.
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
{% endif %}
|
|
{% if request.query_params.get('fw_updated') %}
|
|
<div class="alert alert-success alert-dismissible fade show">
|
|
<i class="bi bi-check-circle"></i> Update auf <strong>{{ request.query_params.get('fw_updated') }}</strong> gestartet. Geraet startet neu.
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
{% endif %}
|
|
{% if request.query_params.get('fw_error') %}
|
|
<div class="alert alert-danger alert-dismissible fade show">
|
|
<i class="bi bi-x-circle"></i>
|
|
{% if request.query_params.get('fw_error') == 'format' %}Nur .bin Dateien erlaubt.
|
|
{% elif request.query_params.get('fw_error') == 'nofile' %}Firmware-Datei nicht gefunden.
|
|
{% elif request.query_params.get('fw_error') == 'failed' %}Update fehlgeschlagen. Config-Backup wurde erstellt.
|
|
{% else %}Firmware-Fehler.{% endif %}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</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>
|
|
{% 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><small class="font-monospace">{{ device.mac if device.mac else '-' }}</small></td>
|
|
<td><small>{{ device.last_activity or '-' }}</small></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>
|
|
{% if firmwares and device.version and device.online %}
|
|
{% set needs_update = [] %}
|
|
{% for fw in firmwares %}
|
|
{% if device.version not in fw.name %}
|
|
{% if needs_update.append(1) %}{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% if needs_update %}
|
|
<button class="btn btn-sm btn-outline-warning" title="Firmware Update verfuegbar"
|
|
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 }}">
|
|
<i class="bi bi-pencil"></i>
|
|
</button>
|
|
<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">
|
|
<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">Tuerschild 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>
|
|
<!-- OTA Update Modal -->
|
|
{% if firmwares %}
|
|
<div class="modal fade" id="ota-{{ device.id }}" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<form method="post" action="/api/firmware/{{ device.id }}/update">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Firmware Update</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p>Update fuer <strong>{{ device.name or device.hostname }}</strong></p>
|
|
<p><small class="text-muted">Aktuelle Version: {{ device.version or 'unbekannt' }}</small></p>
|
|
<div class="mb-3">
|
|
<label class="form-label">Firmware waehlen</label>
|
|
<select name="firmware_file" class="form-select">
|
|
{% for fw in firmwares %}
|
|
<option value="{{ fw.name }}">{{ fw.name }} ({{ fw.size }})</option>
|
|
{% endfor %}
|
|
</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>
|
|
</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-warning"><i class="bi bi-cloud-arrow-up"></i> Update starten</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if not devices %}
|
|
<tr>
|
|
<td colspan="9" class="text-center text-muted py-4">
|
|
Noch keine Tuerschilder vorhanden.
|
|
</td>
|
|
</tr>
|
|
{% 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 class="col-lg-4">
|
|
<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"
|
|
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>
|
|
|
|
<!-- Firmware Upload -->
|
|
<div class="card mt-3">
|
|
<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>
|
|
<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>
|
|
</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>
|
|
<form method="post" action="/api/firmware/{{ fw.name }}/delete" class="d-inline"
|
|
onsubmit="return confirm('Firmware loeschen?')">
|
|
<button type="submit" class="btn btn-sm btn-outline-danger py-0">
|
|
<i class="bi bi-trash"></i>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|