Skip to content

Commit

Permalink
feat: limit number of queued messages shown (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond authored Nov 12, 2024
1 parent 4ab2576 commit ac04193
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Controller/MessengerMonitorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function detail(string $id, ViewHelper $helper): Response
#[Route('/transport/{name}', name: 'zenstruck_messenger_monitor_transport', defaults: ['name' => null])]
public function transports(
ViewHelper $helper,

Request $request,
?string $name = null,
): Response {
$countable = $helper->transports->filter()->countable();
Expand All @@ -145,6 +145,7 @@ public function transports(
'helper' => $helper,
'transports' => $countable,
'transport' => $helper->transports->get($name),
'limit' => $request->query->getInt('limit', 50),
]);
}

Expand Down
13 changes: 12 additions & 1 deletion templates/transport.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@
</div>
</div>
{% else %}
{% set queuedMessages = transport.list(limit) %}

{% if queuedMessages|length == limit %}
<div class="card-alert card-text alert alert-warning d-flex align-items-center" role="alert">
<svg fill="currentcolor" height="1em" width="1em" class="me-1 align-text-bottom" role="img" aria-label="Info:"><use xlink:href="#info-fill"/></svg>
<div>
Only showing the oldest {{ limit }} messages.
</div>
</div>
{% endif %}

<div class="table-responsive">
<table class="table card-table table-striped text-nowrap align-middle">
<thead>
Expand All @@ -63,7 +74,7 @@
</tr>
</thead>
<tbody>
{% for queued in transport.list %}
{% for queued in queuedMessages %}
<tr>
<td>
<abbr title="{{ queued.message }}">{{ queued.message.shortName }}</abbr>
Expand Down

0 comments on commit ac04193

Please sign in to comment.