icingadb-web/application/controllers/ServicesController.php

59 lines
1.9 KiB
PHP
Raw Normal View History

2019-10-09 11:25:39 -04:00
<?php
2019-11-04 19:07:30 -05:00
namespace Icinga\Module\Icingadb\Controllers;
2019-10-09 11:25:39 -04:00
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Icingadb\Model\ServicestateSummary;
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\ServiceList;
2019-10-09 11:25:39 -04:00
class ServicesController extends Controller
{
public function indexAction()
{
$this->setTitle($this->translate('Services'));
$db = $this->getDb();
$services = Service::on($db)->with([
'state',
2019-10-10 09:13:27 -04:00
'host',
'host.state'
2019-10-09 11:25:39 -04:00
]);
$summary = ServicestateSummary::on($db)->with('state');
2019-10-09 11:25:39 -04:00
$limitControl = $this->createLimitControl();
2019-10-15 09:29:36 -04:00
$paginationControl = $this->createPaginationControl($services);
2019-12-11 07:59:39 -05:00
$sortControl = $this->createSortControl(
$services,
[
'service.display_name, host.display_name' => $this->translate('Name'),
'service.state.severity desc' => $this->translate('Severity'),
'service.state.soft_state' => $this->translate('Current State'),
'service.state.last_state_change desc' => $this->translate('Last State Change'),
'host.display_name, service.display_name' => $this->translate('Host')
]
);
2019-10-15 09:29:36 -04:00
$viewModeSwitcher = $this->createViewModeSwitcher();
2019-10-18 02:44:38 -04:00
$filterControl = $this->createFilterControl($services);
2019-10-09 11:25:39 -04:00
2019-10-16 03:22:05 -04:00
$this->filter($services);
$this->filter($summary);
2019-10-16 03:22:05 -04:00
yield $this->export($services, $summary);
2019-10-09 11:25:39 -04:00
$serviceList = (new ServiceList($services))
->setViewMode($viewModeSwitcher->getViewMode());
2019-10-15 09:29:36 -04:00
$this->addControl($paginationControl);
2019-12-11 07:59:39 -05:00
$this->addControl($sortControl);
2019-10-09 11:25:39 -04:00
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
2019-10-18 02:44:38 -04:00
$this->addControl($filterControl);
2019-10-09 11:25:39 -04:00
$this->addContent($serviceList);
$this->setAutorefreshInterval(10);
2019-10-09 11:25:39 -04:00
}
}