Userverwaltung
This commit is contained in:
87
srv/poe_manager/templates/users.html
Normal file
87
srv/poe_manager/templates/users.html
Normal file
@@ -0,0 +1,87 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<h2>Users</h2>
|
||||
|
||||
{% if current_user.is_admin %}
|
||||
<!-- Button Neues User-Popup -->
|
||||
<button class="btn btn-success mb-3" data-bs-toggle="modal" data-bs-target="#userModal" onclick="openUserModal()">Neuer Benutzer</button>
|
||||
{% endif %}
|
||||
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Funktion</th>
|
||||
{% if current_user.is_admin %}<th>Aktionen</th>{% endif %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for u in users %}
|
||||
<tr>
|
||||
<td>{{ u['username'] }}</td>
|
||||
<td>{% if u['is_admin'] %}Admin{% else %}User{% endif %}</td>
|
||||
{% if current_user.is_admin %}
|
||||
<td>
|
||||
<button class="btn btn-primary btn-sm" data-bs-toggle="modal" data-bs-target="#userModal"
|
||||
onclick="openUserModal({{ u['id'] }}, '{{ u['username'] }}', {{ u['is_admin'] }})">Bearbeiten</button>
|
||||
<form method="post" style="display:inline;">
|
||||
<button name="delete_user" value="{{ u['id'] }}" class="btn btn-danger btn-sm"
|
||||
onclick="return confirm('Willst du den Benutzer wirklich löschen?');">Löschen</button>
|
||||
</form>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="userModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<form method="post" id="userForm">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="userModalTitle">Benutzer</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input type="hidden" name="user_id" id="user_id">
|
||||
<input type="hidden" name="edit_user" id="edit_user">
|
||||
<div class="mb-3">
|
||||
<label>Username</label>
|
||||
<input type="text" name="username" id="modal_username" class="form-control" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label>Passwort</label>
|
||||
<input type="password" name="password" id="modal_password" class="form-control" placeholder="Nur eintragen, wenn Passwort geändert werden soll">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label>Rolle</label>
|
||||
<select name="is_admin" id="modal_is_admin" class="form-control">
|
||||
<option value="0">User</option>
|
||||
<option value="1">Admin</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function openUserModal(id=null, username='', is_admin=0) {
|
||||
document.getElementById('user_id').value = id || '';
|
||||
document.getElementById('modal_username').value = username || '';
|
||||
document.getElementById('modal_password').value = '';
|
||||
document.getElementById('modal_is_admin').value = is_admin;
|
||||
document.getElementById('edit_user').value = id ? 1 : '';
|
||||
document.getElementById('userModalTitle').innerText = id ? 'Benutzer bearbeiten' : 'Neuen Benutzer anlegen';
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user