Created a dashboard and created an invite code for game sessions.
This commit is contained in:
74
templates/game/dashboard.html.twig
Normal file
74
templates/game/dashboard.html.twig
Normal file
@@ -0,0 +1,74 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Game Dashboard{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Game Dashboard</h1>
|
||||
|
||||
<h2>Create New Session</h2>
|
||||
{% if availableGames is not empty %}
|
||||
<form method="post">
|
||||
<select name="game_id">
|
||||
{% for game in availableGames %}
|
||||
<option value="{{ game.id }}">
|
||||
{{ game.name }} ({{ game.numberOfPlayers }} players)
|
||||
{% if is_granted('ROLE_ADMIN') %}
|
||||
[{{ game.status.value }}]
|
||||
{% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button type="submit" name="create_session">Create Session</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<p>No games available to start.</p>
|
||||
{% endif %}
|
||||
|
||||
<h2>Your Sessions</h2>
|
||||
{% if sessions is not empty %}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Game</th>
|
||||
<th>Status</th>
|
||||
<th>Created At</th>
|
||||
<th>Invite Code</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>{{ session.created|date('Y-m-d H:i') }}</td>
|
||||
<td>
|
||||
{% set inviteCode = '' %}
|
||||
{% for setting in session.settings %}
|
||||
{% if setting.name.value == 'InviteCode' %}
|
||||
{% set inviteCode = setting.value %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if inviteCode %}
|
||||
<code>{{ inviteCode }}</code>
|
||||
{% else %}
|
||||
<form method="post" style="display:inline;">
|
||||
<input type="hidden" name="session_id" value="{{ session.id }}">
|
||||
<button type="submit" name="create_invite">Generate Invite</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ path('game', {session: session.id}) }}">Enter Game</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>You are not part of any sessions.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user