Basic structure for the notification overview

refs #4187
This commit is contained in:
Johannes Meyer 2013-08-09 11:23:42 +02:00 committed by Eric Lippmann
parent 5202854152
commit 3c2122515a
5 changed files with 214 additions and 8 deletions

View File

@ -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"

View File

@ -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',

View File

@ -0,0 +1,39 @@
<?= $this->tabs->render($this); ?>
<form method="get" action="<?= $this->qUrl(
'monitoring/list/notifications',
$this->notifications->getAppliedFilter()->toParams()
);
?>">
Sort by <?= $this->formSelect(
'sort',
$this->sort,
array(
'class' => 'autosubmit'
),
array(
'time' => 'Time'
)
);
?>
<input type="search" name="filter" placeholder="Type to filter" />
<button class="btn btn-small"><i class="icon-refresh"></i></button>
</form>
<table class="statustable action hosts">
<thead>
<tr>
<th>Host</th>
<th>Service</th>
<th>Type</th>
<th>Time</th>
<th>Time period</th>
<th>Contact</th>
<th>Notification command</th>
<th>Information</th>
</tr>
</thead>
<tbody>
</tbody>
</table>

View File

@ -0,0 +1,88 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @author Icinga Development Team <info@icinga.org>
*/
// {{{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()
{
}
}

View File

@ -0,0 +1,58 @@
<?php
// {{{ICINGA_LICENSE_HEADER}}}
/**
* Icinga 2 Web - Head for multiple monitoring frontends
* Copyright (C) 2013 Icinga Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright 2013 Icinga Development Team <info@icinga.org>
* @author Icinga Development Team <info@icinga.org>
*/
// {{{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
)
);
}