ServicegroupsController: Add show more widget in compact mode

This commit is contained in:
Johannes Meyer 2020-01-31 15:57:28 +01:00
parent 585e65817d
commit 1f5d57165b

View file

@ -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);
}
}