Make event history view more fancier

refs #6637
This commit is contained in:
Johannes Meyer 2014-08-15 17:03:03 +02:00
parent cae84a5d7f
commit 043688e514

View File

@ -1,122 +1,114 @@
<?php if (false === $this->compact): ?>
<?php if (!$this->compact): ?>
<div class="controls"> <div class="controls">
<?= $this->tabs->render($this); ?> <?= $this->tabs->render($this); ?>
<div style="margin: 1em" class="dontprint"> <div style="margin: 1em" class="dontprint">
<?= $this->translate('Sort by') ?> <?= $this->sortControl->render($this); ?> <?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
</div> </div>
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?> <?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
</div> </div>
<?php endif; ?> <?php endif ?>
<div class="content"> <div class="content">
<?php if (empty($history)): ?> <?php if (empty($history)): ?>
<?= $this->translate('No entries found') ?> <?= $this->translate('No history events matching the filter') ?>
</div> </div>
<?php return; endif ?> <?php return; endif ?>
<table data-base-target="_next" class="action"> <table data-base-target="_next" class="action">
<tbody> <tbody>
<?php
if (count($history) === 0) {
echo t('No history events matching the filter');
}
?>
<?php foreach ($history as $event): ?> <?php foreach ($history as $event): ?>
<?php <?php
$class = null; $stateName = 'invalid';
$isService = false; $isService = isset($event->service);
switch ($event->type) { switch ($event->type) {
case 'notify': case 'notify':
$icon = 'notification'; $icon = 'notification';
$title = 'Notification'; $title = $this->translate('Notification');
$msg = $event->output; $msg = $event->output;
break; break;
case 'comment': case 'comment':
$icon = 'comment'; $icon = 'comment';
$title = 'Comment'; $title = $this->translate('Comment');
$msg = $event->output; $msg = $event->output;
break; break;
case 'ack': case 'ack':
$icon = 'acknowledgement'; $icon = 'acknowledgement';
$title = 'Acknowledgement'; $title = $this->translate('Acknowledgement');
$msg = $event->output; $msg = $event->output;
break; break;
case 'dt_comment': case 'dt_comment':
$icon = 'in-downtime'; $icon = 'in_downtime';
$title = 'In Downtime'; $title = $this->translate('In Downtime');
$msg = $event->output; $msg = $event->output;
break; break;
case 'flapping': case 'flapping':
$icon = 'flapping'; $icon = 'flapping';
$title = 'Flapping'; $title = $this->translate('Flapping');
$msg = $event->output; $msg = $event->output;
break; break;
case 'hard_state': case 'hard_state':
$icon = '{{HARDSTATE_ICON}}'; $icon = $isService ? 'service' : 'host';
$title = 'Hard State'; $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $event->output;
$msg = $event->output . '<br /><small>Attempt ' . $event->attempt . '/' . $event->max_attempts . ' (Hard)</small>'; $stateName = (
$class = 'border-status-' . ( $isService
$isService ? ? strtolower($this->util()->getServiceStateName($event->state))
strtolower($this->util()->getServiceStateName($event->state)) : : strtolower($this->util()->getHostStateName($event->state))
strtolower($this->util()->getHostStateName($event->state))
); );
$title = strtoupper($stateName); // TODO: Should be translatable!
break; break;
case 'soft_state': case 'soft_state':
$icon = '{{SOFTSTATE_ICON}}'; $icon = 'softstate';
$title = 'Soft State'; $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $event->output;
$msg = $event->output . '<br /><small>Attempt ' . $event->attempt . '/' . $event->max_attempts . ' (Soft)</small>'; $stateName = (
$class = 'border-status-' . ( $isService
$isService ? ? strtolower($this->util()->getServiceStateName($event->state))
strtolower($this->util()->getServiceStateName($event->state)) : : strtolower($this->util()->getHostStateName($event->state))
strtolower($this->util()->getHostStateName($event->state))
); );
$title = strtoupper($stateName); // TODO: Should be translatable!
break; break;
case 'dt_start': case 'dt_start':
$icon = 'downtime-start'; $icon = 'downtime_start';
$title = 'Downtime Start'; $title = $this->translate('Downtime Start');
$msg = $event->output; $msg = $event->output;
break; break;
case 'dt_end': case 'dt_end':
$icon = 'downtime-end'; $icon = 'downtime_end';
$title = 'Downtime End'; $title = $this->translate('Downtime End');
$msg = $event->output; $msg = $event->output;
break; break;
} }
?> ?>
<tr class="state"> <tr class="state <?= $stateName; ?>">
<td style="width: 6em;" <?= !empty($class) ? 'class="' . $class . '"' : '' ?>"> <td class="state">
<strong><?= $this->escape($title); ?></strong>
<br>
<?= date('d.m. H:i', $event->timestamp); ?> <?= date('d.m. H:i', $event->timestamp); ?>
</td> </td>
<td> <td>
<?php if (isset($event->service)): ?> <?php if ($isService): ?>
<a href="<?= $this->href('monitoring/show/service', array( <a href="<?= $this->href('monitoring/show/service', array(
'host' => $event->host, 'host' => $event->host,
'service' => $event->service 'service' => $event->service
)); ?>"> )); ?>">
<?= $event->service ?> <?= $event->service; ?>
</a> </a>
<small> <small>
on <?= $event->host ?> <?= $this->translate('on') . ' ' . $event->host; ?>
</small> </small>
<?php $isService = true; ?>
<?php else: ?> <?php else: ?>
<a href="<?= $this->href('monitoring/show/host', array( <a href="<?= $this->href('monitoring/show/host', array(
'host' => $event->host 'host' => $event->host
)); ?>"> )); ?>">
<?= $event->host ?> <?= $event->host; ?>
</a> </a>
<?php endif; ?> <?php endif ?>
<br /> <br>
<div> <div>
<i title="<?= $title ?>" class="icinga-icon-<?= $icon ?>"></i> <?= $this->icon($icon . '.png', $title); ?> <?= empty($msg) ? '' : $msg; ?>
<?php if (!empty($msg)) { echo $msg; } ?>
</div> </div>
</td> </td>
</tr> </tr>
<? endforeach; ?> <? endforeach ?>
</tbody> </tbody>
</table> </table>
</div> </div>