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

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