From e1a107ddde3d40d169530fa178ae5b74b8aed46e Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 15 Jan 2020 09:54:32 +0100 Subject: [PATCH] HostsController: Prefer to use the `ShowMore` widget --- application/controllers/HostsController.php | 23 ++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/application/controllers/HostsController.php b/application/controllers/HostsController.php index 27a84e66..7ac90756 100644 --- a/application/controllers/HostsController.php +++ b/application/controllers/HostsController.php @@ -15,10 +15,8 @@ use Icinga\Module\Icingadb\Widget\Detail\MultiselectQuickActions; use Icinga\Module\Icingadb\Widget\Detail\ObjectsDetail; use Icinga\Module\Icingadb\Widget\HostList; use Icinga\Module\Icingadb\Widget\HostStatusBar; +use Icinga\Module\Icingadb\Widget\ShowMore; use ipl\Orm\Compat\FilterProcessor; -use ipl\Web\Widget\ActionLink; -use IteratorIterator; -use LimitIterator; class HostsController extends Controller { @@ -92,8 +90,12 @@ class HostsController extends Controller $this->filter($hosts); $this->filter($summary); + $hosts->limit(3); + $hosts->peekAhead(); + yield $this->export($hosts, $summary); + $results = $hosts->execute(); $summary = $summary->first(); $downtimes = Host::on($db)->with(['downtime']); @@ -107,17 +109,14 @@ class HostsController extends Controller $summary->comments_total = $comments->count(); $this->addControl( - (new HostList(new LimitIterator(new IteratorIterator($hosts), 0, 3))) + (new HostList($results)) ->setViewMode('minimal') ); - if ($hosts->count() > 3) { - $this->addControl(new ActionLink( - sprintf($this->translate('Show all %d hosts'), $hosts->count()), - Links::hosts()->setQueryString($this->getFilter()->toQueryString()), - null, - ['class' => 'show-more'] - )); - } + $this->addControl(new ShowMore( + $results, + Links::hosts()->setQueryString($this->getFilter()->toQueryString()), + sprintf($this->translate('Show all %d hosts'), $hosts->count()) + )); $this->addControl( (new MultiselectQuickActions('host', $hosts, $summary)) ->setBaseFilter($this->getFilter())