From 3c2122515afa95ad7e808b0f9f0602efc107d8c9 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 9 Aug 2013 11:23:42 +0200 Subject: [PATCH] Basic structure for the notification overview refs #4187 --- config/modules/monitoring/menu.ini | 1 + .../controllers/ListController.php | 36 ++++++-- .../views/scripts/list/notifications.phtml | 39 ++++++++ .../Backend/Ido/Query/NotificationQuery.php | 88 +++++++++++++++++++ .../Monitoring/View/NotificationView.php | 58 ++++++++++++ 5 files changed, 214 insertions(+), 8 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/list/notifications.phtml create mode 100644 modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php create mode 100644 modules/monitoring/library/Monitoring/View/NotificationView.php diff --git a/config/modules/monitoring/menu.ini b/config/modules/monitoring/menu.ini index 25dd62018..2a6dae3ca 100755 --- a/config/modules/monitoring/menu.ini +++ b/config/modules/monitoring/menu.ini @@ -10,4 +10,5 @@ _1 = 1 Hosts = "/monitoring/list/hosts" Services = "/monitoring/list/services" Downtimes = "/monitoring/list/downtimes" +Notifications = "/monitoring/list/notifications" Summaries = "/monitoring/summary/group/by/hostgroup" diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 044ae6bcf..970cefa30 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -215,13 +215,30 @@ class Monitoring_ListController extends ModuleActionController } /** - * Create a query for the given view - * - * @param string $view An string identifying view to query - * @param array $columns An array with the column names to display - * - * @return \Icinga\Data\Db\Query + * Display notification overview */ + public function notificationsAction() + { + $query = $this->backend->select() + ->from('notification', array( + 'host_name', + 'service_description', + 'notification_type', + 'notification_start_time', + 'notification_contact', + 'notification_information', + //'notification_timeperiod', + //'notification_command' + )); + if (!$this->_getParam('sort')) { + // TODO: Remove this once MonitoringView::applyRequestSorting + // applies NotificationView::sortDefaults + $query->order('time', -1); // Descending + } + $this->view->notifications = $query->applyRequest($this->_request); + $this->inheritCurrentSortColumn(); + } + protected function query($view, $columns) { $extra = preg_split( @@ -299,8 +316,11 @@ class Monitoring_ListController extends ModuleActionController 'icon' => 'img/classic/downtime.gif', 'url' => 'monitoring/list/downtimes', )); - - + $tabs->add('notifications', array( + 'title' => 'Notifications', + 'icon' => 'img/classic/alarm-clock.png', + 'url' => 'monitoring/list/notifications' + )); /* $tabs->add('hostgroups', array( 'title' => 'Hostgroups', diff --git a/modules/monitoring/application/views/scripts/list/notifications.phtml b/modules/monitoring/application/views/scripts/list/notifications.phtml new file mode 100644 index 000000000..e05d10fe4 --- /dev/null +++ b/modules/monitoring/application/views/scripts/list/notifications.phtml @@ -0,0 +1,39 @@ +tabs->render($this); ?> + +
+ Sort by formSelect( + 'sort', + $this->sort, + array( + 'class' => 'autosubmit' + ), + array( + 'time' => 'Time' + ) + ); +?> + + +
+ + + + + + + + + + + + + + + + + +
HostServiceTypeTimeTime periodContactNotification commandInformation
\ No newline at end of file diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php new file mode 100644 index 000000000..0a9af695d --- /dev/null +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/NotificationQuery.php @@ -0,0 +1,88 @@ + + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} + +namespace Monitoring\Backend\Ido\Query; + + +/** + * Handling notification queries + */ +class NotificationQuery extends AbstractQuery +{ + /** + * Column map + * + * @var array + */ + protected $columnMap = array( + 'notification' => array( + 'notification_type' => '', + 'notification_start_time' => '', + 'notification_information' => '' + ), + 'objects' => array( + 'host_name' => '', + 'service_description' => '' + ), + 'contact' => array( + 'notification_contact' => '' + ), + 'timeperiod' => array( + 'notification_timeperiod' => '' + ) + ); + + /** + * Fetch basic information about notifications + */ + protected function joinBaseTables() + { + + } + + /** + * Fetch description of each affected host/service + */ + protected function joinObjects() + { + + } + + /** + * Fetch name of involved contacts and/or contact groups + */ + protected function joinContact() + { + + } + + /** + * Fetch assigned time period for each notification + */ + protected function joinTimeperiod() + { + + } +} \ No newline at end of file diff --git a/modules/monitoring/library/Monitoring/View/NotificationView.php b/modules/monitoring/library/Monitoring/View/NotificationView.php new file mode 100644 index 000000000..cea4df1b7 --- /dev/null +++ b/modules/monitoring/library/Monitoring/View/NotificationView.php @@ -0,0 +1,58 @@ + + * @author Icinga Development Team + */ +// {{{ICINGA_LICENSE_HEADER}}} +namespace Monitoring\View; + +/** + * NotificationView + */ +class NotificationView extends MonitoringView +{ + /** + * Available columns provided by this view + * + * @var array + */ + protected $availableColumns = array( + 'host_name', + 'service_description', + 'notification_type', + 'notification_start_time', + 'notification_contact', + 'notification_information', + 'notification_timeperiod', + 'notification_command' + ); + + /** + * Default sorting rules + * + * @var array + */ + protected $sortDefaults = array( + 'notification_start_time' => array( + 'default_dir' => self::SORT_DESC + ) + ); +} \ No newline at end of file