Skip to content

Commit c5ce339

Browse files
authored
Merge pull request #123 from J-Mose/easy_admin
EasyAdmin Configuration template and some adaptations
2 parents 1ac9c4e + 94b4e7c commit c5ce339

9 files changed

+208
-12
lines changed

Controller/ListController.php

+15-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use JMose\CommandSchedulerBundle\Entity\ScheduledCommand;
66
use Symfony\Component\HttpFoundation\JsonResponse;
7+
use Symfony\Component\HttpFoundation\Request;
78
use Symfony\Component\HttpFoundation\Response;
89

910
/**
@@ -77,9 +78,10 @@ public function toggleAction($id)
7778

7879
/**
7980
* @param $id
80-
* @return \Symfony\Component\HttpFoundation\Response
81+
* @param Request $request
82+
* @return \Symfony\Component\HttpFoundation\RedirectResponse
8183
*/
82-
public function executeAction($id)
84+
public function executeAction($id, Request $request)
8385
{
8486
$entityManager = $this->getDoctrineManager();
8587
$scheduledCommand = $entityManager->getRepository(ScheduledCommand::class)->find($id);
@@ -90,14 +92,19 @@ public function executeAction($id)
9092
$this->get('session')->getFlashBag()
9193
->add('success', $this->translator->trans('flash.execute', [], 'JMoseCommandScheduler'));
9294

95+
if ($request->query->has('referer')) {
96+
return $this->redirect($request->getSchemeAndHttpHost().urldecode($request->query->get('referer')));
97+
}
98+
9399
return $this->redirect($this->generateUrl('jmose_command_scheduler_list'));
94100
}
95101

96102
/**
97103
* @param $id
98-
* @return \Symfony\Component\HttpFoundation\Response
104+
* @param Request $request
105+
* @return \Symfony\Component\HttpFoundation\RedirectResponse
99106
*/
100-
public function unlockAction($id)
107+
public function unlockAction($id, Request $request)
101108
{
102109
$entityManager = $this->getDoctrineManager();
103110
$scheduledCommand = $entityManager->getRepository(ScheduledCommand::class)->find($id);
@@ -108,6 +115,10 @@ public function unlockAction($id)
108115
$this->get('session')->getFlashBag()
109116
->add('success', $this->translator->trans('flash.unlocked', [], 'JMoseCommandScheduler'));
110117

118+
if ($request->query->has('referer')) {
119+
return $this->redirect($request->getSchemeAndHttpHost().urldecode($request->query->get('referer')));
120+
}
121+
111122
return $this->redirect($this->generateUrl('jmose_command_scheduler_list'));
112123
}
113124

Form/Type/ScheduledCommandType.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
105105
'save',
106106
SubmitType::class,
107107
[
108-
'label' => 'detail.save',
108+
'label' => 'action.save',
109109
]
110110
);
111111

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ To use it, you have to enable contrib recipes on your project : `composer config
3535
- Locking system, to stop scheduling a command that has returned an error
3636
- Monitoring with timeout or failed commands (Json URL and command with mailing)
3737
- Translated in french, english, german and spanish
38+
- An [EasyAdmin](https://github.com/EasyCorp/EasyAdminBundle) configuration template available [here](Resources/doc/index.md#6---easyadmin-integration)
3839

3940
## Screenshots
4041
![list](Resources/doc/images/scheduled-list.png)

Resources/doc/index.md

+40
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,46 @@ This can easily be done by using standard overrides in Symfony, as described [he
142142

143143
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.
144144

145+
### 6 - EasyAdmin integration
146+
147+
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.
148+
149+
```yaml
150+
easy_admin:
151+
entities:
152+
Cron:
153+
translation_domain: 'JMoseCommandScheduler'
154+
label: 'list.title'
155+
class: JMose\CommandSchedulerBundle\Entity\ScheduledCommand
156+
list:
157+
title: "list.title"
158+
fields:
159+
- { property: 'id', label: 'ID' }
160+
- { property: 'name', label: 'detail.name' }
161+
- { property: 'command', label: 'detail.command' }
162+
- { property: 'arguments', label: 'detail.arguments' }
163+
- { property: 'lastExecution', label: 'detail.lastExecution' }
164+
- { property: 'lastReturncode', label: 'detail.lastReturnCode' }
165+
- { property: 'locked', label: 'detail.locked', type: boolean}
166+
- { property: 'priority', label: 'detail.priority' }
167+
- { property: 'disabled', label: 'detail.disabled' }
168+
actions:
169+
- { name: 'jmose_command_scheduler_action_execute', type: 'route', label: 'action.execute' }
170+
- { name: 'jmose_command_scheduler_action_unlock', type: 'route', label: 'action.unlock' }
171+
form:
172+
fields:
173+
- { property: 'name', label: 'detail.name' }
174+
- { property: 'command', label: 'detail.command', type: 'JMose\CommandSchedulerBundle\Form\Type\CommandChoiceType' }
175+
- { property: 'arguments', label: 'detail.arguments' }
176+
- { property: 'cronExpression', label: 'detail.cronExpression' }
177+
- { property: 'priority', label: 'detail.priority' }
178+
- { property: 'disabled', label: 'detail.disabled' }
179+
- { property: 'logFile', label: 'detail.logFile' }
180+
new:
181+
fields:
182+
- { property: 'executeImmediately', label: 'detail.executeImmediately' }
183+
```
184+
145185
Usage
146186
============
147187

Resources/translations/JMoseCommandScheduler.de.xlf

+30-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@
5252
<source>confirm.unlock</source>
5353
<target>Die Aufgabe könnte gerade ausgeführt werden. Möchtest du sie wirklich entsperren?</target>
5454
</trans-unit>
55+
<trans-unit id="108">
56+
<source>action.search</source>
57+
<target>Suche</target>
58+
</trans-unit>
59+
<trans-unit id="109">
60+
<source>action.list</source>
61+
<target>Zurück zur Liste</target>
62+
</trans-unit>
63+
<trans-unit id="110">
64+
<source>action.cancel</source>
65+
<target>Stornieren</target>
66+
</trans-unit>
5567

5668
<!-- Detail -->
5769
<trans-unit id="201">
@@ -92,7 +104,7 @@
92104
<target>Deaktivieren</target>
93105
</trans-unit>
94106
<trans-unit id="210">
95-
<source>detail.save</source>
107+
<source>action.save</source>
96108
<target>Speichern</target>
97109
</trans-unit>
98110
<trans-unit id="211">
@@ -107,6 +119,10 @@
107119
<source>detail.actions</source>
108120
<target>Aktionen</target>
109121
</trans-unit>
122+
<trans-unit id="214">
123+
<source>detail.locked</source>
124+
<target>Verschlossen</target>
125+
</trans-unit>
110126

111127
<!-- Flashs messages -->
112128
<trans-unit id="300">
@@ -126,6 +142,19 @@
126142
<target>Aufgabe erfolgreich entsperrt.</target>
127143
</trans-unit>
128144

145+
<!-- admin label -->
146+
<trans-unit id="400">
147+
<source>label.null</source>
148+
<target>Null</target>
149+
</trans-unit>
150+
<trans-unit id="401">
151+
<source>label.true</source>
152+
<target>True</target>
153+
</trans-unit>
154+
<trans-unit id="402">
155+
<source>label.false</source>
156+
<target>False</target>
157+
</trans-unit>
129158
</body>
130159
</file>
131160
</xliff>

Resources/translations/JMoseCommandScheduler.en.xlf

+31-3
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,24 @@
5252
<source>confirm.unlock</source>
5353
<target>The task may be running. Are you sure you want to unlock it ?</target>
5454
</trans-unit>
55+
<trans-unit id="108">
56+
<source>action.search</source>
57+
<target>Search</target>
58+
</trans-unit>
59+
<trans-unit id="109">
60+
<source>action.list</source>
61+
<target>Back to list</target>
62+
</trans-unit>
63+
<trans-unit id="110">
64+
<source>action.cancel</source>
65+
<target>Cancel</target>
66+
</trans-unit>
5567

5668
<!-- Detail -->
5769
<trans-unit id="201">
5870
<source>detail.title</source>
5971
<target>Scheduled command</target>
6072
</trans-unit>
61-
6273
<trans-unit id="202">
6374
<source>detail.name</source>
6475
<target>Name</target>
@@ -89,10 +100,10 @@
89100
</trans-unit>
90101
<trans-unit id="209">
91102
<source>detail.disabled</source>
92-
<target>Disable</target>
103+
<target>Disabled</target>
93104
</trans-unit>
94105
<trans-unit id="210">
95-
<source>detail.save</source>
106+
<source>action.save</source>
96107
<target>Save</target>
97108
</trans-unit>
98109
<trans-unit id="211">
@@ -107,6 +118,10 @@
107118
<source>detail.actions</source>
108119
<target>Actions</target>
109120
</trans-unit>
121+
<trans-unit id="214">
122+
<source>detail.locked</source>
123+
<target>Locked</target>
124+
</trans-unit>
110125

111126
<!-- Flashs messages -->
112127
<trans-unit id="300">
@@ -126,6 +141,19 @@
126141
<target>Scheduling successfully unlocked.</target>
127142
</trans-unit>
128143

144+
<!-- admin label -->
145+
<trans-unit id="400">
146+
<source>label.null</source>
147+
<target>Null</target>
148+
</trans-unit>
149+
<trans-unit id="401">
150+
<source>label.true</source>
151+
<target>True</target>
152+
</trans-unit>
153+
<trans-unit id="402">
154+
<source>label.false</source>
155+
<target>False</target>
156+
</trans-unit>
129157
</body>
130158
</file>
131159
</xliff>

Resources/translations/JMoseCommandScheduler.es.xlf

+30-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@
5252
<source>confirm.unlock</source>
5353
<target>La tarea puede estar corriendo ¿Está seguro que desea desbloquearla?</target>
5454
</trans-unit>
55+
<trans-unit id="108">
56+
<source>action.search</source>
57+
<target>Buscar</target>
58+
</trans-unit>
59+
<trans-unit id="109">
60+
<source>action.list</source>
61+
<target>Volver a la lista</target>
62+
</trans-unit>
63+
<trans-unit id="110">
64+
<source>action.cancel</source>
65+
<target>Cancelar</target>
66+
</trans-unit>
5567

5668
<!-- Detail -->
5769
<trans-unit id="201">
@@ -92,7 +104,7 @@
92104
<target>Deshabilitar</target>
93105
</trans-unit>
94106
<trans-unit id="210">
95-
<source>detail.save</source>
107+
<source>action.save</source>
96108
<target>Guardar</target>
97109
</trans-unit>
98110
<trans-unit id="211">
@@ -107,6 +119,10 @@
107119
<source>detail.actions</source>
108120
<target>Acciones</target>
109121
</trans-unit>
122+
<trans-unit id="214">
123+
<source>detail.locked</source>
124+
<target>Bloqueado</target>
125+
</trans-unit>
110126

111127
<!-- Flashs messages -->
112128
<trans-unit id="300">
@@ -126,6 +142,19 @@
126142
<target>Tarea desbloqueada exitosamente.</target>
127143
</trans-unit>
128144

145+
<!-- admin label -->
146+
<trans-unit id="400">
147+
<source>label.null</source>
148+
<target>Null</target>
149+
</trans-unit>
150+
<trans-unit id="401">
151+
<source>label.true</source>
152+
<target>True</target>
153+
</trans-unit>
154+
<trans-unit id="402">
155+
<source>label.false</source>
156+
<target>False</target>
157+
</trans-unit>
129158
</body>
130159
</file>
131160
</xliff>

Resources/translations/JMoseCommandScheduler.fr.xlf

+30-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@
5050
<source>confirm.unlock</source>
5151
<target>Le traitement est peut-être en cours d'exécution. Etes-vous sur de vouloir le déverrouiller ?</target>
5252
</trans-unit>
53+
<trans-unit id="108">
54+
<source>action.search</source>
55+
<target>Rechercher</target>
56+
</trans-unit>
57+
<trans-unit id="109">
58+
<source>action.list</source>
59+
<target>Retour à la liste</target>
60+
</trans-unit>
61+
<trans-unit id="110">
62+
<source>action.cancel</source>
63+
<target>Annuler</target>
64+
</trans-unit>
5365

5466
<!-- Detail -->
5567
<trans-unit id="201">
@@ -89,7 +101,7 @@
89101
<target>Désactiver</target>
90102
</trans-unit>
91103
<trans-unit id="210">
92-
<source>detail.save</source>
104+
<source>action.save</source>
93105
<target>Enregistrer</target>
94106
</trans-unit>
95107
<trans-unit id="211">
@@ -104,6 +116,10 @@
104116
<source>detail.actions</source>
105117
<target>Actions</target>
106118
</trans-unit>
119+
<trans-unit id="214">
120+
<source>detail.locked</source>
121+
<target>Verrouillé</target>
122+
</trans-unit>
107123

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

142+
<!-- admin label -->
143+
<trans-unit id="400">
144+
<source>label.null</source>
145+
<target>Aucun</target>
146+
</trans-unit>
147+
<trans-unit id="401">
148+
<source>label.true</source>
149+
<target>Oui</target>
150+
</trans-unit>
151+
<trans-unit id="402">
152+
<source>label.false</source>
153+
<target>Non</target>
154+
</trans-unit>
126155
</body>
127156
</file>
128157
</xliff>

0 commit comments

Comments
 (0)