Integrate comments and downtimes into MonitoredObjectsController

Add option to list all related commends and downtimes into the specific hosts and serivces views.

refs #8565
This commit is contained in:
Matthias Jentsch 2015-05-18 14:03:10 +02:00
parent fe2ee3617b
commit 00bbb762a1
5 changed files with 58 additions and 7 deletions

View File

@ -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');

View File

@ -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();

View File

@ -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');
}
}

View File

@ -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
*/

View File

@ -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');
}
}