Monitoring/Notifications: Wrap information in a two column view

This commit is contained in:
Eric Lippmann 2013-10-19 13:13:56 +02:00
parent ebc9f02cb4
commit 06158aa4ea
4 changed files with 68 additions and 104 deletions

View File

@ -218,20 +218,7 @@ class Monitoring_ListController extends MonitoringController
*/ */
public function notificationsAction() public function notificationsAction()
{ {
$query = NotificationView::fromRequest( $query = NotificationView::fromRequest($this->_request)->getQuery();
$this->_request,
array(
'host_name',
'service_description',
'notification_type',
'notification_reason',
'notification_start_time',
'notification_contact',
'notification_information',
'notification_command',
'notification_internal_id'
)
)->getQuery();
$this->view->notifications = $query->paginate(); $this->view->notifications = $query->paginate();
$this->setupSortControl(array( $this->setupSortControl(array(
'notification_start_time' => 'Notification Start' 'notification_start_time' => 'Notification Start'

View File

@ -1,71 +1,56 @@
<?= $this->tabs->render($this); ?> <h1>Notifications</h1>
<?php
$formatter = $this->getHelper('MonitoringProperties');
?>
<div data-icinga-component="app/mainDetailGrid" data-icinga-grid-selection-type="multi">
<?= $this->sortControl->render($this); ?>
<?= $this->paginationControl($notifications, null, null, array('preserve' => $this->preserve)); ?>
<table class="table table-condensed" >
<thead>
<tr>
<th>Host</th>
<th>Service</th>
<th>Type</th>
<th>Time</th>
<th>Contact</th>
<th>Notification Command</th>
<th>Information</th>
</tr>
</thead>
<tbody>
<?php foreach ($notifications as $notification): ?>
<?php
if (empty($notification->service_description)) {
$detailLink = $this->href('monitoring/show/host', array('host' => $notification->host_name));
} else {
$detailLink = $this->href('monitoring/show/host', array(
'host' => $notification->host_name,
'service' => $notification->service_description,
'notification_id' => $notification->notification_internal_id
)
);
}
?>
<tr <?= ($this->activeRowHref === $detailLink) ? 'class="active"' : ''; ?>>
<td>
<a href="<?= $detailLink; ?>" style="visibility:hidden"></a>
<a href="<?= $this->href('monitoring/show/host', array('host' => $notification->host_name)); ?>">
<?= $notification->host_name ?>
</a>
</td>
<td>
<a href="<?= $this->href('monitoring/show/host', array(
'host' => $notification->host_name,
'service' => $notification->service_description
)
); ?>">
<?= empty($notification->service_description) ? '' : $notification->service_description; ?>
</a>
</td>
<td><?= $formatter->getNotificationType($notification); ?>
</td>
<td>
<?= $notification->notification_start_time ?>
</td>
<td>
<?= $notification->notification_contact ?>
</td>
<td>
<?= $notification->notification_command ?>
</td>
<td>
<?= $this->escape(substr(strip_tags($notification->notification_information), 0, 10000)); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if (!empty($notifications)): ?>
<div data-icinga-component="app/mainDetailGrid" data-icinga-grid-selection-type="single">
<?= $this->sortControl->render($this); ?>
<?= $this->paginationControl($notifications, null, null, array('preserve' => $this->preserve)); ?>
<table class="table table-condensed" >
<tbody>
<?php foreach ($notifications as $notification): ?>
<?php
if (isset($notification->service)) {
$isService = true;
$href = $this->href('monitoring/show/service', array(
'host' => $notification->host,
'service' => $notification->service
));
$stateName = strtolower($this->util()->getServiceStateName($notification->notification_state));
} else {
$isService = false;
$href = $this->href('monitoring/show/host', array(
'host' => $notification->host
));
$stateName = strtolower($this->util()->getHostStateName($notification->notification_state));
}
?>
<tr>
<td class="border-status-<?= $stateName ?>"><?= date('d.m. H:i', $notification->notification_start_time); ?></td>
<td>
<?php if ($isService): ?>
<a href="<?= $href ?>"><?= $notification->service ?></a>
<small>
on <?= $notification->host ?>
</small>
<?php $isService = true; ?>
<?php else: ?>
<a href="<?= $href ?>"><?= $notification->host ?></a>
<?php endif; ?>
<br />
<?= $this->escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?>
<br />
<small>
Sent to
<a href="<?= $this->href('monitoring/show/contact', array('contact' => $notification->notification_contact)); ?>">
<?= $notification->notification_contact ?>
</a>
</small>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?= $this->paginationControl($notifications, null, null, array('preserve' => $this->preserve)); ?>
</div> </div>
<?php else: ?>
No notifications yet
<?php endif; ?>

View File

@ -37,23 +37,19 @@ class NotificationQuery extends IdoQuery
*/ */
protected $columnMap = array( protected $columnMap = array(
'notification' => array( 'notification' => array(
'notification_type' => 'n.notification_type', 'notification_output' => 'n.output',
'notification_reason' => 'n.notification_reason', 'notification_start_time' => 'UNIX_TIMESTAMP(n.start_time)',
'notification_start_time' => 'n.start_time', 'notification_state' => 'n.state'
'notification_information' => 'n.output',
'notification_internal_id' => 'n.notification_id'
), ),
'objects' => array( 'objects' => array(
'host_name' => 'o.name1', 'host' => 'o.name1',
'service_description' => 'o.name2', 'service' => 'o.name2'
'service' => 'o.name2',
'host_name' => 'o.name1'
), ),
'contact' => array( 'contact' => array(
'notification_contact' => 'c_o.name1' 'notification_contact' => 'c_o.name1'
), ),
'command' => array( 'command' => array(
'notification_command' => 'cmd_o.name1' 'notification_command' => 'cmd_o.name1'
) )
); );

View File

@ -14,17 +14,13 @@ class Notification extends DataView
public function getColumns() public function getColumns()
{ {
return array( return array(
'host_name', 'host',
'service_description', 'service',
'notification_type', 'notification_state',
'notification_reason',
'notification_start_time', 'notification_start_time',
'notification_contact', 'notification_contact',
'notification_information', 'notification_output',
'notification_command', 'notification_command'
'host',
'service'
'notification_internal_id'
); );
} }