diff --git a/src/Controller/DashboardController.php b/src/Controller/DashboardController.php index b48f2d6..cd0c91b 100644 --- a/src/Controller/DashboardController.php +++ b/src/Controller/DashboardController.php @@ -8,6 +8,7 @@ use CodeRhapsodie\DataflowBundle\Entity\ScheduledDataflow; use CodeRhapsodie\DataflowBundle\ExceptionsHandler\ExceptionHandlerInterface; use CodeRhapsodie\DataflowBundle\ExceptionsHandler\NullExceptionHandler; +use CodeRhapsodie\DataflowBundle\Registry\DataflowTypeRegistryInterface; use CodeRhapsodie\IbexaDataflowBundle\CodeRhapsodieIbexaDataflowBundle; use CodeRhapsodie\IbexaDataflowBundle\Form\CreateOneshotType; use CodeRhapsodie\IbexaDataflowBundle\Form\CreateScheduledType; @@ -32,9 +33,9 @@ class DashboardController extends Controller public function __construct( private readonly JobGateway $jobGateway, private readonly ScheduledDataflowGateway $scheduledDataflowGateway, - private readonly ExceptionHandlerInterface $exceptionHandler - ) - { + private readonly ExceptionHandlerInterface $exceptionHandler, + private readonly DataflowTypeRegistryInterface $registry + ) { } #[Route(path: '/', name: 'coderhapsodie.ibexa_dataflow.main')] @@ -51,8 +52,8 @@ public function main(): Response return $this->render('@ibexadesign/ibexa_dataflow/Dashboard/main.html.twig', [ 'link' => 'https://www.code-rhapsodie.fr/product/redirect/'.str_replace('=', '', - base64_encode(json_encode($data)) - ), + base64_encode(json_encode($data)) + ), ]); } @@ -114,11 +115,22 @@ public function getOneshotPage(Request $request): Response public function getHistoryPage(Request $request): Response { $this->denyAccessUnlessGranted(new Attribute('ibexa_dataflow', 'view')); - $filter = (int) $request->query->get('filter', JobGateway::FILTER_NONE); + $statusFilter = (int) $request->query->get('status', JobGateway::FILTER_NONE); + $typeFilter = $request->query->get('type'); + + $typeChoices = [['value' => '', 'label' => 'all']]; + foreach ($this->registry->listDataflowTypes() as $type) { + $typeChoices[] = [ + 'value' => $type::class, + 'label' => $type->getLabel(), + ]; + } return $this->render('@ibexadesign/ibexa_dataflow/Dashboard/history.html.twig', [ - 'pager' => $this->getPager($this->jobGateway->getListQueryForAdmin($filter), $request, Job::class), - 'filter' => $filter, + 'pager' => $this->getPager($this->jobGateway->getListQueryForAdmin($statusFilter), $request, Job::class), + 'status' => $statusFilter, + 'type' => $typeFilter, + 'typeChoices' => $typeChoices, ]); } diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index 801c0ff..ed322e4 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -15,6 +15,7 @@ services: $jobGateway: '@CodeRhapsodie\IbexaDataflowBundle\Gateway\JobGateway' $scheduledDataflowGateway: '@CodeRhapsodie\IbexaDataflowBundle\Gateway\ScheduledDataflowGateway' $exceptionHandler: '@CodeRhapsodie\DataflowBundle\ExceptionsHandler\ExceptionHandlerInterface' + $registry: '@CodeRhapsodie\DataflowBundle\Registry\DataflowTypeRegistryInterface' CodeRhapsodie\IbexaDataflowBundle\Controller\ScheduledDataflowController: public: true diff --git a/src/Resources/views/themes/admin/ibexa_dataflow/Dashboard/history.html.twig b/src/Resources/views/themes/admin/ibexa_dataflow/Dashboard/history.html.twig index 15e6fb3..01d1c49 100644 --- a/src/Resources/views/themes/admin/ibexa_dataflow/Dashboard/history.html.twig +++ b/src/Resources/views/themes/admin/ibexa_dataflow/Dashboard/history.html.twig @@ -1,5 +1,5 @@ {%- block content -%} - {% set choices = [ + {% set statusChoices = [ { 'value': 0, 'label': 'coderhapsodie.ibexa_dataflow.history.filter.none'|trans, @@ -10,9 +10,18 @@ }, ] %} - {% set source %} - + {% for choice in statusChoices %} + + {% endfor %} + + {% endset %} + {% set typeSource %} +