Use the new command-view scripts

This commit is contained in:
Johannes Meyer 2015-02-02 16:30:52 +01:00
parent 2e99e476fe
commit 8b377cd651
4 changed files with 88 additions and 4 deletions

View File

@ -12,7 +12,6 @@ use Icinga\Module\Monitoring\Forms\Command\Object\RemoveAcknowledgementCommandFo
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostCheckCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\ScheduleHostDowntimeCommandForm;
use Icinga\Module\Monitoring\Object\Host;
use Icinga\Module\Monitoring\Object\Service;
use Icinga\Module\Monitoring\Object\HostList;
use Icinga\Web\Url;
use Icinga\Web\Widget\Chart\InlinePie;
@ -33,12 +32,39 @@ class Monitoring_HostsController extends Controller
protected function handleCommandForm(ObjectsCommandForm $form)
{
$this->hostList->setColumns(array(
'host_name',
'host_state',
'host_problem',
'host_handled',
'host_acknowledged',
'host_in_downtime'
));
$form
->setObjects($this->hostList)
->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params))
->handleRequest();
$hostStates = array(
Host::getStateText(Host::STATE_UP) => 0,
Host::getStateText(Host::STATE_DOWN) => 0,
Host::getStateText(Host::STATE_UNREACHABLE) => 0,
Host::getStateText(Host::STATE_PENDING) => 0,
);
foreach ($this->hostList as $host) {
++$hostStates[$host::getStateText($host->state)];
}
$this->view->form = $form;
$this->_helper->viewRenderer('partials/command-form', null, true);
$this->view->objects = $this->hostList;
$this->view->hostStates = $hostStates;
$this->view->hostStatesPieChart = $this->createPieChart(
$hostStates,
$this->translate('Host State'),
array('#44bb77', '#FF5566', '#E066FF', '#77AAFF')
);
$this->_helper->viewRenderer('partials/command/objects-command-form', null, true);
return $form;
}

View File

@ -33,12 +33,59 @@ class Monitoring_ServicesController extends Controller
protected function handleCommandForm(ObjectsCommandForm $form)
{
$this->serviceList->setColumns(array(
'host_name',
'host_state',
'service_description',
'service_state',
'service_problem',
'service_handled',
'service_acknowledged',
'service_in_downtime'
));
$form
->setObjects($this->serviceList)
->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params))
->handleRequest();
$serviceStates = array(
Service::getStateText(Service::STATE_OK) => 0,
Service::getStateText(Service::STATE_WARNING) => 0,
Service::getStateText(Service::STATE_CRITICAL) => 0,
Service::getStateText(Service::STATE_UNKNOWN) => 0,
Service::getStateText(Service::STATE_PENDING) => 0
);
$knownHostStates = array();
$hostStates = array(
Host::getStateText(Host::STATE_UP) => 0,
Host::getStateText(Host::STATE_DOWN) => 0,
Host::getStateText(Host::STATE_UNREACHABLE) => 0,
Host::getStateText(Host::STATE_PENDING) => 0,
);
foreach ($this->serviceList as $service) {
++$serviceStates[$service::getStateText($service->state)];
if (! isset($knownHostStates[$service->getHost()->getName()])) {
$knownHostStates[$service->getHost()->getName()] = true;
++$hostStates[$service->getHost()->getStateText($service->host_state)];
}
}
$this->view->form = $form;
$this->_helper->viewRenderer('partials/command-form', null, true);
$this->view->objects = $this->serviceList;
$this->view->serviceStates = $serviceStates;
$this->view->hostStates = $hostStates;
$this->view->serviceStatesPieChart = $this->createPieChart(
$serviceStates,
$this->translate('Service State'),
array('#44bb77', '#FFCC66', '#FF5566', '#E066FF', '#77AAFF')
);
$this->view->hostStatesPieChart = $this->createPieChart(
$hostStates,
$this->translate('Host State'),
array('#44bb77', '#FF5566', '#E066FF', '#77AAFF')
);
$this->_helper->viewRenderer('partials/command/objects-command-form', null, true);
return $form;
}

View File

@ -109,7 +109,9 @@ abstract class MonitoredObjectController extends Controller
->setRedirectUrl(Url::fromPath($this->commandRedirectUrl)->setParams($this->params))
->handleRequest();
$this->view->form = $form;
$this->_helper->viewRenderer('partials/command-form', null, true);
$this->view->object = $this->object;
$this->view->tabs->remove('dashboard');
$this->_helper->viewRenderer('partials/command/object-command-form', null, true);
return $form;
}

View File

@ -190,3 +190,12 @@ div.selection-info {
.optionbox input {
vertical-align: middle;
}
h1.command-title {
border: none;
}
hr.command-separator {
border: none;
border-bottom: 2px solid @colorPetrol;
}