2017-01-10 10:49:53 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Businessprocess\Controllers;
|
|
|
|
|
|
|
|
|
|
use Icinga\Module\Businessprocess\Renderer\Breadcrumb;
|
|
|
|
|
use Icinga\Module\Businessprocess\Renderer\TileRenderer;
|
2017-01-11 10:55:05 -05:00
|
|
|
use Icinga\Module\Businessprocess\Simulation;
|
|
|
|
|
use Icinga\Module\Businessprocess\State\MonitoringState;
|
2017-01-10 10:49:53 -05:00
|
|
|
use Icinga\Module\Businessprocess\Web\Controller;
|
|
|
|
|
use Icinga\Module\Businessprocess\Web\Url;
|
|
|
|
|
|
|
|
|
|
class NodeController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function impactAction()
|
|
|
|
|
{
|
2017-01-11 10:55:05 -05:00
|
|
|
$this->setAutorefreshInterval(10);
|
2017-01-10 10:49:53 -05:00
|
|
|
$content = $this->content();
|
|
|
|
|
$this->controls()->add(
|
|
|
|
|
$this->singleTab($this->translate('Node Impact'))
|
|
|
|
|
);
|
|
|
|
|
$name = $this->params->get('name');
|
|
|
|
|
$this->addTitle($this->translate('Business Impact (%s)'), $name);
|
|
|
|
|
|
2017-01-26 15:37:09 -05:00
|
|
|
$simulation = Simulation::fromSession($this->session());
|
2017-01-10 10:49:53 -05:00
|
|
|
foreach ($this->storage()->listProcessNames() as $configName) {
|
|
|
|
|
$config = $this->storage()->loadProcess($configName);
|
|
|
|
|
|
|
|
|
|
// TODO: Fix issues with children, they do not exist unless resolved :-/
|
|
|
|
|
// This is a workaround:
|
|
|
|
|
foreach ($config->getRootNodes() as $node) {
|
|
|
|
|
$node->getState();
|
|
|
|
|
}
|
2017-01-11 10:55:05 -05:00
|
|
|
foreach ($config->getRootNodes() as $node) {
|
|
|
|
|
$node->clearState();
|
|
|
|
|
}
|
2017-01-10 10:49:53 -05:00
|
|
|
|
|
|
|
|
if (! $config->hasNode($name)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-11 10:55:05 -05:00
|
|
|
MonitoringState::apply($config);
|
|
|
|
|
$config->applySimulation($simulation);
|
|
|
|
|
|
2017-01-10 10:49:53 -05:00
|
|
|
foreach ($config->getNode($name)->getPaths() as $path) {
|
2017-01-27 09:01:48 -05:00
|
|
|
array_pop($path);
|
2017-01-10 10:49:53 -05:00
|
|
|
$node = array_pop($path);
|
|
|
|
|
$renderer = new TileRenderer($config, $config->getNode($node));
|
|
|
|
|
$renderer->setUrl(
|
|
|
|
|
Url::fromPath(
|
|
|
|
|
'businessprocess/process/show',
|
|
|
|
|
array('config' => $configName)
|
|
|
|
|
)
|
|
|
|
|
)->setPath($path);
|
|
|
|
|
|
|
|
|
|
$bc = Breadcrumb::create($renderer);
|
|
|
|
|
$bc->attributes()->set('data-base-target', '_next');
|
|
|
|
|
$content->add($bc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|