list/notifications: fix query, select columns, style

This commit is contained in:
Thomas Gelf 2014-06-20 19:12:10 +02:00
parent f9b18828c1
commit 127b728a4c
2 changed files with 29 additions and 25 deletions

View File

@ -213,7 +213,14 @@ class Monitoring_ListController extends Controller
{ {
$this->addTitleTab('notifications'); $this->addTitleTab('notifications');
$this->setAutorefreshInterval(15); $this->setAutorefreshInterval(15);
$query = $this->backend->select()->from('notification'); $query = $this->backend->select()->from('notification', array(
'host',
'service',
'notification_output',
'notification_contact',
'notification_start_time',
'notification_state'
));
$this->applyFilters($query); $this->applyFilters($query);
$this->view->notifications = $query->paginate(); $this->view->notifications = $query->paginate();
$this->setupSortControl(array( $this->setupSortControl(array(

View File

@ -1,10 +1,11 @@
<div class="controls"> <div class="controls">
<?= $this->tabs ?> <?= $this->tabs ?>
<div style="margin: 1em" class="dontprint"> <div class="dontprint">
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?> <?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this) ?>
<?= $this->selectionToolbar('single') ?> <?= $this->selectionToolbar('single') ?>
</div> </div>
<?= $this->widget('limiter') ?>
<?php if ($notifications->count() >= 100): ?><br /><?php endif ?>
<?= $this->paginationControl($notifications, null, null, array('preserve' => $this->preserve)) ?> <?= $this->paginationControl($notifications, null, null, array('preserve' => $this->preserve)) ?>
</div> </div>
@ -37,29 +38,25 @@ foreach ($notifications as $notification):
)); ));
$stateName = strtolower($this->util()->getHostStateName($notification->notification_state)); $stateName = strtolower($this->util()->getHostStateName($notification->notification_state));
} }
?> ?>
<tr class="state <?= $stateName ?>"> <tr class="state <?= $stateName ?>">
<td class="state"><?= $this->timeSince($notification->notification_start_time) ?></td> <td class="state"><?= $this->timeSince($notification->notification_start_time) ?></td>
<td> <td>
<?php if ($isService): ?> <?php if ($isService): ?>
<a href="<?= $href ?>"><?= $notification->service ?></a> <a href="<?= $href ?>"><?= $notification->service ?></a> on <?= $notification->host ?>
<small> <?php else: ?>
on <?= $notification->host ?> <a href="<?= $href ?>"><?= $notification->host ?></a>
</small> <?php endif; ?>
<?php $isService = true; ?> <br />
<?php else: ?> <?= $this->escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?>
<a href="<?= $href ?>"><?= $notification->host ?></a> <br />
<?php endif; ?> <small>
<br /> Sent to <a href="<?= $this->href(
<?= $this->escape(substr(strip_tags($notification->notification_output), 0, 10000)); ?> 'monitoring/show/contact',
<br /> array('contact' => $notification->notification_contact)
<small> ) ?>"><?= $this->escape($notification->notification_contact) ?></a>
Sent to </small>
<a href="<?= $this->href('monitoring/show/contact', array('contact' => $notification->notification_contact)); ?>"> </td>
<?= $notification->notification_contact ?>
</a>
</small>
</td>
</tr> </tr>
<?php endforeach ?> <?php endforeach ?>
</tbody> </tbody>