mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
update backend code for PHRAS-1783
This commit is contained in:
@@ -86,10 +86,6 @@ class TaskManagerController extends Controller
|
||||
|
||||
public function getLiveInformation(Request $request)
|
||||
{
|
||||
if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) {
|
||||
throw new RuntimeException('The use of the task manager is disabled on this instance.');
|
||||
}
|
||||
|
||||
if ($request->getRequestFormat() !== "json") {
|
||||
$this->app->abort(406, 'Only JSON format is accepted.');
|
||||
}
|
||||
@@ -108,23 +104,28 @@ class TaskManagerController extends Controller
|
||||
|
||||
public function getScheduler(Request $request)
|
||||
{
|
||||
if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) {
|
||||
throw new RuntimeException('The use of the task manager is disabled on this instance.');
|
||||
}
|
||||
|
||||
if ($request->getRequestFormat() !== "json") {
|
||||
$this->app->abort(406, 'Only JSON format is accepted.');
|
||||
}
|
||||
|
||||
return $this->app->json([
|
||||
$ret = [
|
||||
'name' => $this->app->trans('Task Scheduler'),
|
||||
'configuration' => $this->app['task-manager.status']->getStatus(),
|
||||
'urls' => [
|
||||
];
|
||||
|
||||
if (($this->app['phraseanet.configuration']['main']['task-manager']['enabled'] === true)) {
|
||||
$ret['urls'] = [
|
||||
'start' => $this->app->path('admin_tasks_scheduler_start'),
|
||||
'stop' => $this->app->path('admin_tasks_scheduler_stop'),
|
||||
'log' => $this->app->path('admin_tasks_scheduler_log'),
|
||||
]
|
||||
]);
|
||||
];
|
||||
}
|
||||
else {
|
||||
$ret['urls'] = [
|
||||
'log' => $this->app->path('admin_tasks_scheduler_log'),
|
||||
];
|
||||
}
|
||||
|
||||
return $this->app->json($ret);
|
||||
}
|
||||
|
||||
public function getTasks(Request $request)
|
||||
@@ -212,10 +213,6 @@ class TaskManagerController extends Controller
|
||||
|
||||
public function postTaskDelete(Task $task)
|
||||
{
|
||||
if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) {
|
||||
throw new RuntimeException('The use of the task manager is disabled on this instance.');
|
||||
}
|
||||
|
||||
$this->getTaskManipulator()->delete($task);
|
||||
|
||||
return $this->app->redirectPath('admin_tasks_list');
|
||||
@@ -223,10 +220,6 @@ class TaskManagerController extends Controller
|
||||
|
||||
public function postStartTask(Task $task)
|
||||
{
|
||||
if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) {
|
||||
throw new RuntimeException('The use of the task manager is disabled on this instance.');
|
||||
}
|
||||
|
||||
$this->getTaskManipulator()->start($task);
|
||||
|
||||
return $this->app->redirectPath('admin_tasks_list');
|
||||
@@ -234,10 +227,6 @@ class TaskManagerController extends Controller
|
||||
|
||||
public function postStopTask(Task $task)
|
||||
{
|
||||
if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) {
|
||||
throw new RuntimeException('The use of the task manager is disabled on this instance.');
|
||||
}
|
||||
|
||||
$this->getTaskManipulator()->stop($task);
|
||||
|
||||
return $this->app->redirectPath('admin_tasks_list');
|
||||
@@ -252,10 +241,6 @@ class TaskManagerController extends Controller
|
||||
|
||||
public function postSaveTask(Request $request, Task $task)
|
||||
{
|
||||
if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) {
|
||||
throw new RuntimeException('The use of the task manager is disabled on this instance.');
|
||||
}
|
||||
|
||||
if (!$this->doValidateXML($request->request->get('settings'))) {
|
||||
return $this->app->json(['success' => false, 'message' => sprintf('Unable to load XML %s', $request->request->get('xml'))]);
|
||||
}
|
||||
@@ -292,10 +277,6 @@ class TaskManagerController extends Controller
|
||||
|
||||
public function getTask(Request $request, Task $task)
|
||||
{
|
||||
if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) {
|
||||
throw new RuntimeException('The use of the task manager is disabled on this instance.');
|
||||
}
|
||||
|
||||
if ('json' === $request->getContentType()) {
|
||||
return $this->app->json(array_replace([
|
||||
'id' => $task->getId(),
|
||||
@@ -322,10 +303,6 @@ class TaskManagerController extends Controller
|
||||
|
||||
public function validateXML(Request $request)
|
||||
{
|
||||
if (false === $this->app['phraseanet.configuration']['main']['task-manager']['enabled']) {
|
||||
throw new RuntimeException('The use of the task manager is disabled on this instance.');
|
||||
}
|
||||
|
||||
return $this->app->json(['success' => $this->doValidateXML($request->getContent())]);
|
||||
}
|
||||
|
||||
|
@@ -28,86 +28,8 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="scheduler-view">
|
||||
<tr>
|
||||
<td class="menu">
|
||||
<div class="btn-group dropdown">
|
||||
<a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% if app['phraseanet.configuration']['main']['task-manager']['enabled'] %}
|
||||
<li>
|
||||
<a method="POST" href="{{ path('admin_tasks_scheduler_start') }}">
|
||||
{{ 'Start' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a method="POST" href="{{ path('admin_tasks_scheduler_stop') }}">
|
||||
{{ 'Stop' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<a href="{{ path('admin_tasks_scheduler_log') }}">
|
||||
{{ 'Logs' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{{ scheduler["status"] }}</td>
|
||||
<td>{{ scheduler["name"] }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody class="tasks-list-view">
|
||||
{% for task in tasks %}
|
||||
<tr>
|
||||
<td class="menu">
|
||||
<div class="btn-group dropdown">
|
||||
<a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="{{ path('admin_tasks_task_show', {"task" : task["id"] }) }}">
|
||||
{{ 'Edit' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a method="POST" href="{{ path('admin_tasks_task_start', {"task" : task["id"] }) }}">
|
||||
{{ 'Start' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a method="POST" href="{{ path('admin_tasks_task_stop', {"task" : task["id"] }) }}">
|
||||
{{ 'Stop' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a method="POST" href="{{ path('admin_tasks_task_delete', {"task" : task["id"] }) }}">
|
||||
{{ 'Delete' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ path('admin_tasks_task_log', {"task" : task["id"] }) }}">
|
||||
{{ 'Logs' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ task["id"] }}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{{ task["status"] }}</td>
|
||||
<td>{{ task["name"] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<form id="form-create-task" method="post" name="form-create-task" action="{{ path('admin_tasks_task_create') }}">
|
||||
@@ -124,7 +46,6 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('.dropdown-toggle').dropdown();
|
||||
$("form[name='form-create-task'] select").bind("change", function() {
|
||||
$(this).closest('form').submit();
|
||||
});
|
||||
|
@@ -48,6 +48,7 @@
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% if app['phraseanet.configuration']['main']['task-manager']['enabled'] %}
|
||||
<li>
|
||||
<a method="POST" href="<%- scheduler['urls']['start'] %>">
|
||||
{{ 'Start' | trans }}
|
||||
@@ -58,6 +59,7 @@
|
||||
{{ 'Stop' | trans }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
<li>
|
||||
<a href="<%- scheduler['urls']['log'] %>">
|
||||
{{ 'Logs' | trans }}
|
||||
|
@@ -36,7 +36,7 @@ define([
|
||||
tasksCollection: TaskManagerApp.tasksCollection,
|
||||
scheduler: TaskManagerApp.Scheduler
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var load = function() {
|
||||
TaskManagerApp.refreshView.refreshAction();
|
||||
|
Reference in New Issue
Block a user