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;
|
2020-01-31 09:57:28 -05:00
|
|
|
use Icinga\Module\Icingadb\Widget\ShowMore;
|
|
|
|
|
use ipl\Web\Url;
|
2019-11-01 18:10:34 -04:00
|
|
|
|
|
|
|
|
class ServicegroupsController extends Controller
|
|
|
|
|
{
|
2020-01-17 10:34:16 -05:00
|
|
|
public function indexAction()
|
|
|
|
|
{
|
2020-04-24 08:36:37 -04:00
|
|
|
$this->setTitle(t('Service Groups'));
|
2020-01-31 09:57:28 -05:00
|
|
|
$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,
|
|
|
|
|
[
|
2020-04-24 08:36:37 -04:00
|
|
|
'display_name' => t('Name'),
|
|
|
|
|
'services_severity desc' => t('Severity'),
|
|
|
|
|
'services_total desc' => t('Total Services')
|
2019-12-11 07:57:13 -05:00
|
|
|
]
|
|
|
|
|
);
|
2020-05-19 06:34:24 -04:00
|
|
|
$filterControl = $this->createFilterControl($servicegroups, [
|
|
|
|
|
$limitControl->getLimitParam(),
|
|
|
|
|
$sortControl->getSortParam()
|
|
|
|
|
]);
|
2019-11-01 18:10:34 -04:00
|
|
|
|
|
|
|
|
$this->filter($servicegroups);
|
|
|
|
|
|
2020-01-31 09:57:28 -05:00
|
|
|
$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);
|
|
|
|
|
|
2020-01-31 09:57:28 -05:00
|
|
|
$results = $servicegroups->execute();
|
|
|
|
|
|
2019-12-03 05:26:39 -05:00
|
|
|
$this->addContent(
|
2020-01-31 09:57:28 -05:00
|
|
|
(new ServicegroupList($results))->setBaseFilter($this->getFilter())
|
2019-12-03 05:26:39 -05:00
|
|
|
);
|
2019-12-11 02:59:30 -05:00
|
|
|
|
2020-01-31 09:57:28 -05:00
|
|
|
if ($compact) {
|
|
|
|
|
$this->addContent(
|
2020-06-04 03:54:55 -04:00
|
|
|
(new ShowMore($results, Url::fromRequest()->without(['showCompact', 'limit'])))
|
2020-01-31 09:57:28 -05:00
|
|
|
->setAttribute('data-base-target', '_next')
|
|
|
|
|
->setAttribute('title', sprintf(
|
2020-04-24 08:36:37 -04:00
|
|
|
t('Show all %d servicegroups'),
|
2020-01-31 09:57:28 -05:00
|
|
|
$servicegroups->count()
|
|
|
|
|
))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-11 02:59:30 -05:00
|
|
|
$this->setAutorefreshInterval(30);
|
2019-11-01 18:10:34 -04:00
|
|
|
}
|
|
|
|
|
}
|