mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-20 23:00:16 -05:00
Process: add and use new form
This commit is contained in:
parent
991d9f9b05
commit
c11a181701
9 changed files with 64 additions and 7 deletions
|
|
@ -53,6 +53,7 @@ class ProcessController extends Controller
|
||||||
public function showAction()
|
public function showAction()
|
||||||
{
|
{
|
||||||
$mode = $this->params->get('mode');
|
$mode = $this->params->get('mode');
|
||||||
|
$action = $this->params->get('action');
|
||||||
$unlocked = (bool) $this->params->get('unlocked');
|
$unlocked = (bool) $this->params->get('unlocked');
|
||||||
$this->prepareProcessActions();
|
$this->prepareProcessActions();
|
||||||
$this->prepareProcess();
|
$this->prepareProcess();
|
||||||
|
|
@ -117,7 +118,7 @@ class ProcessController extends Controller
|
||||||
} else {
|
} else {
|
||||||
$renderer = new TreeRenderer($bp, $bpNode);
|
$renderer = new TreeRenderer($bp, $bpNode);
|
||||||
}
|
}
|
||||||
$renderer->setBaseUrl($this->url())
|
$renderer->setUrl($this->url())
|
||||||
->setPath($this->params->getValues('path'));
|
->setPath($this->params->getValues('path'));
|
||||||
$this->content()->add($renderer);
|
$this->content()->add($renderer);
|
||||||
$controls = $this->controls();
|
$controls = $this->controls();
|
||||||
|
|
@ -147,6 +148,28 @@ class ProcessController extends Controller
|
||||||
$renderer->unlock();
|
$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->isXhr()) {
|
||||||
if ($this->params->get('addSimulation')) {
|
if ($this->params->get('addSimulation')) {
|
||||||
$this->setAutorefreshInterval(30);
|
$this->setAutorefreshInterval(30);
|
||||||
|
|
@ -206,7 +229,7 @@ class ProcessController extends Controller
|
||||||
$this->actions()->add(
|
$this->actions()->add(
|
||||||
Link::create(
|
Link::create(
|
||||||
$this->translate('Lock'),
|
$this->translate('Lock'),
|
||||||
$this->url()->without('unlocked'),
|
$this->url()->without('unlocked')->without('action'),
|
||||||
null,
|
null,
|
||||||
array(
|
array(
|
||||||
'class' => 'icon-lock',
|
'class' => 'icon-lock',
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class AddNodeForm extends QuickForm
|
||||||
|
|
||||||
public function setup()
|
public function setup()
|
||||||
{
|
{
|
||||||
$type = $this->selectNodeType();
|
$type = $this->selectNodeType();
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'host':
|
case 'host':
|
||||||
$this->selectHost();
|
$this->selectHost();
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,7 @@ class BpConfigForm extends QuickForm
|
||||||
|
|
||||||
$this->redirectOnSuccess(sprintf('Process %s has been created', $name));
|
$this->redirectOnSuccess(sprintf('Process %s has been created', $name));
|
||||||
} else {
|
} else {
|
||||||
|
$config = $this->config;
|
||||||
if ($title) {
|
if ($title) {
|
||||||
$config->setTitle($title);
|
$config->setTitle($title);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,9 @@ class Controller extends ModuleController
|
||||||
return $this->view->controls;
|
return $this->view->controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Content
|
||||||
|
*/
|
||||||
protected function content()
|
protected function content()
|
||||||
{
|
{
|
||||||
if ($this->view->content === null) {
|
if ($this->view->content === null) {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ namespace Icinga\Module\Businessprocess\Modification;
|
||||||
use Icinga\Module\Businessprocess\BusinessProcess;
|
use Icinga\Module\Businessprocess\BusinessProcess;
|
||||||
use Icinga\Module\Businessprocess\BpNode;
|
use Icinga\Module\Businessprocess\BpNode;
|
||||||
use Icinga\Module\Businessprocess\Node;
|
use Icinga\Module\Businessprocess\Node;
|
||||||
use stdClass;
|
|
||||||
|
|
||||||
class NodeCreateAction extends NodeAction
|
class NodeCreateAction extends NodeAction
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,19 @@ class ProcessChanges
|
||||||
return $this->push($action);
|
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 Node|string $nodeName
|
||||||
* @param object $properties
|
* @param object $properties
|
||||||
|
|
|
||||||
|
|
@ -298,7 +298,7 @@ abstract class Node
|
||||||
return static::$stateToSortStateMap[$state];
|
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)
|
protected function sortStateTostate($sortState)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ use Icinga\Module\Businessprocess\Html\Container;
|
||||||
use Icinga\Module\Businessprocess\Html\Element;
|
use Icinga\Module\Businessprocess\Html\Element;
|
||||||
use Icinga\Module\Businessprocess\Html\Html;
|
use Icinga\Module\Businessprocess\Html\Html;
|
||||||
use Icinga\Module\Businessprocess\Html\HtmlString;
|
use Icinga\Module\Businessprocess\Html\HtmlString;
|
||||||
use Icinga\Module\Businessprocess\Html\Text;
|
|
||||||
use Icinga\Module\Businessprocess\Node;
|
use Icinga\Module\Businessprocess\Node;
|
||||||
use Icinga\Module\Businessprocess\Web\Url;
|
use Icinga\Module\Businessprocess\Web\Url;
|
||||||
use Icinga\Web\Request;
|
use Icinga\Web\Request;
|
||||||
|
|
@ -26,6 +25,9 @@ abstract class Renderer extends Html
|
||||||
/** @var bool Administrative actions are hidden unless unlocked */
|
/** @var bool Administrative actions are hidden unless unlocked */
|
||||||
protected $locked = true;
|
protected $locked = true;
|
||||||
|
|
||||||
|
/** @var Url */
|
||||||
|
protected $url;
|
||||||
|
|
||||||
/** @var Url */
|
/** @var Url */
|
||||||
protected $baseUrl;
|
protected $baseUrl;
|
||||||
|
|
||||||
|
|
@ -162,6 +164,17 @@ abstract class Renderer extends Html
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Url $url
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setUrl(Url $url)
|
||||||
|
{
|
||||||
|
$this->url = clone($url);
|
||||||
|
$this->setBaseUrl($url);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Url $url
|
* @param Url $url
|
||||||
* @return $this
|
* @return $this
|
||||||
|
|
@ -172,6 +185,11 @@ abstract class Renderer extends Html
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUrl()
|
||||||
|
{
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Url
|
* @return Url
|
||||||
* @throws ProgrammingError
|
* @throws ProgrammingError
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ class AndOperatorTest extends BaseTestCase
|
||||||
$p->addChild($host);
|
$p->addChild($host);
|
||||||
$p->addChild($service);
|
$p->addChild($service);
|
||||||
|
|
||||||
$this->assertEquals('DOWN',$host->getStateName());
|
$this->assertEquals('DOWN', $host->getStateName());
|
||||||
$this->assertEquals('WARNING', $service->getStateName());
|
$this->assertEquals('WARNING', $service->getStateName());
|
||||||
$this->assertEquals('WARNING', $p->getStateName());
|
$this->assertEquals('WARNING', $p->getStateName());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue