diff --git a/modules/monitoring/application/controllers/HostsController.php b/modules/monitoring/application/controllers/HostsController.php index af29d3489..32916ba42 100644 --- a/modules/monitoring/application/controllers/HostsController.php +++ b/modules/monitoring/application/controllers/HostsController.php @@ -2,6 +2,7 @@ /* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ use Icinga\Data\Filter\Filter; +use Icinga\Data\Filter\FilterEqual; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Forms\Command\Object\AcknowledgeProblemCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\CheckNowCommandForm; @@ -140,7 +141,6 @@ class Monitoring_HostsController extends Controller $this->view->downtimeAllLink = Url::fromRequest()->setPath('monitoring/hosts/schedule-downtime'); $this->view->processCheckResultAllLink = Url::fromRequest()->setPath('monitoring/hosts/process-check-result'); $this->view->addCommentLink = Url::fromRequest()->setPath('monitoring/hosts/add-comment'); - $this->view->deleteCommentLink = Url::fromRequest()->setPath('monitoring/hosts/delete-comment'); $this->view->stats = $hostStates; $this->view->objects = $this->hostList; $this->view->unhandledObjects = $this->hostList->getUnhandledObjects(); @@ -154,9 +154,20 @@ class Monitoring_HostsController extends Controller ->setQueryString($this->hostList->getProblemObjects()->objectsFilter()); $this->view->acknowledgedObjects = $this->hostList->getAcknowledgedObjects(); $this->view->objectsInDowntime = $this->hostList->getObjectsInDowntime(); - $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') - ->setQueryString($this->hostList->getObjectsInDowntime()->objectsFilter(array('host' => 'downtime_host'))); - + $this->view->inDowntimeLink = Url::fromPath('monitoring/list/hosts') + ->setQueryString( + $this->hostList + ->getObjectsInDowntime() + ->objectsFilter() + ->toQueryString() + ); + $this->view->showDowntimesLink = Url::fromPath('monitoring/list/downtimes') + ->setQueryString( + $this->hostList + ->objectsFilter() + ->andFilter(FilterEqual::where('downtime_objecttype', 'host')) + ->toQueryString() + ); $this->view->commentsLink = Url::fromRequest()->setPath('monitoring/list/comments'); $this->view->baseFilter = $this->hostList->getFilter(); $this->view->sendCustomNotificationLink = Url::fromRequest()->setPath('monitoring/hosts/send-custom-notification'); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 17be9569f..583b03246 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -160,9 +160,14 @@ class Monitoring_ServicesController extends Controller ->setQueryString($this->serviceList->getProblemObjects()->objectsFilter()->toQueryString()); $this->view->acknowledgedObjects = $acknowledgedObjects; $this->view->objectsInDowntime = $this->serviceList->getObjectsInDowntime(); - $this->view->inDowntimeLink = Url::fromPath('monitoring/list/downtimes') + $this->view->inDowntimeLink = Url::fromPath('monitoring/list/services') ->setQueryString($this->serviceList->getObjectsInDowntime() - ->objectsFilter(array('host' => 'downtime_host', 'service' => 'downtime_service'))->toQueryString()); + ->objectsFilter(array('host' => 'host_name', 'service' => 'service_description'))->toQueryString()); + $this->view->showDowntimesLink = Url::fromPath('monitoring/downtimes/show') + ->setQueryString( + $this->serviceList->getObjectsInDowntime() + ->objectsFilter()->toQueryString() + ); $this->view->commentsLink = Url::fromRequest() ->setPath('monitoring/list/comments'); $this->view->baseFilter = $this->serviceList->getFilter(); diff --git a/modules/monitoring/library/Monitoring/Object/HostList.php b/modules/monitoring/library/Monitoring/Object/HostList.php index 48a7560b1..4236f94d8 100644 --- a/modules/monitoring/library/Monitoring/Object/HostList.php +++ b/modules/monitoring/library/Monitoring/Object/HostList.php @@ -86,4 +86,17 @@ class HostList extends ObjectList } return FilterOr::matchAny($filterExpression); } + + /** + * Get the scheduled downtimes + * + * @return type + */ + public function getScheduledDowntimes() + { + return $this->backend->select() + ->from('downtime') + ->applyFilter(clone $this->filter) + ->where('downtime_objecttype', 'host'); + } } diff --git a/modules/monitoring/library/Monitoring/Object/ObjectList.php b/modules/monitoring/library/Monitoring/Object/ObjectList.php index 4f5ada43c..75fe1ba76 100644 --- a/modules/monitoring/library/Monitoring/Object/ObjectList.php +++ b/modules/monitoring/library/Monitoring/Object/ObjectList.php @@ -127,6 +127,16 @@ abstract class ObjectList implements Countable, IteratorAggregate return $this->backend->select()->from('comment')->applyFilter($this->filter); } + /** + * Get the scheduled downtimes + * + * @return type + */ + public function getScheduledDowntimes() + { + return $this->backend->select()->from('downtime')->applyFilter($this->filter); + } + /** * @return ObjectList */ diff --git a/modules/monitoring/library/Monitoring/Object/ServiceList.php b/modules/monitoring/library/Monitoring/Object/ServiceList.php index 379d8234c..5ae9b8193 100644 --- a/modules/monitoring/library/Monitoring/Object/ServiceList.php +++ b/modules/monitoring/library/Monitoring/Object/ServiceList.php @@ -134,5 +134,17 @@ class ServiceList extends ObjectList } return FilterOr::matchAny($filterExpression); } -} + /** + * Get the scheduled downtimes + * + * @return type + */ + public function getScheduledDowntimes() + { + return $this->backend->select() + ->from('downtime') + ->applyFilter(clone $this->filter) + ->where('downtime_objecttype', 'service'); + } +}