icingadb-web/application/controllers/HostController.php

59 lines
1.4 KiB
PHP
Raw Normal View History

2019-10-09 11:26:40 -04:00
<?php
namespace Icinga\Module\Eagle\Controllers;
use Icinga\Exception\NotFoundError;
use Icinga\Module\Eagle\Common\CommandActions;
use Icinga\Module\Eagle\Common\Links;
2019-10-09 11:26:40 -04:00
use Icinga\Module\Eagle\Model\Host;
use Icinga\Module\Eagle\Web\Controller;
2019-11-03 09:32:46 -05:00
use Icinga\Module\Eagle\Widget\Detail\ObjectDetail;
use Icinga\Module\Eagle\Widget\Detail\QuickActions;
use Icinga\Module\Eagle\Widget\HostList;
use ipl\Web\Url;
2019-10-09 11:26:40 -04:00
class HostController extends Controller
{
use CommandActions;
/** @var Host The host object */
protected $host;
public function init()
2019-10-09 11:26:40 -04:00
{
2019-11-03 09:33:06 -05:00
$this->setTitle($this->translate('Host'));
2019-10-09 11:26:40 -04:00
$name = $this->params->shiftRequired('name');
$query = Host::on($this->getDb())->with('state');
$query->getSelectBase()
->where(['name = ?' => $name]);
/** @var Host $host */
$host = $query->first();
if ($host === null) {
throw new NotFoundError($this->translate('Host not found'));
}
$this->host = $host;
}
protected function getCommandTargetsUrl()
{
return Links::host($this->host);
}
protected function fetchCommandTargets()
{
return [$this->host];
}
public function indexAction()
{
2019-11-03 09:32:46 -05:00
$this->addControl((new HostList([$this->host]))->setViewMode('compact'));
$this->addControl(new QuickActions($this->host));
$this->addContent(new ObjectDetail($this->host));
2019-10-09 11:26:40 -04:00
}
}