node: add new url for simulation and editing

This commit is contained in:
Thomas Gelf 2014-11-30 12:20:55 +01:00
parent f2989790f2
commit 5cea970d8b
3 changed files with 61 additions and 0 deletions

View file

@ -0,0 +1,47 @@
<?php
use Icinga\Module\Bpapp\Controller;
use Icinga\Module\Bpapp\Forms\ProcessForm;
use Icinga\Module\Bpapp\Forms\SimulationForm;
use Icinga\Web\Url;
class Bpapp_NodeController extends Controller
{
public function editAction()
{
$bp = $this->loadBp();
$node = $bp->getNode($this->getParam('node'));
$form = new ProcessForm();
$form->setBackend($this->backend)
->setProcess($bp)
->setNode($node)
->handleRequest();
$this->view->form = $form;
$this->view->node = $node;
}
public function simulateAction()
{
$bp = $this->loadBp();
$nodename = $this->getParam('node');
$node = $bp->getNode($nodename);
$detail = Url::fromPath(
'bpapp/node/simulate',
array('node' => $nodename)
);
$form = new SimulationForm();
$form->setBackend($this->backend)
->setProcess($bp)
->setSession($this->session())
->setNode($node)
// TODO: find a better way to handle redirects
->setRedirectUrl('bpapp/process/simulate#!' . $detail->getAbsoluteUrl())
->handleRequest();
$this->view->form = $form;
$this->view->node = $node;
}
}

View file

@ -0,0 +1,10 @@
<?php
use Icinga\Module\Bpapp\HostNode;
use Icinga\Module\Bpapp\ServiceNode;
use Icinga\Module\Bpapp\BpNode;
?><div class="content">
<h1><?= $this->escape($node) ?></h1>
<?= $this->form ?>
</div>

View file

@ -0,0 +1,4 @@
<div class="content">
<h1>BI Simulation: <?= $this->escape(preg_replace('/;/', ' - ', $this->node)) ?></h1>
<?= $this->form ?>
</div>