mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
add sql view
This commit is contained in:
@@ -17,12 +17,14 @@ use Alchemy\Phrasea\WorkerManager\Form\WorkerSearchengineType;
|
|||||||
use Alchemy\Phrasea\WorkerManager\Form\WorkerValidationReminderType;
|
use Alchemy\Phrasea\WorkerManager\Form\WorkerValidationReminderType;
|
||||||
use Alchemy\Phrasea\WorkerManager\Queue\AMQPConnection;
|
use Alchemy\Phrasea\WorkerManager\Queue\AMQPConnection;
|
||||||
use Alchemy\Phrasea\WorkerManager\Queue\MessagePublisher;
|
use Alchemy\Phrasea\WorkerManager\Queue\MessagePublisher;
|
||||||
|
use Alchemy\Phrasea\WorkerManager\Worker\RecordMoverWorker;
|
||||||
use Doctrine\ORM\OptimisticLockException;
|
use Doctrine\ORM\OptimisticLockException;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Form\Form;
|
use Symfony\Component\Form\Form;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
|
|
||||||
@@ -400,6 +402,35 @@ class AdminConfigurationController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function recordMoverFacilityAction(PhraseaApplication $app, Request $request)
|
||||||
|
{
|
||||||
|
$ret = ['tasks' => []];
|
||||||
|
$job = new RecordMoverWorker($app);
|
||||||
|
switch ($request->get('ACT')) {
|
||||||
|
case 'PLAYTEST':
|
||||||
|
$sxml = simplexml_load_string($request->get('xml'));
|
||||||
|
if (isset($sxml->tasks->task)) {
|
||||||
|
foreach ($sxml->tasks->task as $sxtask) {
|
||||||
|
$ret['tasks'][] = $job->calcSQL($app, $sxtask, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'CALCTEST':
|
||||||
|
case 'CALCSQL':
|
||||||
|
$sxml = simplexml_load_string($request->get('xml'));
|
||||||
|
if (isset($sxml->tasks->task)) {
|
||||||
|
foreach ($sxml->tasks->task as $sxtask) {
|
||||||
|
$ret['tasks'][] = $job->calcSQL($app, $sxtask, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new NotFoundHttpException('Route not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $app->json($ret);
|
||||||
|
}
|
||||||
|
|
||||||
public function populateStatusAction(PhraseaApplication $app, Request $request)
|
public function populateStatusAction(PhraseaApplication $app, Request $request)
|
||||||
{
|
{
|
||||||
$databoxIds = $request->get('sbasIds');
|
$databoxIds = $request->get('sbasIds');
|
||||||
|
@@ -109,6 +109,10 @@ class ControllerServiceProvider implements ControllerProviderInterface, ServiceP
|
|||||||
->method('GET|POST')
|
->method('GET|POST')
|
||||||
->bind('worker_admin_recordMover');
|
->bind('worker_admin_recordMover');
|
||||||
|
|
||||||
|
$controllers->match('/record-mover/facility', 'controller.worker.admin.configuration:recordMoverFacilityAction')
|
||||||
|
->method('POST')
|
||||||
|
->bind('worker_admin_recordMover_facility');
|
||||||
|
|
||||||
/** @uses AdminConfigurationController::queueMonitorAction */
|
/** @uses AdminConfigurationController::queueMonitorAction */
|
||||||
$controllers->match('/queue-monitor', 'controller.worker.admin.configuration:queueMonitorAction')
|
$controllers->match('/queue-monitor', 'controller.worker.admin.configuration:queueMonitorAction')
|
||||||
->method('GET')
|
->method('GET')
|
||||||
|
@@ -216,7 +216,7 @@ class RecordMoverWorker implements WorkerInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function calcSQL(Application $app, $sxtask, $playTest = false)
|
public function calcSQL(Application $app, $sxtask, $playTest = false)
|
||||||
{
|
{
|
||||||
$sbas_id = (int) $sxtask['sbas_id'];
|
$sbas_id = (int) $sxtask['sbas_id'];
|
||||||
|
|
||||||
|
@@ -1,3 +1,55 @@
|
|||||||
|
{% block css %}
|
||||||
|
<style type="text/css">
|
||||||
|
OPTION.jsFilled
|
||||||
|
{
|
||||||
|
padding-left:10px;
|
||||||
|
padding-right:20px;
|
||||||
|
}
|
||||||
|
#OUTOFDATETAB TD
|
||||||
|
{
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
DIV.terminal
|
||||||
|
{
|
||||||
|
margin:5px;
|
||||||
|
border:1px #000000 solid;
|
||||||
|
font-family:monospace;
|
||||||
|
font-size:13px;
|
||||||
|
text-align:left;
|
||||||
|
color:#00FF00;
|
||||||
|
background-color:#182018
|
||||||
|
}
|
||||||
|
DIV.terminal DIV.title
|
||||||
|
{
|
||||||
|
color:#303830;
|
||||||
|
background-color:#00C000;
|
||||||
|
padding:2px;
|
||||||
|
}
|
||||||
|
DIV.terminal DIV.sql
|
||||||
|
{
|
||||||
|
padding:5px;
|
||||||
|
}
|
||||||
|
DIV.terminal DIV.sqltest
|
||||||
|
{
|
||||||
|
padding-left:45px;
|
||||||
|
padding-right:25px;
|
||||||
|
}
|
||||||
|
SPAN.active
|
||||||
|
{
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #000000;
|
||||||
|
color:#00FF00;
|
||||||
|
}
|
||||||
|
SPAN.notactive
|
||||||
|
{
|
||||||
|
font-weight: bold;
|
||||||
|
background-color: #000000;
|
||||||
|
color:#FF0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
<h1>{{ 'admin::workermanager:tab:record mover: description' |trans }}</h1>
|
<h1>{{ 'admin::workermanager:tab:record mover: description' |trans }}</h1>
|
||||||
|
|
||||||
{{ form_start(form, {'action': path('worker_admin_recordMover')}) }}
|
{{ form_start(form, {'action': path('worker_admin_recordMover')}) }}
|
||||||
@@ -6,10 +58,18 @@
|
|||||||
{{ form_row(form.ttl_retry) }}
|
{{ form_row(form.ttl_retry) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<button class="btn show-graphic-view">{{ 'Refresh graphic view' | trans }}</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
{{ form_row(form.xmlSetting, {'attr': {'style': 'width:99%;height:250px;'}}) }}
|
{{ form_row(form.xmlSetting, {'attr': {'style': 'width:99%;height:250px;'}}) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="graphic-view control-group" style="background-color: #f5f5f5;border-top: 1px solid #e5e5e5;">
|
||||||
|
<div class="terminal" id="sqla">{{ 'Graphic view' | trans }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
{{ form_row(form.apply) }}
|
{{ form_row(form.apply) }}
|
||||||
</div>
|
</div>
|
||||||
@@ -47,4 +107,113 @@
|
|||||||
form.submit();
|
form.submit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#worker-record-mover").on('click', '.show-graphic-view', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(".graphic-view ").show();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
"url": "{{ path('admin_tasks_validate_xml') }}",
|
||||||
|
"data": $("#worker_recordMover_xmlSetting").val(),
|
||||||
|
"processData": false,
|
||||||
|
"dataType": "json",
|
||||||
|
"type": "POST",
|
||||||
|
"async": false,
|
||||||
|
success: function (data) {
|
||||||
|
if (data.success == true) {
|
||||||
|
var x = $("#worker_recordMover_xmlSetting").val();
|
||||||
|
try {
|
||||||
|
taskFillGraphic(x);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (jqXHR, textStatus, errorThrown) {
|
||||||
|
// todo add notification
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function taskFillGraphic(xml)
|
||||||
|
{
|
||||||
|
// $("#sqlu").text("");
|
||||||
|
// $("#sqls").text("");
|
||||||
|
if (xml) {
|
||||||
|
xml2 = $.parseXML(xml);
|
||||||
|
xml2 = $(xml2);
|
||||||
|
|
||||||
|
var data = {};
|
||||||
|
data["ACT"] = "CALCTEST";
|
||||||
|
data["cls"]="RecordMover";
|
||||||
|
data["xml"] = xml;
|
||||||
|
$.ajax({ url: "{{ path('worker_admin_recordMover_facility') }}"
|
||||||
|
, data: data
|
||||||
|
, dataType:'json'
|
||||||
|
, type:"POST"
|
||||||
|
, async:true
|
||||||
|
, success:function(data) {
|
||||||
|
t = "";
|
||||||
|
for (i in data.tasks) {
|
||||||
|
t += "<div class=\"title\"> ";
|
||||||
|
if(data.tasks[i].active)
|
||||||
|
t += "<span class=\"active\"> X </span> ";
|
||||||
|
else
|
||||||
|
t += "<span class=\"notactive\"> X </span> ";
|
||||||
|
if(data.tasks[i].name_htmlencoded)
|
||||||
|
t += "<b>" + data.tasks[i].name_htmlencoded + "</b>";
|
||||||
|
else
|
||||||
|
t += "<b><i>sans nom</i></b>";
|
||||||
|
|
||||||
|
if(data.tasks[i].basename_htmlencoded)
|
||||||
|
t += " (action=" + data.tasks[i].action + ' on ' + data.tasks[i].basename_htmlencoded + ')';
|
||||||
|
else
|
||||||
|
t += " (action=" + data.tasks[i].action + ' on <i>Unknown</i>)';
|
||||||
|
t += "</div>";
|
||||||
|
|
||||||
|
if(data.tasks[i].err_htmlencoded) ;
|
||||||
|
t += "<div class=\"err\">" + data.tasks[i].err_htmlencoded + "</div>";
|
||||||
|
|
||||||
|
t += "<div class=\"sql\">";
|
||||||
|
|
||||||
|
if(data.tasks[i].sql && data.tasks[i].sql.test.sql_htmlencoded)
|
||||||
|
t += "<div class=\"sqltest\">" + data.tasks[i].sql.test.sql_htmlencoded + "</div>";
|
||||||
|
t += "--> <span id=\"SQLRET"+i+"\"><i>wait...</i></span><br/>";
|
||||||
|
|
||||||
|
t += "</div>";
|
||||||
|
}
|
||||||
|
$("#sqla").html(t);
|
||||||
|
|
||||||
|
var data = {};
|
||||||
|
data["ACT"] = "PLAYTEST";
|
||||||
|
data["cls"]="RecordMover";
|
||||||
|
data["xml"] = xml;
|
||||||
|
$.ajax({ url: "{{ path('worker_admin_recordMover_facility') }}"
|
||||||
|
, data: data
|
||||||
|
, dataType:'json'
|
||||||
|
, type:"POST"
|
||||||
|
, async:true
|
||||||
|
, success:function(data) {
|
||||||
|
for (i in data.tasks) {
|
||||||
|
if (data.tasks[i].sql) {
|
||||||
|
if (data.tasks[i].sql.test.err) {
|
||||||
|
$("#SQLRET"+i).html("err: " + data.tasks[i].sql.test.err);
|
||||||
|
} else {
|
||||||
|
t = '';
|
||||||
|
for(j in data.tasks[i].sql.test.result.rids)
|
||||||
|
t += (t?', ':'') + data.tasks[i].sql.test.result.rids[j];
|
||||||
|
if(data.tasks[i].sql.test.result.rids.length < data.tasks[i].sql.test.result.n)
|
||||||
|
t += ', ...';
|
||||||
|
$("#SQLRET"+i).html("n=" + data.tasks[i].sql.test.result.n + ", rids:(" + t + ")");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$("#SQLRET"+i).html("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user