From 26cfafcaadc962b96ba824318ec7cd9b4eae9dac Mon Sep 17 00:00:00 2001
From: Xbird
Date: Wed, 14 Sep 2022 18:33:21 +0200
Subject: [PATCH 1/6] add objectId on watchdog
---
src/Controller/AdminController.php | 14 ++++++++++++--
templates/_cells/historyDisplay.html.twig | 2 +-
visionversion.json | 2 +-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php
index 02d97ea..3b289d4 100644
--- a/src/Controller/AdminController.php
+++ b/src/Controller/AdminController.php
@@ -679,14 +679,16 @@ class AdminController extends AbstractController
}
#[Route('/watchdog', name: 'watchdog')]
+ #[Route('/watchdog/view/{id}', name: 'watchdog_view')]
#[Route('/watchdog/{type}', name: 'watchdog_type')]
- #[Route('/watchdog/{type}/{action}', name: 'watchdog_type_action')]
+ #[Route('/watchdog/{type}/{action}', name: 'watchdog_type_action')]
public function watchdog(
PaginatorInterface $paginator,
Request $Request,
EntityManagerInterface $EntityManagerInterface,
string $type = null,
- string $action = null
+ string $action = null,
+ int $id = null
): Response {
/**
* @var LogEntryRepository $logEntryRepository
@@ -704,6 +706,9 @@ class AdminController extends AbstractController
->from('Gedmo\Loggable\Entity\LogEntry', 'l')
->orderBy('l.loggedAt', 'DESC');
+
+
+
if (null != $type) {
$qb->where('l.objectClass = :type');
$qb->setParameter('type', 'App\Entity\\' . $type);
@@ -718,6 +723,11 @@ class AdminController extends AbstractController
}
}
+ if(null != $id){
+ $qb->where('l.objectId = :id');
+ $qb->setParameter('id', $id);
+ }
+
$pagination = $paginator->paginate(
$qb->getQuery()->getResult(),
$Request->query->getInt('page', 1)
diff --git a/templates/_cells/historyDisplay.html.twig b/templates/_cells/historyDisplay.html.twig
index 4cdd176..de4df31 100644
--- a/templates/_cells/historyDisplay.html.twig
+++ b/templates/_cells/historyDisplay.html.twig
@@ -11,7 +11,7 @@
{% endif %}
{% if notype is not defined %}
- {{ i.objectClass }} (# {{ i.objectId }})
+ {{ i.objectClass }} (# {{ i.objectId }}) {% if is_granted('ROLE_ADMIN') %}{% endif %}
{% endif %}
{{ ('title_data_' ~ i.action)|trans }}
diff --git a/visionversion.json b/visionversion.json
index 9379a31..ed58696 100644
--- a/visionversion.json
+++ b/visionversion.json
@@ -1,3 +1,3 @@
{
- "version": "0.2.8"
+ "version": "0.2.9"
}
From d82ec4bd255b542354dd657f04bcdcd1fff3952f Mon Sep 17 00:00:00 2001
From: Xbird
Date: Wed, 14 Sep 2022 18:33:34 +0200
Subject: [PATCH 2/6] PHPCBF
---
src/Controller/AdminController.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php
index 3b289d4..650c7d0 100644
--- a/src/Controller/AdminController.php
+++ b/src/Controller/AdminController.php
@@ -681,7 +681,7 @@ class AdminController extends AbstractController
#[Route('/watchdog', name: 'watchdog')]
#[Route('/watchdog/view/{id}', name: 'watchdog_view')]
#[Route('/watchdog/{type}', name: 'watchdog_type')]
- #[Route('/watchdog/{type}/{action}', name: 'watchdog_type_action')]
+ #[Route('/watchdog/{type}/{action}', name: 'watchdog_type_action')]
public function watchdog(
PaginatorInterface $paginator,
Request $Request,
@@ -706,7 +706,7 @@ class AdminController extends AbstractController
->from('Gedmo\Loggable\Entity\LogEntry', 'l')
->orderBy('l.loggedAt', 'DESC');
-
+
if (null != $type) {
@@ -723,7 +723,7 @@ class AdminController extends AbstractController
}
}
- if(null != $id){
+ if (null != $id) {
$qb->where('l.objectId = :id');
$qb->setParameter('id', $id);
}
From 2c76f0fd894d63422ff34931842917a60dd2e110 Mon Sep 17 00:00:00 2001
From: Xbird
Date: Thu, 15 Sep 2022 16:20:26 +0200
Subject: [PATCH 3/6] working
---
src/Controller/AdminController.php | 9 +++------
templates/_cells/historyDisplay.html.twig | 2 +-
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php
index 650c7d0..5bd8928 100644
--- a/src/Controller/AdminController.php
+++ b/src/Controller/AdminController.php
@@ -677,9 +677,10 @@ class AdminController extends AbstractController
return $response;
}
+
#[Route('/watchdog', name: 'watchdog')]
- #[Route('/watchdog/view/{id}', name: 'watchdog_view')]
+ #[Route('/watchdog/view/{type}/{id}/{action}', name: 'watchdog_view')]
#[Route('/watchdog/{type}', name: 'watchdog_type')]
#[Route('/watchdog/{type}/{action}', name: 'watchdog_type_action')]
public function watchdog(
@@ -690,10 +691,6 @@ class AdminController extends AbstractController
string $action = null,
int $id = null
): Response {
- /**
- * @var LogEntryRepository $logEntryRepository
- */
- $logEntryRepository = $EntityManagerInterface->getRepository('Gedmo\Loggable\Entity\LogEntry');
$qb = $EntityManagerInterface->createQueryBuilder();
$qbButtons = $EntityManagerInterface->createQueryBuilder();
@@ -724,7 +721,7 @@ class AdminController extends AbstractController
}
if (null != $id) {
- $qb->where('l.objectId = :id');
+ $qb->andWhere('l.objectId = :id');
$qb->setParameter('id', $id);
}
diff --git a/templates/_cells/historyDisplay.html.twig b/templates/_cells/historyDisplay.html.twig
index de4df31..e348a09 100644
--- a/templates/_cells/historyDisplay.html.twig
+++ b/templates/_cells/historyDisplay.html.twig
@@ -11,7 +11,7 @@
{% endif %}
{% if notype is not defined %}
- {{ i.objectClass }} (# {{ i.objectId }}) {% if is_granted('ROLE_ADMIN') %}{% endif %}
+ {{ i.objectClass }} (# {{ i.objectId }}) {% if is_granted('ROLE_ADMIN') %}{% endif %}
{% endif %}
{{ ('title_data_' ~ i.action)|trans }}
From 95462fafba7c0cab947ebf3b1ec6866dca804c9b Mon Sep 17 00:00:00 2001
From: Xbird
Date: Thu, 15 Sep 2022 17:30:31 +0200
Subject: [PATCH 4/6] remork watchdogs filter and logic
---
src/Controller/AdminController.php | 49 +++++++++++------------
templates/_cells/historyDisplay.html.twig | 2 +-
templates/admin/watchdog.html.twig | 29 +++++++++-----
3 files changed, 44 insertions(+), 36 deletions(-)
diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php
index 5bd8928..c4db8c9 100644
--- a/src/Controller/AdminController.php
+++ b/src/Controller/AdminController.php
@@ -679,48 +679,45 @@ class AdminController extends AbstractController
}
- #[Route('/watchdog', name: 'watchdog')]
- #[Route('/watchdog/view/{type}/{id}/{action}', name: 'watchdog_view')]
- #[Route('/watchdog/{type}', name: 'watchdog_type')]
- #[Route('/watchdog/{type}/{action}', name: 'watchdog_type_action')]
+ #[Route('/watchdog/{type?*}/{id?*}/{action?*}', name: 'watchdog')]
public function watchdog(
PaginatorInterface $paginator,
Request $Request,
EntityManagerInterface $EntityManagerInterface,
string $type = null,
string $action = null,
- int $id = null
+ string $id = null
): Response {
$qb = $EntityManagerInterface->createQueryBuilder();
$qbButtons = $EntityManagerInterface->createQueryBuilder();
+ $qbButtonsAction = $EntityManagerInterface->createQueryBuilder();
$qb->select('l')
->from('Gedmo\Loggable\Entity\LogEntry', 'l')
->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');
+ ->orderBy('l.objectClass', 'ASC');
+
+ $qbButtonsAction->select('DISTINCT l.action')
+ ->from('Gedmo\Loggable\Entity\LogEntry', 'l')
+ ->orderBy('l.action', 'ASC');
- if (null != $action) {
- $qb->andWhere('l.action = :action');
- $qb->setParameter('action', $action);
- }
+
+
+ if (null != $type && '*' != $type) {
+ $qb->where('l.objectClass = :type');
+ $qb->setParameter('type', 'App\Entity\\' . $type);
}
- if (null != $id) {
+ if (null != $action && '*' != $action) {
+ $qb->andWhere('l.action = :action');
+ $qb->setParameter('action', $action);
+ }
+
+ if (null != $id && '*' != $id) {
$qb->andWhere('l.objectId = :id');
$qb->setParameter('id', $id);
}
@@ -732,11 +729,13 @@ class AdminController extends AbstractController
return $this->render('admin/watchdog.html.twig', [
'controller_name' => 'AdminController',
- 'pagination' => $pagination,
- 'buttonsType' => $qbButtons->getQuery()->getResult(),
'type' => $type,
- 'buttonsAction' => (($type != null) ? $qbButtonsAction->getQuery()->getResult() : null),
'action' => $action,
+ 'id' => $id,
+ 'buttonsType' => $qbButtons->getQuery()->getResult(),
+ 'buttonsAction' => $qbButtonsAction->getQuery()->getResult(),
+ 'pagination' => $pagination,
+
]);
}
diff --git a/templates/_cells/historyDisplay.html.twig b/templates/_cells/historyDisplay.html.twig
index e348a09..9d3c818 100644
--- a/templates/_cells/historyDisplay.html.twig
+++ b/templates/_cells/historyDisplay.html.twig
@@ -11,7 +11,7 @@
{% endif %}
{% if notype is not defined %}
- {{ i.objectClass }} (# {{ i.objectId }}) {% if is_granted('ROLE_ADMIN') %}{% endif %}
+ {{ i.objectClass }} (# {{ i.objectId }}) {% if is_granted('ROLE_ADMIN') %}{% endif %}
{% endif %}
{{ ('title_data_' ~ i.action)|trans }}
diff --git a/templates/admin/watchdog.html.twig b/templates/admin/watchdog.html.twig
index 3fa2e68..11778a8 100644
--- a/templates/admin/watchdog.html.twig
+++ b/templates/admin/watchdog.html.twig
@@ -7,30 +7,39 @@
-
Filtres
-
Type:
-
*
- {% for t in buttonsType %}
- {% set btntype = t.objectClass|replace({'App\\Entity\\': ''}) %}
-
{{ btntype }}
- {% endfor %}
+
Filtres
+
+ {% if id is null or id == '*' %}
+
Type:
+
*
+ {% for t in buttonsType %}
+ {% set btntype = t.objectClass|replace({'App\\Entity\\': ''}) %}
+
{{ btntype }}
+ {% endfor %}
+
+ {% else %}
+
back to list
+ {% endif %}
{% if buttonsAction != null %}
Action:
-
*
+
*
{% for a in buttonsAction %}
-
{{ a.action }}
+
{{ a.action }}
{% endfor %}
{% endif %}
+
{% include '_cells/historyDisplay.html.twig' with {'history': pagination} %}
+
{{ knp_pagination_render(pagination) }}
-
+
+
{% endblock %}
From 38a37601448d69b84702f71b54db3bc5ade59018 Mon Sep 17 00:00:00 2001
From: Xbird
Date: Thu, 15 Sep 2022 17:34:14 +0200
Subject: [PATCH 5/6] add translations
---
templates/admin/watchdog.html.twig | 8 ++++----
translations/messages+intl-icu.en.yaml | 2 ++
translations/messages+intl-icu.fr.yaml | 2 ++
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/templates/admin/watchdog.html.twig b/templates/admin/watchdog.html.twig
index 11778a8..21025e1 100644
--- a/templates/admin/watchdog.html.twig
+++ b/templates/admin/watchdog.html.twig
@@ -7,10 +7,10 @@
-
Filtres
+
{% trans %}title_filter{% endtrans %}
{% if id is null or id == '*' %}
-
Type:
+
{% trans %}title_type{% endtrans %}:
*
{% for t in buttonsType %}
{% set btntype = t.objectClass|replace({'App\\Entity\\': ''}) %}
@@ -18,12 +18,12 @@
{% endfor %}
{% else %}
-
back to list
+
{% trans %}button_back{% endtrans %}
{% endif %}
{% if buttonsAction != null %}
-
Action:
+
{% trans %}title_actions{% endtrans %}:
*
{% for a in buttonsAction %}
{{ a.action }}
diff --git a/translations/messages+intl-icu.en.yaml b/translations/messages+intl-icu.en.yaml
index 39861e0..dc44d94 100644
--- a/translations/messages+intl-icu.en.yaml
+++ b/translations/messages+intl-icu.en.yaml
@@ -145,6 +145,7 @@ breadcrumb_view: View
button_add_comment: Add a comment
button_add_group: Add Group
button_add: Add
+button_back: Back
button_cancel: Cancel
button_change_password: Change password
button_create: Create
@@ -692,6 +693,7 @@ title_errorpage_error_message: This page seems to be malfunctioning, please cont
title_errorpage_error: Error
title_faceImage: Face photo
title_field: Fields
+title_filter: Filters
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_documents: Adding a document to the folder
diff --git a/translations/messages+intl-icu.fr.yaml b/translations/messages+intl-icu.fr.yaml
index 5f92705..f8ca39a 100644
--- a/translations/messages+intl-icu.fr.yaml
+++ b/translations/messages+intl-icu.fr.yaml
@@ -145,6 +145,7 @@ breadcrumb_view: Voir
button_add_comment: Ajouter un commentaire
button_add_group: Créer un groupe
button_add: Ajouter
+button_back: Retour
button_cancel: Annuler
button_change_password: Changer de mot de passe
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_faceImage: Photo de Face
title_field: Champs
+title_filter: Filtre
title_folder_add_directories: Liste des fiches pour ajout au dossier
title_folder_add_directory: Ajouter une fiche au dossier
title_folder_add_documents: Ajouter un document au dossier
From b048a34233c22ab6d1460e8b23ebff5839fedcab Mon Sep 17 00:00:00 2001
From: Xbird
Date: Thu, 15 Sep 2022 17:34:59 +0200
Subject: [PATCH 6/6] PHPCBF
---
src/Controller/AdminController.php | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php
index c4db8c9..f89a57f 100644
--- a/src/Controller/AdminController.php
+++ b/src/Controller/AdminController.php
@@ -677,7 +677,7 @@ class AdminController extends AbstractController
return $response;
}
-
+
#[Route('/watchdog/{type?*}/{id?*}/{action?*}', name: 'watchdog')]
public function watchdog(
@@ -700,7 +700,7 @@ class AdminController extends AbstractController
$qbButtons->select('DISTINCT l.objectClass')
->from('Gedmo\Loggable\Entity\LogEntry', 'l')
->orderBy('l.objectClass', 'ASC');
-
+
$qbButtonsAction->select('DISTINCT l.action')
->from('Gedmo\Loggable\Entity\LogEntry', 'l')
->orderBy('l.action', 'ASC');
@@ -709,7 +709,7 @@ class AdminController extends AbstractController
if (null != $type && '*' != $type) {
$qb->where('l.objectClass = :type');
- $qb->setParameter('type', 'App\Entity\\' . $type);
+ $qb->setParameter('type', 'App\Entity\\' . $type);
}
if (null != $action && '*' != $action) {
@@ -732,10 +732,10 @@ class AdminController extends AbstractController
'type' => $type,
'action' => $action,
'id' => $id,
- 'buttonsType' => $qbButtons->getQuery()->getResult(),
+ 'buttonsType' => $qbButtons->getQuery()->getResult(),
'buttonsAction' => $qbButtonsAction->getQuery()->getResult(),
'pagination' => $pagination,
-
+
]);
}