From 94471363ab5fe9a7e889f8337d6c0ca6f2a29ec5 Mon Sep 17 00:00:00 2001 From: "j.guyon" Date: Tue, 18 Dec 2018 15:54:52 +0100 Subject: [PATCH 1/2] EasyAdmin config template in doc and adapt some translations --- Controller/ListController.php | 19 ++++++-- Form/Type/ScheduledCommandType.php | 2 +- README.md | 1 + Resources/doc/index.md | 43 +++++++++++++++++++ .../translations/JMoseCommandScheduler.de.xlf | 31 ++++++++++++- .../translations/JMoseCommandScheduler.en.xlf | 34 +++++++++++++-- .../translations/JMoseCommandScheduler.es.xlf | 31 ++++++++++++- .../translations/JMoseCommandScheduler.fr.xlf | 31 ++++++++++++- .../JMoseCommandScheduler.pt-br.xlf | 31 ++++++++++++- 9 files changed, 211 insertions(+), 12 deletions(-) diff --git a/Controller/ListController.php b/Controller/ListController.php index a4e583d1..63356974 100644 --- a/Controller/ListController.php +++ b/Controller/ListController.php @@ -4,6 +4,7 @@ use JMose\CommandSchedulerBundle\Entity\ScheduledCommand; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; /** @@ -77,9 +78,10 @@ public function toggleAction($id) /** * @param $id - * @return \Symfony\Component\HttpFoundation\Response + * @param Request $request + * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function executeAction($id) + public function executeAction($id, Request $request) { $entityManager = $this->getDoctrineManager(); $scheduledCommand = $entityManager->getRepository(ScheduledCommand::class)->find($id); @@ -90,14 +92,19 @@ public function executeAction($id) $this->get('session')->getFlashBag() ->add('success', $this->translator->trans('flash.execute', [], 'JMoseCommandScheduler')); + if ($request->query->has('referer')) { + return $this->redirect($request->getSchemeAndHttpHost().urldecode($request->query->get('referer'))); + } + return $this->redirect($this->generateUrl('jmose_command_scheduler_list')); } /** * @param $id - * @return \Symfony\Component\HttpFoundation\Response + * @param Request $request + * @return \Symfony\Component\HttpFoundation\RedirectResponse */ - public function unlockAction($id) + public function unlockAction($id, Request $request) { $entityManager = $this->getDoctrineManager(); $scheduledCommand = $entityManager->getRepository(ScheduledCommand::class)->find($id); @@ -108,6 +115,10 @@ public function unlockAction($id) $this->get('session')->getFlashBag() ->add('success', $this->translator->trans('flash.unlocked', [], 'JMoseCommandScheduler')); + if ($request->query->has('referer')) { + return $this->redirect($request->getSchemeAndHttpHost().urldecode($request->query->get('referer'))); + } + return $this->redirect($this->generateUrl('jmose_command_scheduler_list')); } diff --git a/Form/Type/ScheduledCommandType.php b/Form/Type/ScheduledCommandType.php index 999b2a32..3fbbc236 100644 --- a/Form/Type/ScheduledCommandType.php +++ b/Form/Type/ScheduledCommandType.php @@ -105,7 +105,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'save', SubmitType::class, [ - 'label' => 'detail.save', + 'label' => 'action.save', ] ); diff --git a/README.md b/README.md index 9ce04e92..dc4eb9d1 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ To use it, you have to enable contrib recipes on your project : `composer config - Locking system, to stop scheduling a command that has returned an error - Monitoring with timeout or failed commands (Json URL and command with mailing) - Translated in french, english, german and spanish +- An [EasyAdmin](https://github.com/EasyCorp/EasyAdminBundle) configuration template available [here](Resources/doc/index.md#6---easyadmin-integration) ## Screenshots ![list](Resources/doc/images/scheduled-list.png) diff --git a/Resources/doc/index.md b/Resources/doc/index.md index 5e342869..07d43053 100644 --- a/Resources/doc/index.md +++ b/Resources/doc/index.md @@ -142,6 +142,49 @@ This can easily be done by using standard overrides in Symfony, as described [he In your project, you'll want to copy the `Navbar:navbar:html.twig` template into `app/Resources/JMoseCommandSchedulerBundle/views/Navbar/navbar.html.twig`. Any changes to the file in this location will take precedence over the bundle's template file. +### 6 - EasyAdmin integration + +If you want to manage your scheduled commands via [EasyAdmin](https://github.com/EasyCorp/EasyAdminBundle) here is a configuration template that you can copy/paste and change to your needs. + +```yaml +easy_admin: + entities: + Cron: + translation_domain: 'JMoseCommandScheduler' + label: 'list.title' + class: JMose\CommandSchedulerBundle\Entity\ScheduledCommand + list: + title: "list.title" + fields: + - { property: 'id', label: 'ID' } + - { property: 'name', label: 'detail.name' } + - { property: 'command', label: 'detail.command' } + - { property: 'arguments', label: 'detail.arguments' } + - { property: 'lastExecution', label: 'detail.lastExecution' } + - { property: 'lastReturncode', label: 'detail.lastReturnCode' } + - { property: 'locked', label: 'detail.locked', type: boolean} + - { property: 'priority', label: 'detail.priority' } + - { property: 'disabled', label: 'detail.disabled' } + form_filters: + - disabled + - locked + actions: + - { name: 'jmose_command_scheduler_action_execute', type: 'route', label: 'action.execute' } + - { name: 'jmose_command_scheduler_action_unlock', type: 'route', label: 'action.unlock' } + form: + fields: + - { property: 'name', label: 'detail.name' } + - { property: 'command', label: 'detail.command', type: 'JMose\CommandSchedulerBundle\Form\Type\CommandChoiceType' } + - { property: 'arguments', label: 'detail.arguments' } + - { property: 'cronExpression', label: 'detail.cronExpression' } + - { property: 'priority', label: 'detail.priority' } + - { property: 'disabled', label: 'detail.disabled' } + - { property: 'logFile', label: 'detail.logFile' } + new: + fields: + - { property: 'executeImmediately', label: 'detail.executeImmediately' } +``` + Usage ============ diff --git a/Resources/translations/JMoseCommandScheduler.de.xlf b/Resources/translations/JMoseCommandScheduler.de.xlf index 541a711f..a9ce4141 100644 --- a/Resources/translations/JMoseCommandScheduler.de.xlf +++ b/Resources/translations/JMoseCommandScheduler.de.xlf @@ -52,6 +52,18 @@ confirm.unlock Die Aufgabe könnte gerade ausgeführt werden. Möchtest du sie wirklich entsperren? + + action.search + Suche + + + action.list + Zurück zur Liste + + + action.cancel + Stornieren + @@ -92,7 +104,7 @@ Deaktivieren - detail.save + action.save Speichern @@ -107,6 +119,10 @@ detail.actions Aktionen + + detail.locked + Verschlossen + @@ -126,6 +142,19 @@ Aufgabe erfolgreich entsperrt. + + + label.null + Null + + + label.true + True + + + label.false + False + diff --git a/Resources/translations/JMoseCommandScheduler.en.xlf b/Resources/translations/JMoseCommandScheduler.en.xlf index 960a9126..dfef761c 100644 --- a/Resources/translations/JMoseCommandScheduler.en.xlf +++ b/Resources/translations/JMoseCommandScheduler.en.xlf @@ -52,13 +52,24 @@ confirm.unlock The task may be running. Are you sure you want to unlock it ? + + action.search + Search + + + action.list + Back to list + + + action.cancel + Cancel + detail.title Scheduled command - detail.name Name @@ -89,10 +100,10 @@ detail.disabled - Disable + Disabled - detail.save + action.save Save @@ -107,6 +118,10 @@ detail.actions Actions + + detail.locked + Locked + @@ -126,6 +141,19 @@ Scheduling successfully unlocked. + + + label.null + Null + + + label.true + True + + + label.false + False + \ No newline at end of file diff --git a/Resources/translations/JMoseCommandScheduler.es.xlf b/Resources/translations/JMoseCommandScheduler.es.xlf index b8fe39da..55f5334d 100644 --- a/Resources/translations/JMoseCommandScheduler.es.xlf +++ b/Resources/translations/JMoseCommandScheduler.es.xlf @@ -52,6 +52,18 @@ confirm.unlock La tarea puede estar corriendo ¿Está seguro que desea desbloquearla? + + action.search + Buscar + + + action.list + Volver a la lista + + + action.cancel + Cancelar + @@ -92,7 +104,7 @@ Deshabilitar - detail.save + action.save Guardar @@ -107,6 +119,10 @@ detail.actions Acciones + + detail.locked + Bloqueado + @@ -126,6 +142,19 @@ Tarea desbloqueada exitosamente. + + + label.null + Null + + + label.true + True + + + label.false + False + diff --git a/Resources/translations/JMoseCommandScheduler.fr.xlf b/Resources/translations/JMoseCommandScheduler.fr.xlf index cffc06f0..fed8f955 100644 --- a/Resources/translations/JMoseCommandScheduler.fr.xlf +++ b/Resources/translations/JMoseCommandScheduler.fr.xlf @@ -50,6 +50,18 @@ confirm.unlock Le traitement est peut-être en cours d'exécution. Etes-vous sur de vouloir le déverrouiller ? + + action.search + Rechercher + + + action.list + Retour à la liste + + + action.cancel + Annuler + @@ -89,7 +101,7 @@ Désactiver - detail.save + action.save Enregistrer @@ -104,6 +116,10 @@ detail.actions Actions + + detail.locked + Verrouillé + @@ -123,6 +139,19 @@ Traitement déverrouillé avec succès. + + + label.null + Aucun + + + label.true + Oui + + + label.false + Non + diff --git a/Resources/translations/JMoseCommandScheduler.pt-br.xlf b/Resources/translations/JMoseCommandScheduler.pt-br.xlf index 682e9532..86d8341a 100644 --- a/Resources/translations/JMoseCommandScheduler.pt-br.xlf +++ b/Resources/translations/JMoseCommandScheduler.pt-br.xlf @@ -52,6 +52,18 @@ confirm.unlock Esta tarefa pode estar em execução. Tem certeza que deseja desbloqueá-la ? + + action.search + Procurar + + + action.list + De volta à lista + + + action.cancel + Cancelar + @@ -92,7 +104,7 @@ Desabilitar - detail.save + action.save Salvar @@ -107,6 +119,10 @@ detail.actions Ações + + detail.locked + Bloqueado + @@ -126,6 +142,19 @@ Agendamento desbloqueado com sucesso. + + + label.null + Null + + + label.true + True + + + label.false + False + From 94b4e7c35feddd76954a5d0f0fa4ffbc5e48e097 Mon Sep 17 00:00:00 2001 From: "j.guyon" Date: Tue, 18 Dec 2018 16:14:37 +0100 Subject: [PATCH 2/2] EasyAdmin config template in doc and adapt some translations --- Resources/doc/index.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/Resources/doc/index.md b/Resources/doc/index.md index 07d43053..ae7c8ba8 100644 --- a/Resources/doc/index.md +++ b/Resources/doc/index.md @@ -165,9 +165,6 @@ easy_admin: - { property: 'locked', label: 'detail.locked', type: boolean} - { property: 'priority', label: 'detail.priority' } - { property: 'disabled', label: 'detail.disabled' } - form_filters: - - disabled - - locked actions: - { name: 'jmose_command_scheduler_action_execute', type: 'route', label: 'action.execute' } - { name: 'jmose_command_scheduler_action_unlock', type: 'route', label: 'action.unlock' }