mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-18 23:16:16 -05:00
Add detail integration for Icinga DB Web
This commit is contained in:
parent
b2bc6b852e
commit
b8de4580da
2 changed files with 78 additions and 0 deletions
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Businessprocess\ProvidedHook\Icingadb;
|
||||||
|
|
||||||
|
use Icinga\Module\Businessprocess\Renderer\TileRenderer;
|
||||||
|
use Icinga\Module\Businessprocess\Renderer\TreeRenderer;
|
||||||
|
use Icinga\Module\Businessprocess\State\IcingaDbState;
|
||||||
|
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
|
||||||
|
use Icinga\Module\Businessprocess\Web\Url;
|
||||||
|
use Icinga\Module\Icingadb\Hook\ServiceDetailExtensionHook;
|
||||||
|
use Icinga\Module\Icingadb\Model\Service;
|
||||||
|
use ipl\Html\Html;
|
||||||
|
use ipl\Html\HtmlDocument;
|
||||||
|
use ipl\Html\HtmlString;
|
||||||
|
use ipl\Html\ValidHtml;
|
||||||
|
|
||||||
|
class ServiceDetailExtension extends ServiceDetailExtensionHook
|
||||||
|
{
|
||||||
|
/** @var LegacyStorage */
|
||||||
|
private $storage;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private $commandName;
|
||||||
|
|
||||||
|
protected function init()
|
||||||
|
{
|
||||||
|
$this->setSection(self::GRAPH_SECTION);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->storage = LegacyStorage::getInstance();
|
||||||
|
$this->commandName = $this->getModule()->getConfig()->get(
|
||||||
|
'DetailviewExtension',
|
||||||
|
'checkcommand_name',
|
||||||
|
'icingacli-businessprocess'
|
||||||
|
);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Ignore and don't display anything
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHtmlForObject(Service $service): ValidHtml
|
||||||
|
{
|
||||||
|
if (! isset($this->storage)
|
||||||
|
|| $service->checkcommand_name !== $this->commandName
|
||||||
|
) {
|
||||||
|
return HtmlString::create('');
|
||||||
|
}
|
||||||
|
|
||||||
|
$bpName = $service->customvars['businessprocess_config'] ?? null;
|
||||||
|
if (! $bpName) {
|
||||||
|
return HtmlString::create('');
|
||||||
|
}
|
||||||
|
|
||||||
|
$nodeName = $service->customvars['businessprocess_process'] ?? null;
|
||||||
|
if (! $nodeName) {
|
||||||
|
return HtmlString::create('');
|
||||||
|
}
|
||||||
|
|
||||||
|
$bp = $this->storage->loadProcess($bpName);
|
||||||
|
$node = $bp->getBpNode($nodeName);
|
||||||
|
|
||||||
|
IcingaDbState::apply($bp);
|
||||||
|
|
||||||
|
if ($service->customvars['businessprocess_as_tree'] ?? false) {
|
||||||
|
$renderer = new TreeRenderer($bp, $node);
|
||||||
|
$tag = 'ul';
|
||||||
|
} else {
|
||||||
|
$renderer = new TileRenderer($bp, $node);
|
||||||
|
$tag = 'div';
|
||||||
|
}
|
||||||
|
|
||||||
|
$renderer->setUrl(Url::fromPath('businessprocess/process/show?config=' . $bpName . '&node=' . $nodeName));
|
||||||
|
$renderer->ensureAssembled()->getFirst($tag)->setAttribute('data-base-target', '_next');
|
||||||
|
|
||||||
|
return (new HtmlDocument())->addHtml(Html::tag('h2', 'Business Process'), $renderer);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
run.php
1
run.php
|
|
@ -6,4 +6,5 @@ $this->provideHook('monitoring/DetailviewExtension');
|
||||||
$this->provideHook('icingadb/HostActions');
|
$this->provideHook('icingadb/HostActions');
|
||||||
$this->provideHook('icingadb/ServiceActions');
|
$this->provideHook('icingadb/ServiceActions');
|
||||||
$this->provideHook('icingadb/icingadbSupport');
|
$this->provideHook('icingadb/icingadbSupport');
|
||||||
|
$this->provideHook('icingadb/ServiceDetailExtension');
|
||||||
//$this->provideHook('director/shipConfigFiles');
|
//$this->provideHook('director/shipConfigFiles');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue