ui: back to table layout with segment assignments inline

This commit is contained in:
Christian Mueller 2026-04-24 14:14:32 +02:00
parent ed34ea95ca
commit cddea5ba4c

View File

@ -39,7 +39,7 @@
</div> </div>
{% endif %} {% endif %}
<!-- Add Device + Firmware oben --> <!-- Neues Tuerschild + Firmware -->
<div class="row g-3 mb-4"> <div class="row g-3 mb-4">
<div class="col-md-6"> <div class="col-md-6">
<div class="card"> <div class="card">
@ -103,181 +103,169 @@
</div> </div>
</div> </div>
<!-- Device Cards --> <!-- Geraete-Tabelle -->
<div class="row g-3 mb-4"> <div class="card">
{% for device in devices %} <div class="card-body p-0">
<div class="col-md-6 col-lg-4 col-xl-3"> <div class="table-responsive">
<div class="card busylight-card h-100"> <table class="table table-hover table-sm mb-0">
<div class="card-header bg-white border-0 pb-0"> <thead>
<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>
{% else %}
<span class="status-dot" style="background: #dc3545;" title="Offline"></span>
{% endif %}
{% else %}
<span class="status-dot" style="background: #999;" title="Nicht geprueft"></span>
{% endif %}
</div>
</div>
<div class="card-body pt-2">
<table class="table table-sm table-borderless mb-2" style="font-size: 0.8rem;">
<tr> <tr>
<td class="text-muted" style="width:70px">Host</td> <th></th>
<td><code class="small">{{ device.hostname }}</code></td> <th>Name</th>
<th>Hostname</th>
<th>MAC</th>
<th>Version</th>
<th>LEDs</th>
<th>Segmente</th>
<th>Letzte Aktivitaet</th>
<th>Aktionen</th>
</tr> </tr>
</thead>
<tbody>
{% for device in devices %}
<tr> <tr>
<td class="text-muted">MAC</td> <td>
<td><small class="font-monospace">{{ device.mac if device.mac else '-' }}</small></td> {% if device.last_check %}
</tr> {% if device.online %}
<tr> <span class="status-dot" style="background: #28a745;" title="Online"></span>
<td class="text-muted">Version</td> {% else %}
<td>{{ device.version if device.version else '-' }}</td> <span class="status-dot" style="background: #dc3545;" title="Offline"></span>
</tr> {% endif %}
<tr> {% else %}
<td class="text-muted">LEDs</td> <span class="status-dot" style="background: #999;" title="Nicht geprueft"></span>
<td>{{ device.leds if device.leds else '-' }}</td>
</tr>
<tr>
<td class="text-muted">Segmente</td>
<td>{{ device.segment_count }}</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>
</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 %} {% endif %}
{% endfor %} </td>
{% if needs_update %} <td><strong>{{ device.name or '-' }}</strong></td>
<button class="btn btn-sm btn-outline-warning" title="Firmware Update" <td><code class="small">{{ device.hostname }}</code></td>
data-bs-toggle="modal" data-bs-target="#ota-{{ device.id }}"> <td><small class="font-monospace">{{ device.mac if device.mac else '-' }}</small></td>
<i class="bi bi-cloud-arrow-up"></i> <td>{{ device.version if device.version else '-' }}</td>
</button> <td>{{ device.leds if device.leds else '-' }}</td>
{% endif %} <td>
{% endif %} {% if device.segments %}
<button class="btn btn-sm btn-outline-primary" data-bs-toggle="modal" {% for seg in device.segments %}
data-bs-target="#edit-{{ device.id }}" title="Bearbeiten"> <div><span class="badge bg-primary" style="font-size:0.6rem">{{ seg.segment }}</span> <small>{{ seg.display_name }}</small></div>
<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" title="Loeschen">
<i class="bi bi-trash"></i>
</button>
</form>
</div>
</div>
</div>
</div>
<!-- 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 %} {% endfor %}
</select> {% else %}
</div> <small class="text-muted">{{ device.segment_count }}x (leer)</small>
<div class="alert alert-info mb-0"> {% endif %}
<small><i class="bi bi-info-circle"></i> Config wird vor dem Update automatisch gesichert.</small> </td>
<td><small>{{ device.last_activity or '-' }}</small></td>
<td>
<form method="post" action="/api/devices/{{ device.id }}/check" class="d-inline">
<button type="submit" class="btn btn-sm btn-outline-secondary py-0" 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 py-0" 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 py-0" data-bs-toggle="modal"
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"
onsubmit="return confirm('Tuerschild wirklich loeschen?')">
<button type="submit" class="btn btn-sm btn-outline-danger py-0" title="Loeschen">
<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>
</div> </div>
<div class="modal-footer"> <!-- OTA Update Modal -->
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button> {% if firmwares %}
<button type="submit" class="btn btn-warning"><i class="bi bi-cloud-arrow-up"></i> Update starten</button> <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> Config wird vor dem Update automatisch gesichert.</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> </div>
</form> {% endif %}
</div> {% 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>
{% endif %}
{% endfor %}
{% if not devices %}
<div class="col-12">
<div class="text-center text-muted py-4">Noch keine Tuerschilder vorhanden.</div>
</div>
{% endif %}
</div> </div>
<div class="mt-2 text-muted">
<div class="text-muted">
<small>{{ devices|length }} Tuerschilder | Status wird alle 4 Minuten automatisch geprueft</small> <small>{{ devices|length }} Tuerschilder | Status wird alle 4 Minuten automatisch geprueft</small>
</div> </div>
{% endblock %} {% endblock %}