Commit 49c5a0d1 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Améliorations de l'IHM : génération automatique des procédures d'import...

Améliorations de l'IHM : génération automatique des procédures d'import lorsqu'on active ou désactive une table.
Bouton de make-procs dans la page table maintenant.
parent ba773720
Pipeline #7916 failed with stage
in 4 seconds
......@@ -5,6 +5,7 @@ namespace UnicaenImport\Controller\Factory;
use Interop\Container\ContainerInterface;
use UnicaenImport\Controller\TableController;
use UnicaenImport\Form\TableForm;
use UnicaenImport\Processus\ImportProcessus;
use UnicaenImport\Service\SchemaService;
use UnicaenImport\Service\TableService;
......@@ -30,6 +31,7 @@ class TableControllerFactory
$controller->setServiceTable($container->get(TableService::class));
$controller->setServiceSchema($container->get(SchemaService::class));
$controller->setFormTable($container->get('FormElementManager')->get(TableForm::class));
$controller->setProcessusImport($container->get(ImportProcessus::class));
return $controller;
}
......
......@@ -3,6 +3,7 @@
namespace UnicaenImport\Controller;
use UnicaenImport\Form\Traits\TableFormAwareTrait;
use UnicaenImport\Processus\Traits\ImportProcessusAwareTrait;
use UnicaenImport\Service\Traits\SchemaServiceAwareTrait;
use UnicaenImport\Service\Traits\TableServiceAwareTrait;
use Zend\Mvc\Controller\AbstractActionController;
......@@ -19,6 +20,7 @@ class TableController extends AbstractActionController
use TableServiceAwareTrait;
use SchemaServiceAwareTrait;
use TableFormAwareTrait;
use ImportProcessusAwareTrait;
......@@ -51,6 +53,7 @@ class TableController extends AbstractActionController
if ($table) {
$table->setSyncEnabled(!$table->isSyncEnabled());
$this->getServiceTable()->save($table);
$this->getProcessusImport()->updateViewsAndPackages();
}
$result = [
......@@ -89,6 +92,7 @@ class TableController extends AbstractActionController
if ($form->isValid()) {
try {
$this->getServiceTable()->save($table);
$this->getProcessusImport()->updateViewsAndPackages();
} catch (\Exception $e) {
$this->flashMessenger()->addErrorMessage($e->getMessage());
}
......
<h1 class="page-header">Mise à jour des vues et procédures d'import</h1>
<?php
echo $this->partial('unicaen-import/import/menu', ['active' => 'maj-vues-fonctions']);
echo $this->messenger()->setMessage($message, \UnicaenApp\View\Helper\Messenger::SUCCESS);
\ No newline at end of file
......@@ -33,13 +33,6 @@ $pages = [
'popover' => false,
'icon' => 'glyphicon glyphicon-import',
],
'maj-vues-fonctions' => [
'url' => $this->url('import/maj-vues-fonctions'),
'label' => 'Mise à jour des vues et procédures d\'import',
'visible' => $this->isAllowed(Privileges::getResourceId(Privileges::IMPORT_VUES_PROCEDURES)),
'popover' => false,
'icon' => 'glyphicon glyphicon-wrench',
],
];
?>
......
......@@ -11,84 +11,105 @@ $title = 'Tables';
$canEdit = $this->isAllowed(Privileges::getResourceId(Privileges::IMPORT_TABLES_EDITION));
echo $this->inlinescript()->appendFile($this->basePath().'/vendor/unicaen/import/ace-builds-master/src-min/ace.js');
echo $this->inlinescript()->appendFile($this->basePath() . '/vendor/unicaen/import/ace-builds-master/src-min/ace.js');
$this->headTitle()->append($title);
echo $this->tag('h1', ['class' => 'page-header'])->text($title);
echo $this->partial('unicaen-import/import/menu', ['active'=> 'tables'] );
echo $this->partial('unicaen-import/import/menu', ['active' => 'tables']);
?>
<div class="tables-config">
<?php if (empty($tables)): ?>
Aucune table n'est renseignée
<?php else:?>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Table</th>
<th>Synchro active</th>
<th>Job</th>
<th>Filtre</th>
<th>Traitement antérieur</th>
<th>Traitement postérieur</th>
<?php if ($canEdit): ?>
<th>Actions</th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php foreach( $tables as $table ): ?>
<tr class="table-ligne" data-table="<?= $table->getName() ?>">
<th><?= $table->getName() ?></th>
<td style="text-align: center;"><?php
if (in_array($table->getName(), $views)){
$class = $table->isSyncEnabled() ? 'glyphicon-ok text-success' : 'glyphicon-remove text-danger refuse';
$icon = $this->tag('span', ['class' => 'glyphicon glyph-switch ' . $class, 'style' => 'font-size: 14pt']);
if ($canEdit) {
echo $this->tag('a', [
'href' => 'javascript:void(0)',
'class' => 'synchro-switch',
'title' => 'Cliquez pour activer/désactiver la synchro pour cette table',
])->html($icon);
} else {
echo $icon;
}
}else{
echo 'Pas de vue source associée';
}
?></td>
<td><?= $table->getSyncJob() ?></td>
<td title="<?= $table->getSyncFiltre() ?>"><?= $table->getSyncFiltre() ? substr($table->getSyncFiltre(),0,15).' ...':'' ?></td>
<td title="<?= $table->getSyncHookBefore() ?>"><?= $table->getSyncHookBefore() ? substr($table->getSyncHookBefore(),0,15).' ...':'' ?></td>
<td title="<?= $table->getSyncHookAfter() ?>"><?= $table->getSyncHookAfter() ? substr($table->getSyncHookAfter(),0,15).' ...':'' ?></td>
<?php if (empty($tables)): ?>
Aucune table n'est renseignée
<?php else: ?>
<table class="table table-bordered table-condensed">
<thead>
<tr>
<th>Table</th>
<th>Synchro active</th>
<th>Job</th>
<th>Filtre</th>
<th>Traitement antérieur</th>
<th>Traitement postérieur</th>
<?php if ($canEdit): ?>
<td>
<span class="glyphicon glyphicon-move"
title="Vous pouvez trier les tables en déplaçant les lignes du tableau"></span>&nbsp;
<a class="ajax-modal"
data-event="table-modifier"
href="<?= $this->url('import/tables/modifier',['table' => $table->getName()]) ?>"
title="Modifier le paramétrage de la table"
><span class="glyphicon glyphicon-edit"></span></a>
</td>
<th>Actions</th>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php if ($hasNonReferenced): ?>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<p>Des tables synchronisables ne sont pas référencées dans la liste ci-dessus.</p>
<?php if ($canEdit): ?>
<button class="btn btn-warning add-non-referenced">Ajouter ces tables pour les rendre synchronisables</button>
<?php endif; ?>
</div>
<?php endif; ?>
</thead>
<tbody>
<?php foreach ($tables as $table): ?>
<tr class="table-ligne" data-table="<?= $table->getName() ?>">
<th><?= $table->getName() ?></th>
<td style="text-align: center;"><?php
if (in_array($table->getName(), $views)) {
$class = $table->isSyncEnabled() ? 'glyphicon-ok text-success' : 'glyphicon-remove text-danger refuse';
$icon = $this->tag('span', ['class' => 'glyphicon glyph-switch ' . $class, 'style' => 'font-size: 14pt']);
if ($canEdit) {
echo $this->tag('a', [
'href' => 'javascript:void(0)',
'class' => 'synchro-switch',
'title' => 'Cliquez pour activer/désactiver la synchro pour cette table',
])->html($icon);
} else {
echo $icon;
}
} else {
echo 'Pas de vue source associée';
}
?></td>
<td><?= $table->getSyncJob() ?></td>
<td title="<?= $table->getSyncFiltre() ?>"><?= $table->getSyncFiltre() ? substr($table->getSyncFiltre(), 0, 15) . ' ...' : '' ?></td>
<td title="<?= $table->getSyncHookBefore() ?>"><?= $table->getSyncHookBefore() ? substr($table->getSyncHookBefore(), 0, 15) . ' ...' : '' ?></td>
<td title="<?= $table->getSyncHookAfter() ?>"><?= $table->getSyncHookAfter() ? substr($table->getSyncHookAfter(), 0, 15) . ' ...' : '' ?></td>
<?php if ($canEdit): ?>
<td>
<span class="glyphicon glyphicon-move"
title="Vous pouvez trier les tables en déplaçant les lignes du tableau"></span>&nbsp;
<a class="ajax-modal"
data-event="table-modifier"
href="<?= $this->url('import/tables/modifier', ['table' => $table->getName()]) ?>"
title="Modifier le paramétrage de la table"
><span class="glyphicon glyphicon-edit"></span></a>
</td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php if ($hasNonReferenced): ?>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
aria-hidden="true">&times;</span></button>
<p>Des tables synchronisables ne sont pas référencées dans la liste ci-dessus.</p>
<?php if ($canEdit): ?>
<button class="btn btn-warning add-non-referenced">Ajouter ces tables pour les rendre synchronisables</button>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
if ($this->isAllowed(Privileges::getResourceId(Privileges::IMPORT_VUES_PROCEDURES))) {
echo $this->tag('a', [
'class' => 'btn btn-info pop-ajax',
'data-submit-reload' => "true",
'href' => $this->url('import/maj-vues-fonctions'),
])->html('<span class="glyphicon glyphicon-wrench"></span> Mise à jour des vues et procédures d\'import');
}
// 'maj-vues-fonctions' => [
// 'url' => ,
// 'label' => 'Mise à jour des vues et procédures d\'import',
// 'visible' => ,
// 'popover' => false,
// 'icon' => 'glyphicon glyphicon-wrench',
// ],
?>
</div>
<script>
......@@ -110,22 +131,25 @@ echo $this->partial('unicaen-import/import/menu', ['active'=> 'tables'] );
},
synchroSwitch: function( table )
synchroSwitch: function (table)
{
var that = this;
var glyphSwitch = that.element.find("tr.table-ligne[data-table='" + table + "'] .glyph-switch");
glyphSwitch.addClass('loading');
glyphSwitch.removeClass('glyphicon-ok text-success');
glyphSwitch.removeClass('glyphicon-remove text-danger refuse');
$.post("<?= $this->url('import/tables/synchro-switch') ?>", {table: table}, function (data)
{
var glyphSwitch = that.element.find("tr.table-ligne[data-table='" + data.table + "'] .glyph-switch");
if (data.result){
glyphSwitch.removeClass('loading');
if (data.result) {
glyphSwitch.addClass('glyphicon-ok text-success');
glyphSwitch.removeClass('glyphicon-remove text-danger refuse');
}else{
} else {
glyphSwitch.addClass('glyphicon-remove text-danger refuse');
glyphSwitch.removeClass('glyphicon-ok text-success');
}
}).fail(function (jqXHR)
{
glyphSwitch.removeClass('loading');
alertFlash(jqXHR.responseText, 'danger', 5000);
console.log(jqXHR);
});
......@@ -141,7 +165,7 @@ echo $this->partial('unicaen-import/import/menu', ['active'=> 'tables'] );
that.addNonReferenced();
});
this.element.find(".synchro-switch").click( function()
this.element.find(".synchro-switch").click(function ()
{
that.synchroSwitch($(this).parents('tr').data('table'));
});
......@@ -152,7 +176,7 @@ echo $this->partial('unicaen-import/import/menu', ['active'=> 'tables'] );
update: function (event, ui) {
var tables = [];
ui.item.parent().find('tr.table-ligne').each(function () {
tables.push( $(this).data('table') );
tables.push($(this).data('table'));
});
$.post("<?= $this->url('import/tables/trier') ?>", {tables: tables}).done(function (res) {
alertFlash(res.msg, 'success', 3000);
......@@ -164,12 +188,10 @@ echo $this->partial('unicaen-import/import/menu', ['active'=> 'tables'] );
WidgetInitializer.add('tables-config', 'tablesConfig');
$("body").on("table-modifier", function(event, data) {
window.location.reload();
});
$("body").on("table-modifier", function (event, data) {
window.location.reload();
});
});
</script>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment