Files
fruehstuecksapp/views/users.ejs

78 lines
3.0 KiB
Plaintext

<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Benutzerverwaltung - Frühstückskonten Verwaltung</title>
<link rel="stylesheet" href="/styles.css">
</head>
<body>
<div class="container">
<header>
<h1>Frühstückskonten Verwaltung</h1>
<% if (typeof user !== 'undefined' && user) { %>
<nav>
<span>Angemeldet als: <strong><%= user.username %></strong> (<%= user.role %>) |
<a href="/dashboard">Dashboard</a> |
<a href="/accounts">Konten</a>
<% if (user.role === 'admin') { %>
| <a href="/items">Artikel</a>
| <a href="/users">Benutzer</a>
<% } %>
| <a href="/logout">Abmelden</a>
</span>
</nav>
<% } %>
</header>
<main>
<h2>Benutzerverwaltung</h2>
<div class="actions">
<a href="/users/new" class="btn">Neuen Benutzer anlegen</a>
</div>
<table class="data-table">
<thead>
<tr>
<th>Benutzername</th>
<th>Rolle</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
<% if (typeof users !== 'undefined' && users.length > 0) { %>
<% users.forEach(function(userItem) { %>
<tr>
<td><%= userItem.username %></td>
<td><%= userItem.role %></td>
<td>
<% if (userItem.id !== user.id) { %>
<form action="/users/<%= userItem.id %>/delete" method="POST" style="display: inline;">
<button type="submit" class="btn-danger"
onclick="return confirm('Benutzer wirklich löschen?')">Löschen</button>
</form>
<% } else { %>
<span class="disabled">(Eigener Account)</span>
<% } %>
</td>
</tr>
<% }); %>
<% } else { %>
<tr>
<td colspan="3">Keine Benutzer vorhanden</td>
</tr>
<% } %>
</tbody>
</table>
<p>Gesamt: <%= typeof users !== 'undefined' ? users.length : 0 %> Benutzer</p>
</main>
<footer>
<p>&copy; 2024 Frühstückskonten Verwaltung</p>
</footer>
</div>
</body>
</html>