ObjectsDetail: Load native detail hooks

This commit is contained in:
Johannes Meyer 2021-08-11 13:11:32 +02:00
parent fd07d9d6d7
commit 43327bcac8
3 changed files with 22 additions and 9 deletions

View file

@ -164,7 +164,7 @@ class HostsController extends Controller
);
$this->addContent(
(new ObjectsDetail('host', $summary))
(new ObjectsDetail('host', $summary, $hosts))
->setBaseFilter($this->getFilter())
);
}

View file

@ -175,7 +175,7 @@ class ServicesController extends Controller
);
$this->addContent(
(new ObjectsDetail('service', $summary))
(new ObjectsDetail('service', $summary, $services))
->setBaseFilter($this->getFilter())
);
}

View file

@ -8,6 +8,7 @@ use Icinga\Chart\Donut;
use Icinga\Module\Icingadb\Common\BaseFilter;
use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Forms\Command\Object\ToggleObjectFeaturesForm;
use Icinga\Module\Icingadb\Hook\ExtensionHook\ObjectsDetailExtensionHook;
use Icinga\Module\Icingadb\Util\FeatureStatus;
use Icinga\Module\Icingadb\Widget\EmptyState;
use Icinga\Module\Icingadb\Widget\HostStateBadges;
@ -25,15 +26,18 @@ class ObjectsDetail extends BaseHtmlElement
protected $summary;
protected $query;
protected $type;
protected $defaultAttributes = ['class' => 'objects-detail'];
protected $tag = 'div';
public function __construct($type, $summary)
public function __construct($type, $summary, $query)
{
$this->summary = $summary;
$this->query = $query;
$this->type = $type;
}
@ -148,6 +152,15 @@ class ObjectsDetail extends BaseHtmlElement
];
}
protected function createExtensions()
{
return ObjectsDetailExtensionHook::loadExtensions(
$this->type,
$this->query,
$this->getBaseFilter()
);
}
protected function createSummary()
{
return [
@ -158,11 +171,11 @@ class ObjectsDetail extends BaseHtmlElement
protected function assemble()
{
$this->add([
$this->createSummary(),
$this->createComments(),
$this->createDowntimes(),
$this->createFeatureToggles()
]);
$this->add(ObjectsDetailExtensionHook::injectExtensions([
190 => $this->createSummary(),
400 => $this->createComments(),
401 => $this->createDowntimes(),
701 => $this->createFeatureToggles()
], $this->createExtensions()));
}
}