Merge branch 'Xbird/WatchdogEnhancement' into 'main'

Watchdog display more usable

See merge request gamexperience/vision!41
This commit is contained in:
Xbird
2022-09-15 15:40:58 +00:00
6 changed files with 54 additions and 35 deletions

View File

@@ -678,23 +678,20 @@ class AdminController extends AbstractController
return $response; return $response;
} }
#[Route('/watchdog', name: 'watchdog')]
#[Route('/watchdog/{type}', name: 'watchdog_type')] #[Route('/watchdog/{type?*}/{id?*}/{action?*}', name: 'watchdog')]
#[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 $type = null,
string $action = null string $action = null,
string $id = null
): Response { ): Response {
/**
* @var LogEntryRepository $logEntryRepository
*/
$logEntryRepository = $EntityManagerInterface->getRepository('Gedmo\Loggable\Entity\LogEntry');
$qb = $EntityManagerInterface->createQueryBuilder(); $qb = $EntityManagerInterface->createQueryBuilder();
$qbButtons = $EntityManagerInterface->createQueryBuilder(); $qbButtons = $EntityManagerInterface->createQueryBuilder();
$qbButtonsAction = $EntityManagerInterface->createQueryBuilder();
$qb->select('l') $qb->select('l')
->from('Gedmo\Loggable\Entity\LogEntry', 'l') ->from('Gedmo\Loggable\Entity\LogEntry', 'l')
@@ -702,20 +699,27 @@ class AdminController extends AbstractController
$qbButtons->select('DISTINCT l.objectClass') $qbButtons->select('DISTINCT l.objectClass')
->from('Gedmo\Loggable\Entity\LogEntry', 'l') ->from('Gedmo\Loggable\Entity\LogEntry', 'l')
->orderBy('l.loggedAt', 'DESC'); ->orderBy('l.objectClass', 'ASC');
if (null != $type) {
$qb->where('l.objectClass = :type');
$qb->setParameter('type', 'App\Entity\\' . $type);
$qbButtonsAction = $EntityManagerInterface->createQueryBuilder();
$qbButtonsAction->select('DISTINCT l.action') $qbButtonsAction->select('DISTINCT l.action')
->from('Gedmo\Loggable\Entity\LogEntry', 'l') ->from('Gedmo\Loggable\Entity\LogEntry', 'l')
->orderBy('l.loggedAt', 'DESC'); ->orderBy('l.action', 'ASC');
if (null != $action) {
if (null != $type && '*' != $type) {
$qb->where('l.objectClass = :type');
$qb->setParameter('type', 'App\Entity\\' . $type);
}
if (null != $action && '*' != $action) {
$qb->andWhere('l.action = :action'); $qb->andWhere('l.action = :action');
$qb->setParameter('action', $action); $qb->setParameter('action', $action);
} }
if (null != $id && '*' != $id) {
$qb->andWhere('l.objectId = :id');
$qb->setParameter('id', $id);
} }
$pagination = $paginator->paginate( $pagination = $paginator->paginate(
@@ -725,11 +729,13 @@ 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,
'buttonsType' => $qbButtons->getQuery()->getResult(),
'type' => $type, 'type' => $type,
'buttonsAction' => (($type != null) ? $qbButtonsAction->getQuery()->getResult() : null),
'action' => $action, 'action' => $action,
'id' => $id,
'buttonsType' => $qbButtons->getQuery()->getResult(),
'buttonsAction' => $qbButtonsAction->getQuery()->getResult(),
'pagination' => $pagination,
]); ]);
} }

View File

@@ -11,7 +11,7 @@
{% endif %} {% endif %}
</p> </p>
{% if notype is not defined %} {% if notype is not defined %}
<p>{{ i.objectClass }} (# {{ i.objectId }})</p> <p>{{ i.objectClass }} (# {{ i.objectId }}) {% if is_granted('ROLE_ADMIN') %}<a href="{{ path('admin_watchdog', {'type':i.objectClass|replace({'App\\Entity\\': ''}), 'id': i.objectId}) }}" class="btn btn-warning btn-sm" data-bs-toggle="tooltip" data-placement="top" title="{% trans %}tooltip_directory_history{% endtrans %} (Admin)"><i class="fas fa-clock"></i></a>{% endif %}</p>
{% endif %} {% endif %}
<p>{{ ('title_data_' ~ i.action)|trans }}</p> <p>{{ ('title_data_' ~ i.action)|trans }}</p>
<div class="table-responsive"> <div class="table-responsive">

View File

@@ -7,30 +7,39 @@
<div class="row"> <div class="row">
<div class="col mb-5"> <div class="col mb-5">
<h4>Filtres</h4> <h4>{% trans %}title_filter{% endtrans %}</h4>
<h5>Type: </h5>
<a href="{{ path('admin_watchdog') }}" class="btn btn-{{type == null ? 'info' : 'primary'}} m-1">*</a> {% if id is null or id == '*' %}
<h5>{% trans %}title_type{% endtrans %}: </h5>
<a href="{{ path('admin_watchdog', {type:'*', id: id, action: action}) }}" class="btn btn-{{type == '*' ? 'info' : 'primary'}} m-1">*</a>
{% for t in buttonsType %} {% for t in buttonsType %}
{% set btntype = t.objectClass|replace({'App\\Entity\\': ''}) %} {% 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> <a href="{{ path('admin_watchdog',{type: btntype, id: id, action: action}) }}" class="btn btn-{{type == btntype ? 'info' : 'primary'}} m-1">{{ btntype }}</a>
{% endfor %} {% endfor %}
{% else %}
<a href="{{ path('admin_watchdog', {type: type, id: '*', action: action}) }}" class="btn btn-warning m-1">{% trans %}button_back{% endtrans %}</a>
{% endif %}
{% if buttonsAction != null %} {% if buttonsAction != null %}
<h5>Action: </h5> <h5>{% trans %}title_actions{% endtrans %}: </h5>
<a href="{{ path('admin_watchdog_type',{type: type}) }}" class="btn btn-{{action == null ? 'info' : 'primary'}} m-1">*</a> <a href="{{ path('admin_watchdog',{type: type, id: id, action: '*'}) }}" class="btn btn-{{action == '*' ? 'info' : 'primary'}} m-1">*</a>
{% for a in buttonsAction %} {% 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> <a href="{{ path('admin_watchdog',{type: type, id: id, action: a.action }) }}" class="btn btn-{{action == a.action ? 'info' : 'primary'}} m-1">{{ a.action }}</a>
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</div> </div>
</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} %}
</div> </div>
</div> </div>
<div class="row"> <div class="row">
{{ knp_pagination_render(pagination) }} {{ knp_pagination_render(pagination) }}
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -145,6 +145,7 @@ breadcrumb_view: View
button_add_comment: Add a comment button_add_comment: Add a comment
button_add_group: Add Group button_add_group: Add Group
button_add: Add button_add: Add
button_back: Back
button_cancel: Cancel button_cancel: Cancel
button_change_password: Change password button_change_password: Change password
button_create: Create button_create: Create
@@ -692,6 +693,7 @@ title_errorpage_error_message: This page seems to be malfunctioning, please cont
title_errorpage_error: Error title_errorpage_error: Error
title_faceImage: Face photo title_faceImage: Face photo
title_field: Fields title_field: Fields
title_filter: Filters
title_folder_add_directories: List of Directories for adding to a folder title_folder_add_directories: List of Directories for adding to a folder
title_folder_add_directory: Adding a directory to the folder title_folder_add_directory: Adding a directory to the folder
title_folder_add_documents: Adding a document to the folder title_folder_add_documents: Adding a document to the folder

View File

@@ -145,6 +145,7 @@ breadcrumb_view: Voir
button_add_comment: Ajouter un commentaire button_add_comment: Ajouter un commentaire
button_add_group: Créer un groupe button_add_group: Créer un groupe
button_add: Ajouter button_add: Ajouter
button_back: Retour
button_cancel: Annuler button_cancel: Annuler
button_change_password: Changer de mot de passe button_change_password: Changer de mot de passe
button_create: Créer button_create: Créer
@@ -691,6 +692,7 @@ title_errorpage_error_message: Cette page semble mal fonctionner, merci de conta
title_errorpage_error: Ouups ! title_errorpage_error: Ouups !
title_faceImage: Photo de Face title_faceImage: Photo de Face
title_field: Champs title_field: Champs
title_filter: Filtre
title_folder_add_directories: Liste des fiches pour ajout au dossier title_folder_add_directories: Liste des fiches pour ajout au dossier
title_folder_add_directory: Ajouter une fiche au dossier title_folder_add_directory: Ajouter une fiche au dossier
title_folder_add_documents: Ajouter un document au dossier title_folder_add_documents: Ajouter un document au dossier

View File

@@ -1,3 +1,3 @@
{ {
"version": "0.2.8" "version": "0.2.9"
} }