diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index 9f4a753c..9eaf208a 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -5,6 +5,8 @@ namespace Icinga\Module\Icingadb\Controllers; use Icinga\Exception\NotFoundError; +use Icinga\Module\Icingadb\Command\Object\GetObjectCommand; +use Icinga\Module\Icingadb\Command\Transport\CommandTransport; use Icinga\Module\Icingadb\Common\CommandActions; use Icinga\Module\Icingadb\Common\HostLinks; use Icinga\Module\Icingadb\Common\Links; @@ -14,6 +16,7 @@ use Icinga\Module\Icingadb\Model\Service; use Icinga\Module\Icingadb\Model\ServicestateSummary; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\Detail\HostDetail; +use Icinga\Module\Icingadb\Widget\Detail\HostInspectionDetail; use Icinga\Module\Icingadb\Widget\Detail\QuickActions; use Icinga\Module\Icingadb\Widget\DowntimeList; use Icinga\Module\Icingadb\Widget\HostList; @@ -73,6 +76,24 @@ class HostController extends Controller $this->setAutorefreshInterval(10); } + public function sourceAction() + { + $this->assertPermission('icingadb/object/show-source'); + $apiResult = (new CommandTransport())->send((new GetObjectCommand())->setObject($this->host)); + + if ($this->host->state->is_overdue) { + $this->controls->addAttributes(['class' => 'overdue']); + } + + $this->addControl((new HostList([$this->host])) + ->setDetailActionsDisabled() + ->setNoSubjectLink()); + $this->addContent(new HostInspectionDetail( + $this->host, + reset($apiResult) + )); + } + public function commentsAction() { $this->setTitle(t('Comments')); @@ -231,8 +252,7 @@ class HostController extends Controller protected function createTabs() { - return $this - ->getTabs() + $tabs = $this->getTabs() ->add('index', [ 'label' => t('Host'), 'url' => Links::host($this->host) @@ -245,6 +265,15 @@ class HostController extends Controller 'label' => t('History'), 'url' => HostLinks::history($this->host) ]); + + if ($this->hasPermission('icingadb/object/show-source')) { + $tabs->add('source', [ + 'label' => t('Source'), + 'url' => Links::hostSource($this->host) + ]); + } + + return $tabs; } protected function setTitleTab($name) diff --git a/library/Icingadb/Common/Links.php b/library/Icingadb/Common/Links.php index b1d8e339..f206c5aa 100644 --- a/library/Icingadb/Common/Links.php +++ b/library/Icingadb/Common/Links.php @@ -7,7 +7,6 @@ namespace Icinga\Module\Icingadb\Common; use Icinga\Module\Icingadb\Model\Comment; use Icinga\Module\Icingadb\Model\Downtime; use Icinga\Module\Icingadb\Model\Host; -use Icinga\Module\Icingadb\Model\Hostgroup; use Icinga\Module\Icingadb\Model\Service; use Icinga\Module\Icingadb\Model\Servicegroup; use Icinga\Module\Icingadb\Model\User; @@ -61,6 +60,11 @@ abstract class Links return Url::fromPath('icingadb/host', ['name' => $host->name]); } + public static function hostSource(Host $host) + { + return Url::fromPath('icingadb/host/source', ['name' => $host->name]); + } + public static function hostsDetails() { return Url::fromPath('icingadb/hosts/details'); diff --git a/public/css/common.less b/public/css/common.less index 14e75a6d..4b85659a 100644 --- a/public/css/common.less +++ b/public/css/common.less @@ -167,7 +167,8 @@ div.show-more { .content > h2:first-child, .host-detail > h2:first-child, .comment-detail > h2:first-child, -.downtime-detail > h2:first-child { +.downtime-detail > h2:first-child, +.inspection-detail > h2:first-child { margin-top: 0; }