Reorganised eventhistory view script, still far from being perfect

This commit is contained in:
Thomas Gelf 2014-03-04 13:29:02 +00:00
parent 635cdcbbc5
commit 5c5268651c
1 changed files with 109 additions and 128 deletions

View File

@ -1,133 +1,114 @@
<div class="row">
<div class="pull-left">
<h1>History</h1>
</div>
<div class="pull-right">
<?= $this->tabs->render($this); ?>
</div>
<div class="controls">
<?= $this->tabs->render($this); ?>
<?= $this->filterBox->render($this); ?>
<?= $this->sortControl->render($this); ?>
<?= $this->selectionToolbar('single'); ?>
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
</div>
<?php if (!empty($history)): ?>
<div data-icinga-component="app/mainDetailGrid" data-icinga-grid-selection-type="single">
<div class="container pull-left">
<div class="row">
<div class="col-md-5">
<?= $this->filterBox->render($this); ?>
</div>
<div class="col-md-7">
<?= $this->sortControl->render($this); ?>
</div>
</div>
<div class="content">
<?php if (empty($history)): ?>
No entries found
</div>
<?php return; endif ?>
<div class="row">
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
</div>
<div class="row">
<?= $this->selectionToolbar('single'); ?>
</div>
</div>
<table class="action">
<tbody>
<?php foreach ($history as $event): ?>
<?php
$class = null;
$isService = false;
switch ($event->type) {
case 'notify':
$icon = 'notification';
$title = 'Notification';
$msg = $event->output;
break;
case 'comment':
$icon = 'comment';
$title = 'Comment';
$msg = $event->output;
break;
case 'ack':
$icon = 'acknowledgement';
$title = 'Acknowledgement';
$msg = $event->output;
break;
case 'dt_comment':
$icon = 'in-downtime';
$title = 'In Downtime';
$msg = $event->output;
break;
case 'flapping':
$icon = 'flapping';
$title = 'Flapping';
$msg = $event->output;
break;
case 'hard_state':
$icon = '{{HARDSTATE_ICON}}';
$title = 'Hard State';
$msg = $event->output . '<br /><small>Attempt ' . $event->attempt . '/' . $event->max_attempts . ' (Hard)</small>';
$class = 'border-status-' . (
$isService ?
strtolower($this->util()->getServiceStateName($event->state)) :
strtolower($this->util()->getHostStateName($event->state))
);
break;
case 'soft_state':
$icon = '{{SOFTSTATE_ICON}}';
$title = 'Soft State';
$msg = $event->output . '<br /><small>Attempt ' . $event->attempt . '/' . $event->max_attempts . ' (Soft)</small>';
$class = 'border-status-' . (
$isService ?
strtolower($this->util()->getServiceStateName($event->state)) :
strtolower($this->util()->getHostStateName($event->state))
);
break;
case 'dt_start':
$icon = 'downtime-start';
$title = 'Downtime Start';
$msg = $event->output;
break;
case 'dt_end':
$icon = 'downtime-end';
$title = 'Downtime End';
$msg = $event->output;
break;
}
?>
<tr class="state">
<td style="width: 6em;" <?= !empty($class) ? 'class="' . $class . '"' : '' ?>">
<?= date('d.m. H:i', $event->timestamp); ?>
</td>
<td>
<?php if (isset($event->service)): ?>
<a href="<?= $this->href('monitoring/show/service', array(
'host' => $event->host,
'service' => $event->service
)); ?>">
<?= $event->service ?>
</a>
<small>
on <?= $event->host ?>
</small>
<?php $isService = true; ?>
<?php else: ?>
<a href="<?= $this->href('monitoring/show/host', array(
'host' => $event->host
)); ?>">
<?= $event->host ?>
</a>
<?php endif; ?>
<br />
<div>
<i title="<?= $title ?>" class="icinga-icon-<?= $icon ?>"></i>
<?php if (!empty($msg)) { echo $msg; } ?>
</div>
</td>
</tr>
<? endforeach; ?>
</tbody>
</table>
<table class="table table-condensed pull-left">
<tbody>
<?php foreach ($history as $event): ?>
<?php
$class = null;
$isService = false;
switch ($event->type) {
case 'notify':
$icon = 'notification';
$title = 'Notification';
$msg = $event->output;
break;
case 'comment':
$icon = 'comment';
$title = 'Comment';
$msg = $event->output;
break;
case 'ack':
$icon = 'acknowledgement';
$title = 'Acknowledgement';
$msg = $event->output;
break;
case 'dt_comment':
$icon = 'in-downtime';
$title = 'In Downtime';
$msg = $event->output;
break;
case 'flapping':
$icon = 'flapping';
$title = 'Flapping';
$msg = $event->output;
break;
case 'hard_state':
$icon = '{{HARDSTATE_ICON}}';
$title = 'Hard State';
$msg = $event->output . '<br /><small>Attempt ' . $event->attempt . '/' . $event->max_attempts . ' (Hard)</small>';
$class = 'border-status-' . (
$isService ?
strtolower($this->util()->getServiceStateName($event->state)) :
strtolower($this->util()->getHostStateName($event->state))
);
break;
case 'soft_state':
$icon = '{{SOFTSTATE_ICON}}';
$title = 'Soft State';
$msg = $event->output . '<br /><small>Attempt ' . $event->attempt . '/' . $event->max_attempts . ' (Soft)</small>';
$class = 'border-status-' . (
$isService ?
strtolower($this->util()->getServiceStateName($event->state)) :
strtolower($this->util()->getHostStateName($event->state))
);
break;
case 'dt_start':
$icon = 'downtime-start';
$title = 'Downtime Start';
$msg = $event->output;
break;
case 'dt_end':
$icon = 'downtime-end';
$title = 'Downtime End';
$msg = $event->output;
break;
}
?>
<tr>
<td <?= !empty($class) ? 'class="' . $class . '"' : '' ?>">
<?= date('d.m. H:i', $event->timestamp); ?>
</td>
<td>
<?php if (isset($event->service)): ?>
<a href="<?= $this->href('monitoring/show/service', array(
'host' => $event->host,
'service' => $event->service
)); ?>">
<?= $event->service ?>
</a>
<small>
on <?= $event->host ?>
</small>
<?php $isService = true; ?>
<?php else: ?>
<a href="<?= $this->href('monitoring/show/host', array(
'host' => $event->host
)); ?>">
<?= $event->host ?>
</a>
<?php endif; ?>
<br />
<div>
<i title="<?= $title ?>" class="icinga-icon-<?= $icon ?>"></i>
<?php if (!empty($msg)) { echo $msg; } ?>
</div>
</td>
</tr>
<? endforeach; ?>
</tbody>
</table>
</div>
<div class="container pull-left">
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
</div>
</div>
<?php endif; ?>