Properly build the unhandled action links when showing multiple objects

The links designated to acknowledge unhandled problems or to schedule
a downtime for them were generated based on the full list of objects and
limited by non-supported filter parameters. As we are already aware of the
exact "unhandled" objects this list is now used to generate proper links.
(Btw applying filters to URLs is a mess...)

fixes #8017
This commit is contained in:
Johannes Meyer 2014-12-22 13:59:03 +01:00
parent f7d11ce11f
commit 086334c861
2 changed files with 18 additions and 12 deletions

View File

@ -108,12 +108,12 @@ class Monitoring_HostsController extends Controller
$this->view->hostStates = $hostStates;
$this->view->objects = $this->hostList;
$this->view->unhandledObjects = $unhandledObjects;
$this->view->acknowledgeUnhandledLink = Url::fromRequest()
->setPath('monitoring/hosts/acknowledge-problem')
->addParams(array('host_problem' => 1, 'host_handled' => 0));
$this->view->downtimeUnhandledLink = Url::fromRequest()
->setPath('monitoring/hosts/schedule-downtime')
->addParams(array('host_problem' => 1, 'host_handled' => 0));
$this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/hosts/acknowledge-problem')->setQueryString(
Filter::where('host', array_map(function ($h) { return $h->host; }, $unhandledObjects))->toQueryString()
);
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/hosts/schedule-downtime')->setQueryString(
Filter::where('host', array_map(function ($h) { return $h->host; }, $unhandledObjects))->toQueryString()
);
$this->view->acknowledgedObjects = $acknowledgedObjects;
$this->view->objectsInDowntime = $objectsInDowntime;
$this->view->inDowntimeLink = Url::fromRequest()

View File

@ -125,12 +125,18 @@ class Monitoring_ServicesController extends Controller
$this->view->serviceStates = $serviceStates;
$this->view->objects = $this->serviceList;
$this->view->unhandledObjects = $unhandledObjects;
$this->view->acknowledgeUnhandledLink = Url::fromRequest()
->setPath('monitoring/services/acknowledge-problem')
->addParams(array('service_problem' => 1, 'service_handled' => 0));
$this->view->downtimeUnhandledLink = Url::fromRequest()
->setPath('monitoring/services/schedule-downtime')
->addParams(array('service_problem' => 1, 'service_handled' => 0));
$unhandledFilterExpressions = array();
foreach ($unhandledObjects as $service) {
$unhandledFilterExpressions[] = Filter::matchAll(
Filter::expression('host', '=', $service->getHost()->getName()),
Filter::expression('service', '=', $service->getName())
);
}
$queryString = Filter::matchAny($unhandledFilterExpressions)->toQueryString();
$this->view->acknowledgeUnhandledLink = Url::fromPath('monitoring/services/acknowledge-problem');
$this->view->acknowledgeUnhandledLink->setQueryString($queryString);
$this->view->downtimeUnhandledLink = Url::fromPath('monitoring/services/schedule-downtime');
$this->view->downtimeUnhandledLink->setQueryString($queryString);
$this->view->acknowledgedObjects = $acknowledgedObjects;
$this->view->objectsInDowntime = $objectsInDowntime;
$this->view->inDowntimeLink = Url::fromRequest()