From 1f5d57165bc1867181787166d7e43d2f8dba783d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 31 Jan 2020 15:57:28 +0100 Subject: [PATCH] ServicegroupsController: Add show more widget in compact mode --- .../controllers/ServicegroupsController.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/application/controllers/ServicegroupsController.php b/application/controllers/ServicegroupsController.php index 47fc75fc..81003c67 100644 --- a/application/controllers/ServicegroupsController.php +++ b/application/controllers/ServicegroupsController.php @@ -5,12 +5,15 @@ namespace Icinga\Module\Icingadb\Controllers; use Icinga\Module\Icingadb\Model\ServicegroupSummary; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\ItemList\ServicegroupList; +use Icinga\Module\Icingadb\Widget\ShowMore; +use ipl\Web\Url; class ServicegroupsController extends Controller { public function indexAction() { $this->setTitle($this->translate('Service Groups')); + $compact = $this->view->compact; $db = $this->getDb(); @@ -30,6 +33,8 @@ class ServicegroupsController extends Controller $this->filter($servicegroups); + $servicegroups->peekAhead($compact); + yield $this->export($servicegroups); $this->addControl($paginationControl); @@ -37,10 +42,23 @@ class ServicegroupsController extends Controller $this->addControl($limitControl); $this->addControl($filterControl); + $results = $servicegroups->execute(); + $this->addContent( - (new ServicegroupList($servicegroups))->setBaseFilter($this->getFilter()) + (new ServicegroupList($results))->setBaseFilter($this->getFilter()) ); + if ($compact) { + $this->addContent( + (new ShowMore($results, Url::fromRequest()->without(['view', 'limit']))) + ->setAttribute('data-base-target', '_next') + ->setAttribute('title', sprintf( + $this->translate('Show all %d servicegroups'), + $servicegroups->count() + )) + ); + } + $this->setAutorefreshInterval(30); } }