Skip to content

Commit

Permalink
Merge pull request #123 from J-Mose/easy_admin
Browse files Browse the repository at this point in the history
EasyAdmin Configuration template and some adaptations
  • Loading branch information
j-guyon authored Dec 18, 2018
2 parents 1ac9c4e + 94b4e7c commit c5ce339
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 12 deletions.
19 changes: 15 additions & 4 deletions Controller/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use JMose\CommandSchedulerBundle\Entity\ScheduledCommand;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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'));
}

Expand Down
2 changes: 1 addition & 1 deletion Form/Type/ScheduledCommandType.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'save',
SubmitType::class,
[
'label' => 'detail.save',
'label' => 'action.save',
]
);

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
40 changes: 40 additions & 0 deletions Resources/doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,46 @@ 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' }
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
============

Expand Down
31 changes: 30 additions & 1 deletion Resources/translations/JMoseCommandScheduler.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@
<source>confirm.unlock</source>
<target>Die Aufgabe könnte gerade ausgeführt werden. Möchtest du sie wirklich entsperren?</target>
</trans-unit>
<trans-unit id="108">
<source>action.search</source>
<target>Suche</target>
</trans-unit>
<trans-unit id="109">
<source>action.list</source>
<target>Zurück zur Liste</target>
</trans-unit>
<trans-unit id="110">
<source>action.cancel</source>
<target>Stornieren</target>
</trans-unit>

<!-- Detail -->
<trans-unit id="201">
Expand Down Expand Up @@ -92,7 +104,7 @@
<target>Deaktivieren</target>
</trans-unit>
<trans-unit id="210">
<source>detail.save</source>
<source>action.save</source>
<target>Speichern</target>
</trans-unit>
<trans-unit id="211">
Expand All @@ -107,6 +119,10 @@
<source>detail.actions</source>
<target>Aktionen</target>
</trans-unit>
<trans-unit id="214">
<source>detail.locked</source>
<target>Verschlossen</target>
</trans-unit>

<!-- Flashs messages -->
<trans-unit id="300">
Expand All @@ -126,6 +142,19 @@
<target>Aufgabe erfolgreich entsperrt.</target>
</trans-unit>

<!-- admin label -->
<trans-unit id="400">
<source>label.null</source>
<target>Null</target>
</trans-unit>
<trans-unit id="401">
<source>label.true</source>
<target>True</target>
</trans-unit>
<trans-unit id="402">
<source>label.false</source>
<target>False</target>
</trans-unit>
</body>
</file>
</xliff>
34 changes: 31 additions & 3 deletions Resources/translations/JMoseCommandScheduler.en.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,24 @@
<source>confirm.unlock</source>
<target>The task may be running. Are you sure you want to unlock it ?</target>
</trans-unit>
<trans-unit id="108">
<source>action.search</source>
<target>Search</target>
</trans-unit>
<trans-unit id="109">
<source>action.list</source>
<target>Back to list</target>
</trans-unit>
<trans-unit id="110">
<source>action.cancel</source>
<target>Cancel</target>
</trans-unit>

<!-- Detail -->
<trans-unit id="201">
<source>detail.title</source>
<target>Scheduled command</target>
</trans-unit>

<trans-unit id="202">
<source>detail.name</source>
<target>Name</target>
Expand Down Expand Up @@ -89,10 +100,10 @@
</trans-unit>
<trans-unit id="209">
<source>detail.disabled</source>
<target>Disable</target>
<target>Disabled</target>
</trans-unit>
<trans-unit id="210">
<source>detail.save</source>
<source>action.save</source>
<target>Save</target>
</trans-unit>
<trans-unit id="211">
Expand All @@ -107,6 +118,10 @@
<source>detail.actions</source>
<target>Actions</target>
</trans-unit>
<trans-unit id="214">
<source>detail.locked</source>
<target>Locked</target>
</trans-unit>

<!-- Flashs messages -->
<trans-unit id="300">
Expand All @@ -126,6 +141,19 @@
<target>Scheduling successfully unlocked.</target>
</trans-unit>

<!-- admin label -->
<trans-unit id="400">
<source>label.null</source>
<target>Null</target>
</trans-unit>
<trans-unit id="401">
<source>label.true</source>
<target>True</target>
</trans-unit>
<trans-unit id="402">
<source>label.false</source>
<target>False</target>
</trans-unit>
</body>
</file>
</xliff>
31 changes: 30 additions & 1 deletion Resources/translations/JMoseCommandScheduler.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@
<source>confirm.unlock</source>
<target>La tarea puede estar corriendo ¿Está seguro que desea desbloquearla?</target>
</trans-unit>
<trans-unit id="108">
<source>action.search</source>
<target>Buscar</target>
</trans-unit>
<trans-unit id="109">
<source>action.list</source>
<target>Volver a la lista</target>
</trans-unit>
<trans-unit id="110">
<source>action.cancel</source>
<target>Cancelar</target>
</trans-unit>

<!-- Detail -->
<trans-unit id="201">
Expand Down Expand Up @@ -92,7 +104,7 @@
<target>Deshabilitar</target>
</trans-unit>
<trans-unit id="210">
<source>detail.save</source>
<source>action.save</source>
<target>Guardar</target>
</trans-unit>
<trans-unit id="211">
Expand All @@ -107,6 +119,10 @@
<source>detail.actions</source>
<target>Acciones</target>
</trans-unit>
<trans-unit id="214">
<source>detail.locked</source>
<target>Bloqueado</target>
</trans-unit>

<!-- Flashs messages -->
<trans-unit id="300">
Expand All @@ -126,6 +142,19 @@
<target>Tarea desbloqueada exitosamente.</target>
</trans-unit>

<!-- admin label -->
<trans-unit id="400">
<source>label.null</source>
<target>Null</target>
</trans-unit>
<trans-unit id="401">
<source>label.true</source>
<target>True</target>
</trans-unit>
<trans-unit id="402">
<source>label.false</source>
<target>False</target>
</trans-unit>
</body>
</file>
</xliff>
31 changes: 30 additions & 1 deletion Resources/translations/JMoseCommandScheduler.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@
<source>confirm.unlock</source>
<target>Le traitement est peut-être en cours d'exécution. Etes-vous sur de vouloir le déverrouiller ?</target>
</trans-unit>
<trans-unit id="108">
<source>action.search</source>
<target>Rechercher</target>
</trans-unit>
<trans-unit id="109">
<source>action.list</source>
<target>Retour à la liste</target>
</trans-unit>
<trans-unit id="110">
<source>action.cancel</source>
<target>Annuler</target>
</trans-unit>

<!-- Detail -->
<trans-unit id="201">
Expand Down Expand Up @@ -89,7 +101,7 @@
<target>Désactiver</target>
</trans-unit>
<trans-unit id="210">
<source>detail.save</source>
<source>action.save</source>
<target>Enregistrer</target>
</trans-unit>
<trans-unit id="211">
Expand All @@ -104,6 +116,10 @@
<source>detail.actions</source>
<target>Actions</target>
</trans-unit>
<trans-unit id="214">
<source>detail.locked</source>
<target>Verrouillé</target>
</trans-unit>

<!-- Flashs messages -->
<trans-unit id="300">
Expand All @@ -123,6 +139,19 @@
<target>Traitement déverrouillé avec succès.</target>
</trans-unit>

<!-- admin label -->
<trans-unit id="400">
<source>label.null</source>
<target>Aucun</target>
</trans-unit>
<trans-unit id="401">
<source>label.true</source>
<target>Oui</target>
</trans-unit>
<trans-unit id="402">
<source>label.false</source>
<target>Non</target>
</trans-unit>
</body>
</file>
</xliff>
Loading

0 comments on commit c5ce339

Please sign in to comment.