first commit
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Zugriffe für {{ user.username }} - mGuard VPN Manager{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<nav aria-label="breadcrumb" class="mb-3">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="/users">Benutzer</a></li>
|
||||
<li class="breadcrumb-item"><a href="/users/{{ user.id }}/edit">{{ user.username }}</a></li>
|
||||
<li class="breadcrumb-item active">Zugriffe</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h1><i class="bi bi-key"></i> Zugriffe für {{ user.username }}</h1>
|
||||
<p class="text-muted mb-0">{{ user.email }} | Rolle: {{ user.role.value }}</p>
|
||||
</div>
|
||||
<a href="/users" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left"></i> Zurück
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0"><i class="bi bi-router"></i> Gateway-Zugriffe</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="/users/{{ user.id }}/access">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 50px;">Zugriff</th>
|
||||
<th>Gateway</th>
|
||||
<th>Standort</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for gateway in gateways %}
|
||||
<tr>
|
||||
<td>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox"
|
||||
name="gateway_ids" value="{{ gateway.id }}"
|
||||
id="gw_{{ gateway.id }}"
|
||||
{{ 'checked' if gateway.id in access_gateway_ids }}>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<label for="gw_{{ gateway.id }}" class="mb-0" style="cursor: pointer;">
|
||||
{{ gateway.name }}
|
||||
</label>
|
||||
</td>
|
||||
<td class="text-muted">{{ gateway.location or '-' }}</td>
|
||||
<td>
|
||||
{% if gateway.is_online %}
|
||||
<span class="badge bg-success">Online</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary">Offline</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted py-4">
|
||||
Keine Gateways vorhanden
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% if gateways %}
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="selectAll()">
|
||||
Alle auswählen
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" onclick="selectNone()">
|
||||
Keine auswählen
|
||||
</button>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-check-circle"></i> Speichern
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0"><i class="bi bi-info-circle"></i> Info</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="mb-2"><strong>Benutzer:</strong> {{ user.username }}</p>
|
||||
<p class="mb-2"><strong>Rolle:</strong>
|
||||
<span class="badge badge-role-{{ user.role.value }}">{{ user.role.value }}</span>
|
||||
</p>
|
||||
|
||||
<hr>
|
||||
|
||||
<h6>Rollen-Erklärung:</h6>
|
||||
<ul class="small text-muted">
|
||||
<li><strong>technician:</strong> Kann nur zugewiesene Gateways sehen und verbinden</li>
|
||||
<li><strong>admin:</strong> Kann alle Gateways des Mandanten verwalten</li>
|
||||
<li><strong>super_admin:</strong> Voller Zugriff auf alle Mandanten</li>
|
||||
</ul>
|
||||
|
||||
<div class="alert alert-info small mb-0">
|
||||
<i class="bi bi-lightbulb"></i>
|
||||
Admins haben automatisch Zugriff auf alle Gateways ihres Mandanten.
|
||||
Diese Zuweisungen gelten nur für Techniker.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function selectAll() {
|
||||
document.querySelectorAll('input[name="gateway_ids"]').forEach(cb => cb.checked = true);
|
||||
}
|
||||
function selectNone() {
|
||||
document.querySelectorAll('input[name="gateway_ids"]').forEach(cb => cb.checked = false);
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,99 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ 'Benutzer bearbeiten' if user else 'Neuer Benutzer' }} - mGuard VPN Manager{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<nav aria-label="breadcrumb" class="mb-3">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="/users">Benutzer</a></li>
|
||||
<li class="breadcrumb-item active">{{ 'Bearbeiten' if user else 'Neu' }}</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-6">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">
|
||||
<i class="bi bi-{{ 'pencil' if user else 'person-plus' }}"></i>
|
||||
{{ 'Benutzer bearbeiten' if user else 'Neuer Benutzer' }}
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="post" action="{{ '/users/' ~ user.id ~ '/edit' if user else '/users/new' }}">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Benutzername *</label>
|
||||
<input type="text" class="form-control" name="username" required
|
||||
value="{{ user.username if user else '' }}"
|
||||
placeholder="benutzername"
|
||||
{{ 'readonly' if user else '' }}>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">E-Mail *</label>
|
||||
<input type="email" class="form-control" name="email" required
|
||||
value="{{ user.email if user else '' }}"
|
||||
placeholder="user@example.com">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Vollständiger Name</label>
|
||||
<input type="text" class="form-control" name="full_name"
|
||||
value="{{ user.full_name if user else '' }}"
|
||||
placeholder="Max Mustermann">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Passwort {{ '(leer lassen = unverändert)' if user else '*' }}</label>
|
||||
<input type="password" class="form-control" name="password"
|
||||
{{ '' if user else 'required' }}
|
||||
placeholder="{{ '••••••••' if user else 'Mindestens 8 Zeichen' }}">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Rolle *</label>
|
||||
<select class="form-select" name="role" required>
|
||||
{% for role in roles %}
|
||||
<option value="{{ role }}" {{ 'selected' if user and user.role.value == role }}>
|
||||
{{ role }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{% if current_user.is_super_admin and not user %}
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Mandant</label>
|
||||
<select class="form-select" name="tenant_id">
|
||||
<option value="">Kein Mandant (Super Admin)</option>
|
||||
{% for tenant in tenants %}
|
||||
<option value="{{ tenant.id }}">{{ tenant.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if user %}
|
||||
<div class="mb-3 form-check">
|
||||
<input type="checkbox" class="form-check-input" name="is_active" id="is_active"
|
||||
{{ 'checked' if user.is_active }}>
|
||||
<label class="form-check-label" for="is_active">Aktiv</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="/users" class="btn btn-secondary">
|
||||
<i class="bi bi-x-circle"></i> Abbrechen
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-check-circle"></i> {{ 'Speichern' if user else 'Benutzer anlegen' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,83 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Benutzer - mGuard VPN Manager{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1><i class="bi bi-people"></i> Benutzer</h1>
|
||||
<a href="/users/new" class="btn btn-primary">
|
||||
<i class="bi bi-person-plus"></i> Neuer Benutzer
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Benutzername</th>
|
||||
<th>E-Mail</th>
|
||||
<th>Rolle</th>
|
||||
<th>Status</th>
|
||||
<th>Letzter Login</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>
|
||||
<i class="bi bi-person-circle"></i>
|
||||
{{ user.username }}
|
||||
{% if user.full_name %}
|
||||
<small class="text-muted d-block">{{ user.full_name }}</small>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>
|
||||
<span class="badge badge-role-{{ user.role.value }}">{{ user.role.value }}</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if user.is_active %}
|
||||
<span class="badge bg-success">Aktiv</span>
|
||||
{% else %}
|
||||
<span class="badge bg-danger">Inaktiv</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if user.last_login %}
|
||||
<span data-relative-time="{{ user.last_login }}">{{ user.last_login.strftime('%d.%m.%Y %H:%M') }}</span>
|
||||
{% else %}
|
||||
<span class="text-muted">Nie</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="/users/{{ user.id }}/edit" class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<a href="/users/{{ user.id }}/access" class="btn btn-sm btn-outline-info">
|
||||
<i class="bi bi-key"></i> Zugriffe
|
||||
</a>
|
||||
{% if user.id != current_user.id %}
|
||||
<button class="btn btn-sm btn-outline-danger"
|
||||
hx-delete="/htmx/users/{{ user.id }}"
|
||||
hx-confirm="Benutzer '{{ user.username }}' wirklich löschen?"
|
||||
hx-target="closest tr"
|
||||
hx-swap="outerHTML">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="6" class="text-center text-muted py-4">
|
||||
Keine Benutzer vorhanden
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user