Allow to show technical host details

This commit is contained in:
Johannes Meyer 2021-05-05 10:29:26 +02:00
parent c37fdffaba
commit f24ebd50da
3 changed files with 38 additions and 4 deletions

View file

@ -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)

View file

@ -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');

View file

@ -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;
}