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

@ -40,8 +40,22 @@ namespace controllers\publics;
*/
public function list()
{
$events = $this->internal_event->list_for_user($_SESSION['user']['id']);
$this->render('event/list', ['events' => $events, 'nb_results' => \count($events)]);
$this->render('event/list');
}
/**
* Return events as json
*/
public function list_json()
{
$entities = $this->internal_event->list_for_user($_SESSION['user']['id']);
foreach ($entities as &$entity)
{
$entity['icon'] = \controllers\internals\Tool::event_type_to_icon($entity['type']);
}
header('Content-Type: application/json');
echo json_encode(['data' => $entities]);
}
/**
@ -60,6 +74,13 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Event', 'list'));
}
if (!\controllers\internals\Tool::is_admin())
{
\FlashMessage\FlashMessage::push('danger', 'Vous devez être administrateur pour supprimer un event !');
return $this->redirect(\descartes\Router::url('Event', 'list'));
}
$ids = $_GET['ids'] ?? [];
foreach ($ids as $id)