2019-10-09 11:26:40 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Eagle\Controllers;
|
|
|
|
|
|
|
|
|
|
use Icinga\Exception\NotFoundError;
|
2019-10-10 07:41:12 -04:00
|
|
|
use Icinga\Module\Eagle\Common\CommandActions;
|
2019-11-03 15:52:41 -05:00
|
|
|
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;
|
2019-10-24 08:59:09 -04:00
|
|
|
use ipl\Web\Url;
|
2019-10-09 11:26:40 -04:00
|
|
|
|
|
|
|
|
class HostController extends Controller
|
|
|
|
|
{
|
2019-10-10 07:41:12 -04:00
|
|
|
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'));
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-10 07:41:12 -04:00
|
|
|
$this->host = $host;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-24 08:59:09 -04:00
|
|
|
protected function getCommandTargetsUrl()
|
|
|
|
|
{
|
2019-11-03 15:52:41 -05:00
|
|
|
return Links::host($this->host);
|
2019-10-24 08:59:09 -04:00
|
|
|
}
|
|
|
|
|
|
2019-10-10 07:41:12 -04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|