Admin panels

This commit is contained in:
Frank van den Berg
2026-06-27 15:53:43 +02:00
parent 0d8335dd2c
commit ac57385a9d
17 changed files with 997 additions and 88 deletions
+84 -76
View File
@@ -1,82 +1,90 @@
{% extends 'base.html.twig' %}
{% extends 'game/admin/base.html.twig' %}
{% block title %}Game Admin Dashboard{% endblock %}
{% block title %}Admin Dashboard{% endblock %}
{% block body %}
<h1>Game Admin Dashboard</h1>
{% block admin_body %}
<h1 style="margin: 0 0 1.5rem; font-size: 1.5rem; color: #0f172a;">Dashboard</h1>
<div style="display: flex; gap: 2rem;">
<div style="flex: 1;">
<h2>All Players ({{ players|length }})</h2>
<table style="width: 100%; border-collapse: collapse;">
<thead>
<tr style="background-color: #f2f2f2;">
<th>ID</th>
<th>Username</th>
<th>Email</th>
<th>Roles</th>
<th>Verified</th>
</tr>
</thead>
<tbody>
{% for player in players %}
<tr>
<td>{{ player.id }}</td>
<td>{{ player.username }}</td>
<td>{{ player.email }}</td>
<td>{{ player.roles|join(', ') }}</td>
<td>{{ player.isVerified ? 'Yes' : 'No' }}</td>
</tr>
{% else %}
<tr>
<td colspan="5">No players found.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem;">
{% set stats = [
{ label: 'Total Users', value: totalUsers, color: '#3b82f6' },
{ label: 'Players', value: totalPlayers, color: '#8b5cf6' },
{ label: 'Admins', value: totalAdmins, color: '#f59e0b' },
{ label: 'Games', value: totalGames, color: '#10b981' },
{ label: 'Active Sessions', value: activeSessions, color: '#ef4444' },
{ label: 'Total Sessions', value: totalSessions, color: '#64748b' },
] %}
<div style="flex: 2;">
<h2>All Sessions ({{ sessions|length }})</h2>
<table style="width: 100%; border-collapse: collapse;">
<thead>
<tr style="background-color: #f2f2f2;">
<th>ID</th>
<th>Game</th>
<th>Status</th>
<th>Players Joined</th>
<th>Created At</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for session in sessions %}
<tr>
<td>{{ session.id }}</td>
<td>{{ session.game.name }}</td>
<td>{{ session.status.value }}</td>
<td>
<ul>
{% for p in session.players %}
<li>{{ p.user.username }} (Screen: {{ p.screen ?? 'N/A' }})</li>
{% else %}
<li>No players</li>
{% endfor %}
</ul>
({{ session.players|length }} / {{ session.game.numberOfPlayers }})
</td>
<td>{{ session.created|date('Y-m-d H:i') }}</td>
<td>
<a href="{{ path('game_admin_view_session', {session: session.id}) }}">View Game Logs</a>
</td>
</tr>
{% else %}
<tr>
<td colspan="6">No sessions found.</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% for stat in stats %}
<div style="
background: #fff;
border-radius: 8px;
padding: 1.25rem;
border-left: 4px solid {{ stat.color }};
box-shadow: 0 1px 3px rgba(0,0,0,.07);
">
<div style="font-size: 1.75rem; font-weight: 700; color: {{ stat.color }};">{{ stat.value }}</div>
<div style="font-size: 0.8rem; color: #64748b; margin-top: 0.25rem;">{{ stat.label }}</div>
</div>
{% endfor %}
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem;">
<a href="{{ path('game_admin_users') }}" style="
background: #fff;
border-radius: 8px;
padding: 1.25rem;
text-decoration: none;
color: #1e293b;
box-shadow: 0 1px 3px rgba(0,0,0,.07);
display: flex;
align-items: center;
gap: 0.75rem;
font-weight: 600;
">
<span style="font-size: 1.5rem;">👤</span> Manage Users
</a>
<a href="{{ path('game_admin_games') }}" style="
background: #fff;
border-radius: 8px;
padding: 1.25rem;
text-decoration: none;
color: #1e293b;
box-shadow: 0 1px 3px rgba(0,0,0,.07);
display: flex;
align-items: center;
gap: 0.75rem;
font-weight: 600;
">
<span style="font-size: 1.5rem;">🎮</span> Manage Games
</a>
<a href="{{ path('game_admin_sessions') }}" style="
background: #fff;
border-radius: 8px;
padding: 1.25rem;
text-decoration: none;
color: #1e293b;
box-shadow: 0 1px 3px rgba(0,0,0,.07);
display: flex;
align-items: center;
gap: 0.75rem;
font-weight: 600;
">
<span style="font-size: 1.5rem;">▶</span> View Sessions
</a>
<a href="{{ path('game_admin_email_log') }}" style="
background: #fff;
border-radius: 8px;
padding: 1.25rem;
text-decoration: none;
color: #1e293b;
box-shadow: 0 1px 3px rgba(0,0,0,.07);
display: flex;
align-items: center;
gap: 0.75rem;
font-weight: 600;
">
<span style="font-size: 1.5rem;">✉</span> Email Log
</a>
</div>
{% endblock %}