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:
@@ -7,6 +7,7 @@ namespace App\Game\Controller;
|
|||||||
use App\Game\Entity\Session;
|
use App\Game\Entity\Session;
|
||||||
use App\Game\Enum\SessionStatus;
|
use App\Game\Enum\SessionStatus;
|
||||||
use App\Game\Repository\GameRepository;
|
use App\Game\Repository\GameRepository;
|
||||||
|
use App\Game\Repository\LobbyMessageRepository;
|
||||||
use App\Game\Repository\SessionRepository;
|
use App\Game\Repository\SessionRepository;
|
||||||
use App\Tech\Repository\UserRepository;
|
use App\Tech\Repository\UserRepository;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
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'])]
|
#[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 = [];
|
$playersLogs = [];
|
||||||
foreach ($session->getPlayers() as $player) {
|
foreach ($session->getPlayers() as $player) {
|
||||||
@@ -65,6 +66,7 @@ final class GameAdminController extends AbstractController
|
|||||||
return $this->render('game/admin/sessions/view.html.twig', [
|
return $this->render('game/admin/sessions/view.html.twig', [
|
||||||
'session' => $session,
|
'session' => $session,
|
||||||
'playersLogs' => $playersLogs,
|
'playersLogs' => $playersLogs,
|
||||||
|
'lobbyMessages' => $lobbyMessageRepository->findForSession($session),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,24 @@
|
|||||||
<h1 style="margin: 0 0 0.25rem; font-size: 1.5rem; color: #0f172a;">{{ session.game.name }} — Session #{{ session.id }}</h1>
|
<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>
|
<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 %}
|
{% 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);">
|
<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.
|
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;">
|
<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 %}
|
{% for playerLog in playersLogs %}
|
||||||
<button
|
<button
|
||||||
onclick="openTab('player-{{ loop.index }}')"
|
data-tab-target="player-{{ loop.index }}"
|
||||||
id="tab-{{ loop.index }}"
|
id="tab-{{ loop.index }}"
|
||||||
style="
|
style="
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
@@ -65,21 +83,4 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% 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 %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user