icingadb-web/application/controllers/ServicegroupsController.php

70 lines
2.1 KiB
PHP
Raw Normal View History

2019-11-01 18:10:34 -04:00
<?php
2020-03-13 03:38:01 -04:00
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
2019-11-04 19:07:30 -05:00
namespace Icinga\Module\Icingadb\Controllers;
2019-11-01 18:10:34 -04:00
2019-11-05 03:22:58 -05:00
use Icinga\Module\Icingadb\Model\ServicegroupSummary;
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\ItemList\ServicegroupList;
use Icinga\Module\Icingadb\Widget\ShowMore;
use ipl\Web\Url;
2019-11-01 18:10:34 -04:00
class ServicegroupsController extends Controller
{
public function indexAction()
{
$this->setTitle(t('Service Groups'));
$compact = $this->view->compact;
2019-11-01 18:10:34 -04:00
$db = $this->getDb();
2019-11-05 03:22:58 -05:00
$servicegroups = ServicegroupSummary::on($db);
2019-11-01 18:10:34 -04:00
$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($servicegroups);
2019-12-11 07:57:13 -05:00
$sortControl = $this->createSortControl(
$servicegroups,
[
'display_name' => t('Name'),
'services_severity desc' => t('Severity'),
'services_total desc' => t('Total Services')
2019-12-11 07:57:13 -05:00
]
);
$filterControl = $this->createFilterControl($servicegroups, [
$limitControl->getLimitParam(),
$sortControl->getSortParam()
]);
2019-11-01 18:10:34 -04:00
$this->filter($servicegroups);
$servicegroups->peekAhead($compact);
2019-11-01 18:10:34 -04:00
yield $this->export($servicegroups);
$this->addControl($paginationControl);
2019-12-11 07:57:13 -05:00
$this->addControl($sortControl);
2019-11-01 18:10:34 -04:00
$this->addControl($limitControl);
$this->addControl($filterControl);
$results = $servicegroups->execute();
$this->addContent(
(new ServicegroupList($results))->setBaseFilter($this->getFilter())
);
if ($compact) {
$this->addContent(
(new ShowMore($results, Url::fromRequest()->without(['showCompact', 'limit'])))
->setAttribute('data-base-target', '_next')
->setAttribute('title', sprintf(
t('Show all %d servicegroups'),
$servicegroups->count()
))
);
}
$this->setAutorefreshInterval(30);
2019-11-01 18:10:34 -04:00
}
}