Userverwaltung hinzugefügt

This commit is contained in:
Erik Thiele
2026-06-20 12:09:02 +02:00
parent 2a29025386
commit 39aed78b91
12 changed files with 3252 additions and 2498 deletions

131
templates/user_edit.html Normal file
View File

@@ -0,0 +1,131 @@
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>CANCOM Simple Signage User bearbeiten</title>
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
<script>
(() => {
const stored = window.localStorage.getItem("signage-theme");
const theme = stored === "dark" || stored === "light" ? stored : "light";
document.documentElement.setAttribute("data-bs-theme", theme);
})();
</script>
<link rel="stylesheet"
href="https://unpkg.com/@tabler/core@1.0.0-beta20/dist/css/tabler.min.css">
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css">
<script defer
src="https://unpkg.com/@tabler/core@1.0.0-beta20/dist/js/tabler.min.js"></script>
{% include "_styles.html" %}
</head>
<body>
<div class="page">
{% set brand_subtitle = "User bearbeiten" %}
{% set site_dropdown_url_prefix = "/admin/" %}
{% include "_header.html" %}
<div class="navbar-expand-md">
<div class="collapse navbar-collapse show">
<div class="navbar navbar-dark nav-surface">
<div class="container-xl">
<div class="d-flex flex-wrap gap-2 py-2">
<a class="btn btn-white" href="/admin"><i class="ti ti-arrow-left me-1"></i>Zurück</a>
<a class="btn btn-white" href="/admin/users"><i class="ti ti-users me-1"></i>Userliste</a>
<a class="btn btn-white active" href="#"><i class="ti ti-edit me-1"></i>Bearbeiten</a>
</div>
</div>
</div>
</div>
</div>
<div class="page-wrapper">
<div class="container-xl mt-4" style="max-width:600px;">
{% if error %}
<div class="alert alert-danger" role="alert">{{ error }}</div>
{% endif %}
<div class="card">
<div class="card-header">
<h3 class="card-title"><i class="ti ti-edit me-1"></i>User bearbeiten</h3>
</div>
<div class="card-body">
<form action="/admin/users/edit/{{ user.email }}" method="post">
<div class="mb-3">
<label class="form-label">E-Mail (Username)</label>
<input type="email" name="email" class="form-control" value="{{ user.email }}" required>
</div>
<div class="mb-3">
<label class="form-label">Rolle</label>
<select name="role" class="form-select" id="role-select">
<option value="user" {% if user.role == "user" %}selected{% endif %}>User</option>
<option value="superuser" {% if user.role == "superuser" %}selected{% endif %}>Superuser</option>
<option value="admin" {% if user.role == "admin" %}selected{% endif %}>Admin</option>
</select>
</div>
<div class="mb-3" id="sites-select-wrapper" {% if user.role == "admin" or user.role == "superuser" %}style="display:none"{% endif %}>
<label class="form-label">Standort-Berechtigungen</label>
<div class="dropdown">
<button class="btn btn-outline-secondary w-100 text-start" type="button"
data-bs-toggle="dropdown" aria-expanded="false">
<span id="sites-btn-text">
{%- set checked_sites = user.sites -%}
{%- if checked_sites -%}
{{ checked_sites|length }} von {{ all_sites|length }} ausgewählt
{%- else -%}
Standorte auswählen
{%- endif -%}
</span>
<i class="ti ti-chevron-down float-end"></i>
</button>
<div class="dropdown-menu p-2" style="min-width:220px;" id="sites-dropdown-menu">
{% for s in all_sites %}
<label class="dropdown-item d-flex align-items-center gap-2 px-2 py-1">
<input class="form-check-input m-0" type="checkbox" name="sites" value="{{ s }}"
{% if s in user.sites %}checked{% endif %}>
<span>{{ s | capitalize }}</span>
</label>
{% endfor %}
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Speichern</button>
<a href="/admin/users" class="btn btn-outline-secondary ms-2">Abbrechen</a>
</form>
</div>
</div>
</div>
</div>
{% include "_footer.html" %}
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const roleSelect = document.getElementById("role-select");
const sitesWrapper = document.getElementById("sites-select-wrapper");
roleSelect.addEventListener("change", function () {
sitesWrapper.style.display = (this.value === "admin" || this.value === "superuser") ? "none" : "block";
});
const dropdownMenu = document.getElementById("sites-dropdown-menu");
const btnText = document.getElementById("sites-btn-text");
if (dropdownMenu) {
dropdownMenu.addEventListener("change", function () {
const checked = dropdownMenu.querySelectorAll("input:checked");
const total = dropdownMenu.querySelectorAll("input").length;
btnText.textContent = checked.length === 0
? "Standorte auswählen"
: checked.length === total
? "Alle Standorte"
: checked.length + " von " + total + " ausgewählt";
});
}
});
</script>
</body>
</html>