Skip to content

Commit

Permalink
Add AbstractApiCallAdmin::getOriginChoices for api call origin filter
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-ducrot committed Jun 4, 2024
1 parent 6985668 commit 74d79e1
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Admin/Monitoring/AbstractApiCallAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ protected function configureDefaultSortValues(array &$sortValues): void
protected function configureDatagridFilters(DatagridMapper $filter): void
{
$filter
->add('origin', null, [
->add('origin', ChoiceFilter::class, [
'label' => 'label.origin',
'show_filter' => true,
'field_type' => ChoiceType::class,
'field_options' => [
'choices' => $this->getOriginChoices(),
],
])
->add('status', ChoiceFilter::class, [
'label' => 'label.result',
Expand Down Expand Up @@ -82,7 +86,10 @@ protected function configureListFields(ListMapper $list): void
$list
->add('id', null, ['label' => 'field.label_id'])
->add('startedAt', null, ['label' => 'label.started_at'])
->add('origin', null, ['label' => 'label.origin'])
->add('origin', FieldDescriptionInterface::TYPE_CHOICE, [
'label' => 'label.origin',
'choices' => array_flip($this->getOriginChoices()),
])
->add('statusCode', null, [
'label' => 'label.result',
'template' => '@SmartSonata/admin/base_field/list_api_call_status_code.html.twig',
Expand All @@ -107,7 +114,6 @@ protected function configureShowFields(ShowMapper $show): void
->add('type', FieldDescriptionInterface::TYPE_CHOICE, [
'label' => 'label.route',
'choices' => array_flip($this->getRouteChoices()),
'choice_translation_domain' => 'admin',
])
->add('startedAt', null, ['label' => 'label.started_at'])
->add('endedAt', null, ['label' => 'label.ended_at'])
Expand All @@ -119,7 +125,10 @@ protected function configureShowFields(ShowMapper $show): void
->add('summary', null, ['label' => 'label.summary'])
->end()
->with('api_params', ['label' => 'label.api_params', 'class' => 'col-md-8'])
->add('origin', null, ['label' => 'label.origin'])
->add('origin', FieldDescriptionInterface::TYPE_CHOICE, [
'label' => 'label.origin',
'choices' => array_flip($this->getOriginChoices()),
])
->add('statusCode', null, [
'label' => 'label.result',
'template' => '@SmartSonata/admin/base_field/show_api_call_status_code.html.twig',
Expand Down Expand Up @@ -158,4 +167,6 @@ private function getStatusChoices(): array
}

abstract protected function getRouteChoices(): array;

abstract protected function getOriginChoices(): array;
}

0 comments on commit 74d79e1

Please sign in to comment.