busylight_modular/templates/assignments.html
Christian Mueller 39561fe438 ui: rebrand to cynfo GmbH, rename WLED-Geraete to Tuerschilder
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-23 23:53:01 +02:00

116 lines
5.1 KiB
HTML

{% extends "base.html" %}
{% block title %}Zuordnungen - Busylight{% endblock %}
{% block content %}
<h4 class="mb-4">Zuordnungen (Benutzer &rarr; WLED-Segment)</h4>
<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>Benutzer</th>
<th>Tuerschild</th>
<th>Segment</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for a in assignments %}
<tr>
<td>{{ a.display_name }}</td>
<td>
<code>{{ a.hostname }}</code>
{% if a.device_name and a.device_name != a.hostname %}
<small class="text-muted">({{ a.device_name }})</small>
{% endif %}
</td>
<td>
<span class="badge bg-primary">Segment {{ a.segment }}</span>
</td>
<td>
<form method="post" action="/api/assignments/{{ a.id }}/delete" class="d-inline">
<button type="submit" class="btn btn-sm btn-outline-danger">
<i class="bi bi-x-lg"></i>
</button>
</form>
</td>
</tr>
{% endfor %}
{% if not assignments %}
<tr>
<td colspan="4" class="text-center text-muted py-4">
Noch keine Zuordnungen 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> Neue Zuordnung</h6>
</div>
<div class="card-body">
<form method="post" action="/api/assignments">
<div class="mb-3">
<label class="form-label">Benutzer</label>
<select name="user_azure_id" class="form-select" required>
<option value="">-- Benutzer waehlen --</option>
{% for u in users %}
<option value="{{ u.azure_id }}">{{ u.display_name }}</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label">Tuerschild</label>
<select name="wled_device_id" class="form-select" id="device-select" required>
<option value="">-- Geraet waehlen --</option>
{% for d in devices %}
<option value="{{ d.id }}" data-segments="{{ d.segment_count }}">
{{ d.name or d.hostname }} ({{ d.hostname }})
</option>
{% endfor %}
</select>
</div>
<div class="mb-3">
<label class="form-label">Segment</label>
<select name="segment" class="form-select" id="segment-select" required>
<option value="0">Segment 0 (oben)</option>
<option value="1">Segment 1 (unten)</option>
</select>
</div>
<button type="submit" class="btn btn-primary w-100">
<i class="bi bi-link-45deg"></i> Zuordnen
</button>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
document.getElementById('device-select').addEventListener('change', function() {
const opt = this.selectedOptions[0];
const count = parseInt(opt.dataset.segments || '2');
const segSelect = document.getElementById('segment-select');
segSelect.innerHTML = '';
for (let i = 0; i < count; i++) {
const label = i === 0 ? 'unten' : i === 1 ? 'oben' : i.toString();
segSelect.innerHTML += `<option value="${i}">Segment ${i} (${label})</option>`;
}
});
</script>
{% endblock %}