From 56def014a6dcefe40d4fdf4381e923a6758444bf Mon Sep 17 00:00:00 2001 From: Mathieu Ducrot Date: Tue, 18 Jun 2024 18:28:43 +0200 Subject: [PATCH] Add API and Cron monitoring link in show_history_field.html.twig --- CHANGELOG.md | 5 ++++- src/Admin/Monitoring/AbstractApiCallAdmin.php | 1 + src/Admin/Monitoring/AbstractCronAdmin.php | 6 ++--- src/Twig/Extension/HistoryExtension.php | 1 - .../base_field/api_call_status_code.html.twig | 6 ++++- .../base_field/show_history_field.html.twig | 16 ++++++++++++-- translations/admin.en.xlf | 20 ----------------- translations/admin.fr.xlf | 22 +++---------------- translations/messages.en.xlf | 22 +++++++++++++++++++ translations/messages.fr.xlf | 22 +++++++++++++++++++ 10 files changed, 74 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ebf578..6c3379e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ CHANGELOG =================== -## v2.5.0 - (2024-06-18) +## v2.5.0 - (2024-06-19) ### Added - `show_history_field.html.twig` based on tailwind class + Twig `HistoryExtension` required to autocomplete some data of the history rows @@ -14,6 +14,9 @@ CHANGELOG his history. - You must add the `MailableInterface` to your User entity for `BaseMailer::setRecipientToEmail` to work properly - `BaseMailer::setRecipientToEmail` advanced scenario to init the **to**, **cc** and **bcc** of the email based on the recipient type +- **BC Break** `AbstractApiCallAdmin` and `AbstractCronAdmin` now use **messages** for `choice_translation_domain` for their **type** properties + - You must move your cron.my_command.label translations on the **messages.%lang%.%format%** file instead of using the **admin.%lang%.%format%** +- `api_call_status.html.twig` now display null status code as "Ongoing" placeholder text ### Flag as deprecated diff --git a/src/Admin/Monitoring/AbstractApiCallAdmin.php b/src/Admin/Monitoring/AbstractApiCallAdmin.php index d4ea3d6..d2a7af5 100644 --- a/src/Admin/Monitoring/AbstractApiCallAdmin.php +++ b/src/Admin/Monitoring/AbstractApiCallAdmin.php @@ -118,6 +118,7 @@ protected function configureShowFields(ShowMapper $show): void ->add('type', FieldDescriptionInterface::TYPE_CHOICE, [ 'label' => 'label.route', 'choices' => array_flip($this->getRouteChoices()), + 'choice_translation_domain' => 'messages', ]) ->add('startedAt', null, ['label' => 'label.started_at']) ->add('endedAt', null, ['label' => 'label.ended_at']) diff --git a/src/Admin/Monitoring/AbstractCronAdmin.php b/src/Admin/Monitoring/AbstractCronAdmin.php index 6b71b81..d12fa0f 100644 --- a/src/Admin/Monitoring/AbstractCronAdmin.php +++ b/src/Admin/Monitoring/AbstractCronAdmin.php @@ -46,7 +46,7 @@ protected function configureDatagridFilters(DatagridMapper $filter): void 'field_type' => ChoiceType::class, 'field_options' => [ 'choices' => $this->commandPoolHelper->getCronChoices(), - 'choice_translation_domain' => 'admin', + 'choice_translation_domain' => 'messages', ], ]) ->add('status', ChoiceFilter::class, [ @@ -77,7 +77,7 @@ protected function configureListFields(ListMapper $list): void ->addIdentifier('type', FieldDescriptionInterface::TYPE_CHOICE, [ 'label' => 'label.type', 'choices' => array_flip($this->commandPoolHelper->getCronChoices()), - 'choice_translation_domain' => 'admin', + 'choice_translation_domain' => 'messages', 'sortable' => false, ]) ->add('startedAt', null, ['label' => 'label.started_at']) @@ -101,7 +101,7 @@ protected function configureShowFields(ShowMapper $show): void ->add('type', FieldDescriptionInterface::TYPE_CHOICE, [ 'label' => 'label.type', 'choices' => array_flip($this->commandPoolHelper->getCronChoices()), - 'choice_translation_domain' => 'admin', + 'choice_translation_domain' => 'messages', ]) ->add('startedAt', null, ['label' => 'label.started_at']) ->add('endedAt', null, ['label' => 'label.ended_at']) diff --git a/src/Twig/Extension/HistoryExtension.php b/src/Twig/Extension/HistoryExtension.php index cf59588..3a19336 100644 --- a/src/Twig/Extension/HistoryExtension.php +++ b/src/Twig/Extension/HistoryExtension.php @@ -86,7 +86,6 @@ public function getRowTitle(array $row, string $domain = 'admin'): ?string switch ($row['code']) { case 'email.sent': case 'import': - case 'cron': $toReturn = $codeTitle . ($toReturn !== null ? (' : ' . $toReturn) : ''); break; case 'crt': diff --git a/templates/admin/base_field/api_call_status_code.html.twig b/templates/admin/base_field/api_call_status_code.html.twig index 9769a19..2ab16c7 100644 --- a/templates/admin/base_field/api_call_status_code.html.twig +++ b/templates/admin/base_field/api_call_status_code.html.twig @@ -12,7 +12,11 @@
- {{ value }} + {% if value is null %} + {{ 'enum.process_status.ongoing'|trans({}, 'messages') }} + {% else %} + {{ value }} + {% endif %} {% if object is defined and object.restartedAt is defined and object.restartedAt is not null %} - [{{ ('history.context.' ~ row.ctxt)|trans }}{% if row.orgn is defined %} : {{ row.orgn|trans }}{% endif %}] + [{{ ('history.context.' ~ row.ctxt)|trans }}{% if row.orgn is defined %} : {{ row.orgn|trans({}, 'messages') }}{% endif %}] {% endif %}
@@ -63,7 +63,7 @@
- {% if row.status_code is defined %} + {% if row.status_code is defined and row.status_code is not null %}
{% include '@SmartSonata/admin/base_field/api_call_status_code.html.twig' with {value: row.status_code} %}
@@ -88,6 +88,18 @@
+ {# Monitoring spécifique #} + {% if row.api_id is defined %} + + API #{{ row.api_id }} + + {% endif %} + {% if row.cron_id is defined %} + + Cron #{{ row.cron_id }} + + {% endif %} + {% if row.recipient is defined %}
Destinataire de l'email : {{ row.recipient }}
diff --git a/translations/admin.en.xlf b/translations/admin.en.xlf index 87fb5ee..df449ab 100644 --- a/translations/admin.en.xlf +++ b/translations/admin.en.xlf @@ -247,26 +247,6 @@ history.context.api API - - h.crt_f - Creation form - - - h.upd_f - Edit form - - - h.prf_f - My profile form - - - h.imp_f - Import form - - - h.arc_a - Archive action - label.by By diff --git a/translations/admin.fr.xlf b/translations/admin.fr.xlf index da73b49..f21841c 100644 --- a/translations/admin.fr.xlf +++ b/translations/admin.fr.xlf @@ -247,25 +247,9 @@ history.context.api API - - h.crt_f - Formulaire de création - - - h.upd_f - Formulaire d'édition - - - h.prf_f - Formulaire mon profil - - - h.imp_f - Formulaire d'import - - - h.arc_a - Action d'archivage + + history.context.cron + Cron label.by diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index bcff112..64d4feb 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -131,6 +131,28 @@ env_banner_message.unknown - Unknown environment + + + + h.crt_f + Creation form + + + h.upd_f + Edit form + + + h.prf_f + My profile form + + + h.imp_f + Import form + + + h.arc_a + Archive action + \ No newline at end of file diff --git a/translations/messages.fr.xlf b/translations/messages.fr.xlf index 53075a2..8ef376a 100644 --- a/translations/messages.fr.xlf +++ b/translations/messages.fr.xlf @@ -131,6 +131,28 @@ env_banner_message.unknown - Environnement inconnu + + + + h.crt_f + Formulaire de création + + + h.upd_f + Formulaire d'édition + + + h.prf_f + Formulaire mon profil + + + h.imp_f + Formulaire d'import + + + h.arc_a + Action d'archivage + \ No newline at end of file