icingadb-web/application/controllers/ServicesController.php
2019-11-05 13:00:56 +01:00

45 lines
1.3 KiB
PHP

<?php
namespace Icinga\Module\Icingadb\Controllers;
use Icinga\Module\Icingadb\Model\Service;
use Icinga\Module\Icingadb\Model\ServicestateSummary;
use Icinga\Module\Icingadb\Web\Controller;
use Icinga\Module\Icingadb\Widget\ServiceList;
class ServicesController extends Controller
{
public function indexAction()
{
$this->setTitle($this->translate('Services'));
$db = $this->getDb();
$services = Service::on($db)->with([
'state',
'host',
'host.state'
]);
$summary = ServicestateSummary::on($db)->with('state');
$limitControl = $this->createLimitControl();
$paginationControl = $this->createPaginationControl($services);
$viewModeSwitcher = $this->createViewModeSwitcher();
$filterControl = $this->createFilterControl($services);
$this->filter($services);
$this->filter($summary);
yield $this->export($services, $summary);
$serviceList = (new ServiceList($services))
->setViewMode($viewModeSwitcher->getViewMode());
$this->addControl($paginationControl);
$this->addControl($limitControl);
$this->addControl($viewModeSwitcher);
$this->addControl($filterControl);
$this->addContent($serviceList);
}
}