icingaweb2-module-businessp.../application/controllers/ProcessController.php

62 lines
2 KiB
PHP
Raw Normal View History

<?php
2014-11-30 09:56:58 -05:00
use Icinga\Module\Businessprocess\Controller;
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
2014-11-30 09:56:58 -05:00
class Businessprocess_ProcessController extends Controller
{
public function showAction()
{
if ($this->getRequest()->isPost()) {
$this->redirectNow($this->getRequest()->getUrl()->with('processName', $this->getRequest()->getPost('processName')));
}
$this->view->compact = $this->params->get('view') === 'compact';
$storage = new LegacyStorage($this->Config()->getSection('global'));
$this->view->processList = $storage->listProcesses();
$process = $this->params->get('processName', key($this->view->processList));
$this->view->processName = $process;
$this->view->tabs = $this->tabs()->activate('show');
$this->view->title = 'Business Processes';
$bp = $this->loadBp();
if ($process = $this->params->get('process')) {
$this->view->bp = $bp->getNode($process);
} else {
$this->view->bp = $bp;
if ($bp->hasWarnings()) {
2015-01-28 13:50:52 -05:00
$this->view->warnings = $bp->getWarnings();
}
}
$this->setAutorefreshInterval(10);
2014-11-30 06:11:46 -05:00
if ($this->params->get('showSource')) {
$this->view->source = $bp->toLegacyConfigString();
$this->render('source');
}
2014-11-30 06:11:46 -05:00
if ($this->params->get('simulation')) {
$bp->setSimulationMode();
$this->addSimulation($bp);
}
2014-11-30 06:14:11 -05:00
if ($this->params->get('edit')) {
$bp->setEditMode();
}
2014-11-30 06:20:39 -05:00
if ($this->params->get('mode') === 'toplevel') {
$this->render('toplevel');
}
2014-11-30 06:18:04 -05:00
}
2014-11-30 06:14:11 -05:00
2014-11-30 06:18:04 -05:00
protected function addSimulation($bp)
{
$simulations = $this->session()->get('simulations', array());
foreach ($simulations as $node => $s) {
$bp->getNode($node)
->setState($s->state)
->setAck($s->acknowledged)
->setDowntime($s->in_downtime);
}
}
2015-01-28 13:50:52 -05:00
}