diff --git a/application/controllers/ProcessController.php b/application/controllers/ProcessController.php index 9647aaa..8225297 100644 --- a/application/controllers/ProcessController.php +++ b/application/controllers/ProcessController.php @@ -53,6 +53,7 @@ class ProcessController extends Controller public function showAction() { $mode = $this->params->get('mode'); + $action = $this->params->get('action'); $unlocked = (bool) $this->params->get('unlocked'); $this->prepareProcessActions(); $this->prepareProcess(); @@ -117,7 +118,7 @@ class ProcessController extends Controller } else { $renderer = new TreeRenderer($bp, $bpNode); } - $renderer->setBaseUrl($this->url()) + $renderer->setUrl($this->url()) ->setPath($this->params->getValues('path')); $this->content()->add($renderer); $controls = $this->controls(); @@ -147,6 +148,28 @@ class ProcessController extends Controller $renderer->unlock(); } + if ($action === 'add') { + $this->content()->add(HtmlString::create( + (string) $this->loadForm('AddNode') + ->setProcess($bp) + ->setParentNode($bp->getNode($node)) + ->setSession($this->session()) + ->handleRequest() + )); + } elseif ($action === 'simulation') { + $this->content()->add(HtmlString::create( + $this->loadForm('simulation') + ->setSimulation(new Simulation($bp, $this->session())) + ->setNode($node) + ->handleRequest() + )); + } + + if ($action) { + // No autorefresh when showing forms + return; + } + if ($this->isXhr()) { if ($this->params->get('addSimulation')) { $this->setAutorefreshInterval(30); @@ -206,7 +229,7 @@ class ProcessController extends Controller $this->actions()->add( Link::create( $this->translate('Lock'), - $this->url()->without('unlocked'), + $this->url()->without('unlocked')->without('action'), null, array( 'class' => 'icon-lock', diff --git a/application/forms/AddNodeForm.php b/application/forms/AddNodeForm.php index efc89d6..1627a1b 100644 --- a/application/forms/AddNodeForm.php +++ b/application/forms/AddNodeForm.php @@ -30,7 +30,7 @@ class AddNodeForm extends QuickForm public function setup() { - $type = $this->selectNodeType(); + $type = $this->selectNodeType(); switch ($type) { case 'host': $this->selectHost(); diff --git a/application/forms/BpConfigForm.php b/application/forms/BpConfigForm.php index abf3111..5382673 100644 --- a/application/forms/BpConfigForm.php +++ b/application/forms/BpConfigForm.php @@ -167,6 +167,7 @@ class BpConfigForm extends QuickForm $this->redirectOnSuccess(sprintf('Process %s has been created', $name)); } else { + $config = $this->config; if ($title) { $config->setTitle($title); } diff --git a/library/Businessprocess/Controller.php b/library/Businessprocess/Controller.php index 44da2bb..0ec129c 100644 --- a/library/Businessprocess/Controller.php +++ b/library/Businessprocess/Controller.php @@ -100,6 +100,9 @@ class Controller extends ModuleController return $this->view->controls; } + /** + * @return Content + */ protected function content() { if ($this->view->content === null) { diff --git a/library/Businessprocess/Modification/NodeCreateAction.php b/library/Businessprocess/Modification/NodeCreateAction.php index b47dacb..4d970dc 100644 --- a/library/Businessprocess/Modification/NodeCreateAction.php +++ b/library/Businessprocess/Modification/NodeCreateAction.php @@ -5,7 +5,6 @@ namespace Icinga\Module\Businessprocess\Modification; use Icinga\Module\Businessprocess\BusinessProcess; use Icinga\Module\Businessprocess\BpNode; use Icinga\Module\Businessprocess\Node; -use stdClass; class NodeCreateAction extends NodeAction { diff --git a/library/Businessprocess/Modification/ProcessChanges.php b/library/Businessprocess/Modification/ProcessChanges.php index 452bd4a..2adcb25 100644 --- a/library/Businessprocess/Modification/ProcessChanges.php +++ b/library/Businessprocess/Modification/ProcessChanges.php @@ -64,6 +64,19 @@ class ProcessChanges return $this->push($action); } + /** + * @param Node $node + * @param $properties + * + * @return $this + */ + public function addChildrenToNode(Node $node, $children) + { + $action = new NodeAddChildrenAction($node); + $action->setChildren($node, $children); + return $this->push($action); + } + /** * @param Node|string $nodeName * @param object $properties diff --git a/library/Businessprocess/Node.php b/library/Businessprocess/Node.php index 4c99d35..8ba84f1 100644 --- a/library/Businessprocess/Node.php +++ b/library/Businessprocess/Node.php @@ -298,7 +298,7 @@ abstract class Node return static::$stateToSortStateMap[$state]; } - throw new ProgrammingError('Got invalid state: %s', var_export($state, 1)); + throw new ProgrammingError('Got invalid state: %s', var_export($state, 1)); } protected function sortStateTostate($sortState) diff --git a/library/Businessprocess/Renderer/Renderer.php b/library/Businessprocess/Renderer/Renderer.php index ba3088a..6b87432 100644 --- a/library/Businessprocess/Renderer/Renderer.php +++ b/library/Businessprocess/Renderer/Renderer.php @@ -10,7 +10,6 @@ use Icinga\Module\Businessprocess\Html\Container; use Icinga\Module\Businessprocess\Html\Element; use Icinga\Module\Businessprocess\Html\Html; use Icinga\Module\Businessprocess\Html\HtmlString; -use Icinga\Module\Businessprocess\Html\Text; use Icinga\Module\Businessprocess\Node; use Icinga\Module\Businessprocess\Web\Url; use Icinga\Web\Request; @@ -26,6 +25,9 @@ abstract class Renderer extends Html /** @var bool Administrative actions are hidden unless unlocked */ protected $locked = true; + /** @var Url */ + protected $url; + /** @var Url */ protected $baseUrl; @@ -162,6 +164,17 @@ abstract class Renderer extends Html return $path; } + /** + * @param Url $url + * @return $this + */ + public function setUrl(Url $url) + { + $this->url = clone($url); + $this->setBaseUrl($url); + return $this; + } + /** * @param Url $url * @return $this @@ -172,6 +185,11 @@ abstract class Renderer extends Html return $this; } + public function getUrl() + { + return $this->url; + } + /** * @return Url * @throws ProgrammingError diff --git a/test/php/library/Businessprocess/Operators/AndOperatorTest.php b/test/php/library/Businessprocess/Operators/AndOperatorTest.php index 9436184..8e88c39 100644 --- a/test/php/library/Businessprocess/Operators/AndOperatorTest.php +++ b/test/php/library/Businessprocess/Operators/AndOperatorTest.php @@ -138,7 +138,7 @@ class AndOperatorTest extends BaseTestCase $p->addChild($host); $p->addChild($service); - $this->assertEquals('DOWN',$host->getStateName()); + $this->assertEquals('DOWN', $host->getStateName()); $this->assertEquals('WARNING', $service->getStateName()); $this->assertEquals('WARNING', $p->getStateName()); }