Show pregame lobby chat in admin session logs

Admins can now see the full lobby chat transcript (who said what,
when) at the top of a session's log view, alongside the existing
per-player terminal logs. Also swaps the log tabs' inline onclick
handler for a data attribute, in prep for moving the tab-switching
script out of the template.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Frank
2026-08-10 15:32:31 +02:00
co-authored by Claude Sonnet 5
parent 444f54b6c6
commit dfa75719d0
2 changed files with 22 additions and 19 deletions
+3 -1
View File
@@ -7,6 +7,7 @@ namespace App\Game\Controller;
use App\Game\Entity\Session;
use App\Game\Enum\SessionStatus;
use App\Game\Repository\GameRepository;
use App\Game\Repository\LobbyMessageRepository;
use App\Game\Repository\SessionRepository;
use App\Tech\Repository\UserRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -49,7 +50,7 @@ final class GameAdminController extends AbstractController
}
#[Route('/session/{session}', name: 'game_admin_view_session', methods: ['GET'])]
public function viewSession(Session $session): Response
public function viewSession(Session $session, LobbyMessageRepository $lobbyMessageRepository): Response
{
$playersLogs = [];
foreach ($session->getPlayers() as $player) {
@@ -65,6 +66,7 @@ final class GameAdminController extends AbstractController
return $this->render('game/admin/sessions/view.html.twig', [
'session' => $session,
'playersLogs' => $playersLogs,
'lobbyMessages' => $lobbyMessageRepository->findForSession($session),
]);
}
}
+19 -18
View File
@@ -10,6 +10,24 @@
<h1 style="margin: 0 0 0.25rem; font-size: 1.5rem; color: #0f172a;">{{ session.game.name }} — Session #{{ session.id }}</h1>
<p style="margin: 0 0 1.5rem; color: #64748b; font-size: 0.9rem;">{{ session.status.value }} · {{ session.players|length }} player(s) · Created {{ session.created|date('Y-m-d H:i') }}</p>
<div style="background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.07); padding: 1.25rem; margin-bottom: 1.5rem;">
<h2 style="margin: 0 0 1rem; font-size: 1.1rem; color: #0f172a;">Pregame lobby chat</h2>
{% if lobbyMessages is empty %}
<p style="margin: 0; color: #94a3b8;">No lobby chat messages for this session.</p>
{% else %}
<div style="max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.6rem;">
{% for message in lobbyMessages %}
<div style="font-size: 0.9rem;">
<strong style="color: #0f172a;">{{ message.player.user.username }}</strong>
<span style="color: #94a3b8; font-size: 0.8rem;">{{ message.createdAt|date('Y-m-d H:i') }}</span>
<div style="color: #334155;">{{ message.content }}</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
{% if playersLogs is empty %}
<div style="background: #fff; border-radius: 8px; padding: 2rem; text-align: center; color: #94a3b8; box-shadow: 0 1px 3px rgba(0,0,0,.07);">
No players in this session.
@@ -19,7 +37,7 @@
<div style="display: flex; gap: 0; margin-bottom: 0; border-bottom: 1px solid #e2e8f0; overflow-x: auto; -webkit-overflow-scrolling: touch;">
{% for playerLog in playersLogs %}
<button
onclick="openTab('player-{{ loop.index }}')"
data-tab-target="player-{{ loop.index }}"
id="tab-{{ loop.index }}"
style="
flex-shrink: 0;
@@ -65,21 +83,4 @@
</div>
{% endfor %}
{% endif %}
<script>
function openTab(id) {
document.querySelectorAll('[id^="player-"]').forEach(el => el.style.display = 'none');
document.getElementById(id).style.display = 'block';
const idx = id.split('-')[1];
document.querySelectorAll('[id^="tab-"]').forEach((btn, i) => {
const active = String(i + 1) === idx;
btn.style.background = active ? '#fff' : '#f8fafc';
btn.style.color = active ? '#1e40af' : '#64748b';
btn.style.fontWeight = active ? '600' : '400';
btn.style.borderColor = active ? '#3b82f6' : '#e2e8f0';
btn.style.borderBottom = active ? '1px solid #fff' : '1px solid #e2e8f0';
});
}
</script>
{% endblock %}