mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-25 05:22:53 -05:00
BpNode, process/show: error for missing children...
...and unknown as state fixes #105
This commit is contained in:
parent
2f3e5fb419
commit
9750e13234
3 changed files with 32 additions and 0 deletions
|
|
@ -96,8 +96,13 @@ class ProcessController extends Controller
|
|||
}
|
||||
|
||||
$this->prepareControls($bp, $renderer);
|
||||
$missing = $bp->getMissingChildren();
|
||||
if (! empty($missing)) {
|
||||
$bp->addError(sprintf('There are missing nodes: %s', implode(', ', $missing)));
|
||||
}
|
||||
$this->content()->addContent($this->showHints($bp));
|
||||
$this->content()->addContent($this->showWarnings($bp));
|
||||
$this->content()->addContent($this->showErrors($bp));
|
||||
$this->content()->add($renderer);
|
||||
$this->loadActionForm($bp, $node);
|
||||
$this->setDynamicAutorefresh();
|
||||
|
|
@ -264,6 +269,20 @@ class ProcessController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
protected function showErrors(BpConfig $bp)
|
||||
{
|
||||
if ($bp->hasWarnings()) {
|
||||
$ul = Element::create('ul', array('class' => 'error'));
|
||||
foreach ($bp->getErrors() as $msg) {
|
||||
$ul->createElement('li')->addContent($msg);
|
||||
}
|
||||
|
||||
return $ul;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected function showHints(BpConfig $bp)
|
||||
{
|
||||
$ul = Element::create('ul', array('class' => 'error'));
|
||||
|
|
|
|||
|
|
@ -464,6 +464,16 @@ class BpConfig
|
|||
return $this->createBp($name)->setMissing();
|
||||
}
|
||||
|
||||
public function getMissingChildren()
|
||||
{
|
||||
$missing = array();
|
||||
foreach ($this->getRootNodes() as $root) {
|
||||
$missing += $root->getMissingChildren();
|
||||
}
|
||||
|
||||
return $missing;
|
||||
}
|
||||
|
||||
public function createImportedNode($config, $name = null)
|
||||
{
|
||||
$params = (object) array('configName' => $config);
|
||||
|
|
|
|||
|
|
@ -336,6 +336,9 @@ class BpNode extends Node
|
|||
$sort_states[] = $child->getSortingState();
|
||||
$lastStateChange = max($lastStateChange, $child->getLastStateChange());
|
||||
$bp->endLoopDetection($this->name);
|
||||
if ($child instanceof MonitoredNode && $child->isMissing()) {
|
||||
$child->setState(self::ICINGA_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
$this->setLastStateChange($lastStateChange);
|
||||
|
|
|
|||
Loading…
Reference in a new issue