monitoring: Fix the link to services in downtime when multiple services are selected

This commit is contained in:
Eric Lippmann 2014-12-29 12:25:41 +01:00
parent 26bc56e9df
commit bf92f9fa85

View File

@ -77,6 +77,7 @@ class Monitoring_ServicesController extends Controller
$unhandledFilterExpressions = array(); $unhandledFilterExpressions = array();
$acknowledgedObjects = array(); $acknowledgedObjects = array();
$objectsInDowntime = array(); $objectsInDowntime = array();
$downtimeFilterExpressions = array();
$serviceStates = array( $serviceStates = array(
Service::getStateText(Service::STATE_OK) => 0, Service::getStateText(Service::STATE_OK) => 0,
Service::getStateText(Service::STATE_WARNING) => 0, Service::getStateText(Service::STATE_WARNING) => 0,
@ -105,6 +106,10 @@ class Monitoring_ServicesController extends Controller
} }
if ((bool) $service->in_downtime === true) { if ((bool) $service->in_downtime === true) {
$objectsInDowntime[] = $service; $objectsInDowntime[] = $service;
$downtimeFilterExpressions[] = Filter::matchAll(
Filter::where('downtime_host', $service->getHost()->getName()),
Filter::where('downtime_service', $service->getName())
);
} }
++$serviceStates[$service::getStateText($service->state)]; ++$serviceStates[$service::getStateText($service->state)];
if (! isset($knownHostStates[$service->getHost()->getName()])) { if (! isset($knownHostStates[$service->getHost()->getName()])) {
@ -137,8 +142,8 @@ class Monitoring_ServicesController extends Controller
->setQueryString($unhandledFilterQueryString); ->setQueryString($unhandledFilterQueryString);
$this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->acknowledgedObjects = $acknowledgedObjects;
$this->view->objectsInDowntime = $objectsInDowntime; $this->view->objectsInDowntime = $objectsInDowntime;
$this->view->inDowntimeLink = Url::fromRequest() $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes')
->setPath('monitoring/list/downtimes'); ->setQueryString(Filter::matchAny($downtimeFilterExpressions)->toQueryString());
$this->view->havingCommentsLink = Url::fromRequest() $this->view->havingCommentsLink = Url::fromRequest()
->setPath('monitoring/list/comments'); ->setPath('monitoring/list/comments');
$this->view->serviceStatesPieChart = $this->createPieChart( $this->view->serviceStatesPieChart = $this->createPieChart(