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

62 lines
1.9 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')));
}
$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()) {
$this->view->warnings = $bp->getWarings();
}
}
$this->setAutorefreshInterval(10);
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);
}
}
public function sourceAction()
{
$this->view->title = 'Source: ' . $this->bpconf->title;
$this->view->source = file_get_contents($this->filename);
}
}