From def001ff7908b7ce5991c9aa02b3a5cf7ac7c578 Mon Sep 17 00:00:00 2001 From: dumityty Date: Mon, 7 May 2018 22:22:06 +0100 Subject: [PATCH 1/7] delete all runs --- src/Xhgui/Controller/Run.php | 14 ++++++++++++++ src/routes.php | 4 ++++ src/templates/runs/list.twig | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/src/Xhgui/Controller/Run.php b/src/Xhgui/Controller/Run.php index 67de9132a..4d1b151ef 100644 --- a/src/Xhgui/Controller/Run.php +++ b/src/Xhgui/Controller/Run.php @@ -124,6 +124,20 @@ public function delete() $this->app->redirect($redirect); } + public function delete_all() { + $request = $this->app->request(); + + // Delete all profile runs. + $delete = $this->profiles->truncate(); + + $this->app->flash('success', 'Deleted all profiles'); + + $referrer = $request->getReferrer(); + // In case route is accessed directly the referrer is not set. + $redirect = isset($referrer) ? $referrer : $this->app->urlFor('home'); + $this->app->redirect($redirect); + } + public function url() { $request = $this->app->request(); diff --git a/src/routes.php b/src/routes.php index a673d8802..1becebfc8 100644 --- a/src/routes.php +++ b/src/routes.php @@ -34,6 +34,10 @@ $di['runController']->delete(); })->name('run.delete'); +$app->get('/run/delete_all', function () use ($di, $app) { + $di['runController']->delete_all(); +})->name('run.delete_all'); + $app->get('/url/view', function () use ($di, $app) { $app->controller = $di['runController']; $app->controller->url(); diff --git a/src/templates/runs/list.twig b/src/templates/runs/list.twig index 2dc85a179..7033da111 100644 --- a/src/templates/runs/list.twig +++ b/src/templates/runs/list.twig @@ -10,6 +10,10 @@ {% if runs|length or has_search %}