Add watchdogs filters
This commit is contained in:
@@ -679,10 +679,14 @@ class AdminController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/watchdog', name: 'watchdog')]
|
#[Route('/watchdog', name: 'watchdog')]
|
||||||
|
#[Route('/watchdog/{type}', name: 'watchdog_type')]
|
||||||
|
#[Route('/watchdog/{type}/{action}', name: 'watchdog_type_action')]
|
||||||
public function watchdog(
|
public function watchdog(
|
||||||
PaginatorInterface $paginator,
|
PaginatorInterface $paginator,
|
||||||
Request $Request,
|
Request $Request,
|
||||||
EntityManagerInterface $EntityManagerInterface
|
EntityManagerInterface $EntityManagerInterface,
|
||||||
|
string $type = null,
|
||||||
|
string $action = null
|
||||||
): Response {
|
): Response {
|
||||||
/**
|
/**
|
||||||
* @var LogEntryRepository $logEntryRepository
|
* @var LogEntryRepository $logEntryRepository
|
||||||
@@ -690,11 +694,30 @@ class AdminController extends AbstractController
|
|||||||
$logEntryRepository = $EntityManagerInterface->getRepository('Gedmo\Loggable\Entity\LogEntry');
|
$logEntryRepository = $EntityManagerInterface->getRepository('Gedmo\Loggable\Entity\LogEntry');
|
||||||
|
|
||||||
$qb = $EntityManagerInterface->createQueryBuilder();
|
$qb = $EntityManagerInterface->createQueryBuilder();
|
||||||
|
$qbButtons = $EntityManagerInterface->createQueryBuilder();
|
||||||
|
|
||||||
$qb->select('l')
|
$qb->select('l')
|
||||||
->from('Gedmo\Loggable\Entity\LogEntry', 'l')
|
->from('Gedmo\Loggable\Entity\LogEntry', 'l')
|
||||||
->orderBy('l.loggedAt', 'DESC');
|
->orderBy('l.loggedAt', 'DESC');
|
||||||
|
|
||||||
|
$qbButtons->select('DISTINCT l.objectClass')
|
||||||
|
->from('Gedmo\Loggable\Entity\LogEntry', 'l')
|
||||||
|
->orderBy('l.loggedAt', 'DESC');
|
||||||
|
|
||||||
|
if (null != $type) {
|
||||||
|
$qb->where('l.objectClass = :type');
|
||||||
|
$qb->setParameter('type', 'App\Entity\\' . $type);
|
||||||
|
$qbButtonsAction = $EntityManagerInterface->createQueryBuilder();
|
||||||
|
$qbButtonsAction->select('DISTINCT l.action')
|
||||||
|
->from('Gedmo\Loggable\Entity\LogEntry', 'l')
|
||||||
|
->orderBy('l.loggedAt', 'DESC');
|
||||||
|
|
||||||
|
if (null != $action) {
|
||||||
|
$qb->andWhere('l.action = :action');
|
||||||
|
$qb->setParameter('action', $action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$pagination = $paginator->paginate(
|
$pagination = $paginator->paginate(
|
||||||
$qb->getQuery()->getResult(),
|
$qb->getQuery()->getResult(),
|
||||||
$Request->query->getInt('page', 1)
|
$Request->query->getInt('page', 1)
|
||||||
@@ -702,7 +725,11 @@ class AdminController extends AbstractController
|
|||||||
|
|
||||||
return $this->render('admin/watchdog.html.twig', [
|
return $this->render('admin/watchdog.html.twig', [
|
||||||
'controller_name' => 'AdminController',
|
'controller_name' => 'AdminController',
|
||||||
'pagination' => $pagination
|
'pagination' => $pagination,
|
||||||
|
'buttonsType' => $qbButtons->getQuery()->getResult(),
|
||||||
|
'type' => $type,
|
||||||
|
'buttonsAction' => (($type != null) ? $qbButtonsAction->getQuery()->getResult() : null),
|
||||||
|
'action' => $action,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,26 @@
|
|||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col mb-5">
|
||||||
|
<h4>Filtres</h4>
|
||||||
|
<h5>Type: </h5>
|
||||||
|
<a href="{{ path('admin_watchdog') }}" class="btn btn-{{type == null ? 'info' : 'primary'}} m-1">*</a>
|
||||||
|
{% for t in buttonsType %}
|
||||||
|
{% set btntype = t.objectClass|replace({'App\\Entity\\': ''}) %}
|
||||||
|
<a href="{{ path('admin_watchdog_type',{type: btntype}) }}" class="btn btn-{{type == btntype ? 'info' : 'primary'}} m-1">{{ btntype }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if buttonsAction != null %}
|
||||||
|
<h5>Action: </h5>
|
||||||
|
<a href="{{ path('admin_watchdog_type',{type: type}) }}" class="btn btn-{{action == null ? 'info' : 'primary'}} m-1">*</a>
|
||||||
|
{% for a in buttonsAction %}
|
||||||
|
<a href="{{ path('admin_watchdog_type_action',{type: type, action: a.action }) }}" class="btn btn-{{action == a.action ? 'info' : 'primary'}} m-1">{{ a.action }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
{% include '_cells/historyDisplay.html.twig' with {'history': pagination} %}
|
{% include '_cells/historyDisplay.html.twig' with {'history': pagination} %}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"version": "0.2.7"
|
"version": "0.2.8"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user