Change all lists to use ajax data source and high perf datatable + improve all consuming listing queries + add indexes on numbers for perf improvment

This commit is contained in:
osaajani 2020-09-23 03:02:13 +02:00
parent 52ac5b459b
commit b98d5a22ef
34 changed files with 1238 additions and 767 deletions

View file

@ -35,43 +35,29 @@
</div>
<div class="panel-body">
<form method="GET">
<?php if (!$commands) { ?>
<p>Aucune commande n'a été créée pour le moment.</p>
<?php } else { ?>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped datatable" id="table-commands">
<thead>
<tr>
<th>Nom</th>
<th>Script</th>
<th>Admin obligatoire</th>
<th class="checkcolumn">&#10003;</th>
</tr>
</thead>
<tbody>
<?php foreach ($commands as $command) { ?>
<tr>
<td><?php $this->s($command['name']); ?></td>
<td><?php $this->s($command['script']); ?></td>
<td><?php echo $command['admin'] ? 'Oui' : 'Non' ; ?></td>
<td><input type="checkbox" name="ids[]" value="<?php $this->s($command['id']); ?>"></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php } ?>
<div class="table-responsive">
<table class="table table-bordered table-hover table-striped datatable" id="table-commands">
<thead>
<tr>
<th>Nom</th>
<th>Script</th>
<th>Admin obligatoire</th>
<th class="checkcolumn">&#10003;</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div>
<div class="col-xs-6 no-padding">
<a class="btn btn-success" href="<?php echo \descartes\Router::url('Command', 'add'); ?>"><span class="fa fa-plus"></span> Ajouter une commande</a>
</div>
<?php if ($commands) { ?>
<div class="text-right col-xs-6 no-padding">
<strong>Action pour la séléction :</strong>
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Command', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Command', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
<?php } ?>
<div class="text-right col-xs-6 no-padding">
<strong>Action pour la séléction :</strong>
<button class="btn btn-default" type="submit" formaction="<?php echo \descartes\Router::url('Command', 'edit'); ?>"><span class="fa fa-edit"></span> Modifier</button>
<button class="btn btn-default btn-confirm" type="submit" formaction="<?php echo \descartes\Router::url('Command', 'delete', ['csrf' => $_SESSION['csrf']]); ?>"><span class="fa fa-trash-o"></span> Supprimer</button>
</div>
</div>
</form>
</div>
@ -81,5 +67,44 @@
</div>
</div>
</div>
<script>
jQuery(document).ready(function ()
{
jQuery('.datatable').DataTable({
"pageLength": 25,
"bLengthChange": false,
"language": {
"url": HTTP_PWD + "/assets/js/datatables/french.json",
},
"columnDefs": [{
'targets': 'checkcolumn',
'orderable': false,
}],
"ajax": {
'url': '<?php echo \descartes\Router::url('Command', 'list_json'); ?>',
'dataSrc': 'data',
},
"columns" : [
{data: 'name', render: jQuery.fn.dataTable.render.text()},
{data: 'script', render: jQuery.fn.dataTable.render.text()},
{
data: 'admin',
render: function (data, type, row, meta) {
return data ? "Oui" : "Non";
},
},
{
data: 'id',
render: function (data, type, row, meta) {
return '<input name="ids[]" type="checkbox" value="' + data + '">';
},
},
],
"deferRender": true
});
});
</script>
<?php
$this->render('incs/footer');