Skip to content

Commit

Permalink
Add API and Cron monitoring link in show_history_field.html.twig
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-ducrot committed Jun 18, 2024
1 parent 9713822 commit 56def01
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 47 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/Admin/Monitoring/AbstractApiCallAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
6 changes: 3 additions & 3 deletions src/Admin/Monitoring/AbstractCronAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down Expand Up @@ -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'])
Expand All @@ -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'])
Expand Down
1 change: 0 additions & 1 deletion src/Twig/Extension/HistoryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
6 changes: 5 additions & 1 deletion templates/admin/base_field/api_call_status_code.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@

<div class="text-left">
<span class="label label-{{ status_class }}">
{{ value }}
{% if value is null %}
{{ 'enum.process_status.ongoing'|trans({}, 'messages') }}
{% else %}
{{ value }}
{% endif %}
</span>
{% if object is defined and object.restartedAt is defined and object.restartedAt is not null %}
<i
Expand Down
16 changes: 14 additions & 2 deletions templates/admin/base_field/show_history_field.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
{{ history_get_row_title(row) }}
{% if row.ctxt is defined %}
<span class="text-info">
[{{ ('history.context.' ~ row.ctxt)|trans }}{% if row.orgn is defined %}<span v-if="orgn"> : {{ row.orgn|trans }}</span>{% endif %}]
[{{ ('history.context.' ~ row.ctxt)|trans }}{% if row.orgn is defined %}<span v-if="orgn"> : {{ row.orgn|trans({}, 'messages') }}</span>{% endif %}]
</span>
{% endif %}
</div>
Expand All @@ -63,7 +63,7 @@
<!-- Partie droite : date + changement de status -->
<div class="grow">
<div class="text-gray-500 !text-xs !mb-0.5 flex justify-end">
{% if row.status_code is defined %}
{% if row.status_code is defined and row.status_code is not null %}
<div class="mr-2">
{% include '@SmartSonata/admin/base_field/api_call_status_code.html.twig' with {value: row.status_code} %}
</div>
Expand All @@ -88,6 +88,18 @@
</div>
</div>

{# Monitoring spécifique #}
{% if row.api_id is defined %}
<a href="{{ path('admin_app_monitoring_apicall_show', {id: row.api_id}) }}" target="_blank">
API #{{ row.api_id }}
</a>
{% endif %}
{% if row.cron_id is defined %}
<a href="{{ path('admin_app_monitoring_cron_show', {id: row.cron_id}) }}" target="_blank">
Cron #{{ row.cron_id }}
</a>
{% endif %}

<!-- Email spécifique -->
{% if row.recipient is defined %}
<div class="text-gray-500" ><b>Destinataire de l'email :&nbsp;</b>{{ row.recipient }}</div>
Expand Down
20 changes: 0 additions & 20 deletions translations/admin.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -247,26 +247,6 @@
<source>history.context.api</source>
<target>API</target>
</trans-unit>
<trans-unit id="h.crt_f">
<source>h.crt_f</source>
<target>Creation form</target>
</trans-unit>
<trans-unit id="h.upd_f">
<source>h.upd_f</source>
<target>Edit form</target>
</trans-unit>
<trans-unit id="h.prf_f">
<source>h.prf_f</source>
<target>My profile form</target>
</trans-unit>
<trans-unit id="h.imp_f">
<source>h.imp_f</source>
<target>Import form</target>
</trans-unit>
<trans-unit id="h.arc_a">
<source>h.arc_a</source>
<target>Archive action</target>
</trans-unit>
<trans-unit id="label.by">
<source>label.by</source>
<target>By</target>
Expand Down
22 changes: 3 additions & 19 deletions translations/admin.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -247,25 +247,9 @@
<source>history.context.api</source>
<target>API</target>
</trans-unit>
<trans-unit id="h.crt_f">
<source>h.crt_f</source>
<target>Formulaire de création</target>
</trans-unit>
<trans-unit id="h.upd_f">
<source>h.upd_f</source>
<target>Formulaire d'édition</target>
</trans-unit>
<trans-unit id="h.prf_f">
<source>h.prf_f</source>
<target>Formulaire mon profil</target>
</trans-unit>
<trans-unit id="h.imp_f">
<source>h.imp_f</source>
<target>Formulaire d'import</target>
</trans-unit>
<trans-unit id="h.arc_a">
<source>h.arc_a</source>
<target>Action d'archivage</target>
<trans-unit id="history.context.cron">
<source>history.context.cron</source>
<target>Cron</target>
</trans-unit>
<trans-unit id="label.by">
<source>label.by</source>
Expand Down
22 changes: 22 additions & 0 deletions translations/messages.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,28 @@
<source>env_banner_message.unknown</source>
<target> - Unknown environment</target>
</trans-unit>

<!-- History Origin short syntax -->
<trans-unit id="h.crt_f">
<source>h.crt_f</source>
<target>Creation form</target>
</trans-unit>
<trans-unit id="h.upd_f">
<source>h.upd_f</source>
<target>Edit form</target>
</trans-unit>
<trans-unit id="h.prf_f">
<source>h.prf_f</source>
<target>My profile form</target>
</trans-unit>
<trans-unit id="h.imp_f">
<source>h.imp_f</source>
<target>Import form</target>
</trans-unit>
<trans-unit id="h.arc_a">
<source>h.arc_a</source>
<target>Archive action</target>
</trans-unit>
</body>
</file>
</xliff>
22 changes: 22 additions & 0 deletions translations/messages.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,28 @@
<source>env_banner_message.unknown</source>
<target> - Environnement inconnu</target>
</trans-unit>

<!-- History Origin short syntax -->
<trans-unit id="h.crt_f">
<source>h.crt_f</source>
<target>Formulaire de création</target>
</trans-unit>
<trans-unit id="h.upd_f">
<source>h.upd_f</source>
<target>Formulaire d'édition</target>
</trans-unit>
<trans-unit id="h.prf_f">
<source>h.prf_f</source>
<target>Formulaire mon profil</target>
</trans-unit>
<trans-unit id="h.imp_f">
<source>h.imp_f</source>
<target>Formulaire d'import</target>
</trans-unit>
<trans-unit id="h.arc_a">
<source>h.arc_a</source>
<target>Action d'archivage</target>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit 56def01

Please sign in to comment.