diff --git a/library/Businessprocess/ProvidedHook/Monitoring/DetailviewExtension.php b/library/Businessprocess/ProvidedHook/Monitoring/DetailviewExtension.php index a911f45..c781504 100644 --- a/library/Businessprocess/ProvidedHook/Monitoring/DetailviewExtension.php +++ b/library/Businessprocess/ProvidedHook/Monitoring/DetailviewExtension.php @@ -1,20 +1,18 @@ storage = new LegacyStorage( - Config::module('businessprocess')->getSection('global') + $this->getModule()->getConfig()->getSection('global') ); } catch (\Exception $e) { // Ignore and don't display anything } - - $this->hasPreviews = true; } - /** - * Returns false if the MonitoredObject is not a service or the check_command is not icingacli-businessprocess - * - * @param MonitoredObject $object - * @return bool - */ - public function has(MonitoredObject $object) - { - return $object instanceof Service && $object->check_command == 'icingacli-businessprocess'; - } - - /** * Returns the rendered Tree-/TileRenderer HTML * * @param MonitoredObject $object + * * @return string - * @throws \Icinga\Exception\ProgrammingError */ - public function getPreviewHtml(MonitoredObject $object) + public function getHtmlForObject(MonitoredObject $object) { - if (!$this->has($object) || !$this->storage) { + if (! isset($this->storage) + || ! $object instanceof Service + || $object->check_command !== 'icingacli-businessprocess' + ) { return ''; } $bpName = $object->_service_icingacli_businessprocess_process; + if (! $bpName) { + return ''; + } + $bp = $this->storage->loadProcess($bpName); MonitoringState::apply($bp); if (filter_var($object->_service_icingacli_businessprocess_grapher_tree, FILTER_VALIDATE_BOOLEAN)) { $renderer = new TreeRenderer($bp); + $tag = 'ul'; } else { $renderer = new TileRenderer($bp); + $tag = 'div'; } - $renderer->setBaseUrl(Url::fromPath('businessprocess/process/show?config=' . $bpName . '&node=' . $bpName)); + $renderer->setUrl(Url::fromPath('businessprocess/process/show?config=' . $bpName . '&node=' . $bpName)); + $renderer->ensureAssembled()->getFirst($tag)->setAttribute('data-base-target', '_next'); - $html = '