Use icons to separate soft and hard states in the event history views

refs #11859
This commit is contained in:
Eric Lippmann 2016-11-14 15:18:00 +01:00
parent bdeeec50bb
commit bf18238977
1 changed files with 25 additions and 6 deletions

View File

@ -40,12 +40,14 @@ $lastDate = null;
<?php foreach ($history->peekAhead() as $event): <?php foreach ($history->peekAhead() as $event):
$icon = ''; $icon = '';
$iconCssClass = ''; $iconCssClass = '';
$iconTitle = null;
$isService = isset($event->service_description); $isService = isset($event->service_description);
$msg = $event->output; $msg = $event->output;
$stateName = 'no-state'; $stateName = 'no-state';
switch ($event->type) { switch ($event->type) {
case 'notify': case 'notify':
$icon = 'bell-alt'; $icon = 'bell';
$iconTitle = $this->translate('Notification', 'tooltip');
$label = $this->translate('NOTIFICATION'); $label = $this->translate('NOTIFICATION');
$msg = $msg ? preg_replace_callback( $msg = $msg ? preg_replace_callback(
'/^\[([^\]]+)\]/', '/^\[([^\]]+)\]/',
@ -56,55 +58,72 @@ $lastDate = null;
break; break;
case 'comment': case 'comment':
$icon = 'comment'; $icon = 'comment';
$iconTitle = $this->translate('Comment', 'tooltip');
$label = $this->translate('COMMENT'); $label = $this->translate('COMMENT');
break; break;
case 'comment_deleted': case 'comment_deleted':
$icon = 'cancel'; $icon = 'cancel';
$iconTitle = $this->translate('Comment removed', 'tooltip');
$label = $this->translate('COMMENT DELETED'); $label = $this->translate('COMMENT DELETED');
break; break;
case 'ack': case 'ack':
$icon = 'ok'; $icon = 'ok';
$iconTitle = $this->translate('Acknowledged', 'tooltip');
$label = $this->translate('ACKNOWLEDGED'); $label = $this->translate('ACKNOWLEDGED');
break; break;
case 'ack_deleted': case 'ack_deleted':
$icon = 'ok'; $icon = 'ok';
$iconCssClass = 'icon-strikethrough'; $iconCssClass = 'icon-strikethrough';
$iconTitle = $this->translate('Acknowledgement removed', 'tooltip');
$label = $this->translate('ACKNOWLEDGEMENT REMOVED'); $label = $this->translate('ACKNOWLEDGEMENT REMOVED');
break; break;
case 'dt_comment': case 'dt_comment':
// TODO(el): Does not appear in history
$icon = 'plug'; $icon = 'plug';
$iconTitle = $this->translate('Downtime scheduled', 'tooltip');
$label = $this->translate('SCHEDULED DOWNTIME'); $label = $this->translate('SCHEDULED DOWNTIME');
break; break;
case 'dt_comment_deleted': case 'dt_comment_deleted':
// TODO(el): Does not appear in history
$icon = 'plug'; $icon = 'plug';
$iconCssClass = 'icon-strikethrough'; $iconCssClass = 'icon-strikethrough';
$iconTitle = $this->translate('Downtime removed', 'tooltip');
$label = $this->translate('DOWNTIME DELETED'); $label = $this->translate('DOWNTIME DELETED');
break; break;
case 'flapping': case 'flapping':
// TODO(el): Icon $icon = 'flapping';
$iconTitle = $this->translate('Flapping started', 'tooltip');
$label = $this->translate('FLAPPING'); $label = $this->translate('FLAPPING');
break; break;
case 'flapping_deleted': case 'flapping_deleted':
// TODO(el): Icon $icon = 'flapping';
$iconCssClass = 'icon-strikethrough';
$iconTitle = $this->translate('Flapping stopped', 'tooltip');
$label = $this->translate('FLAPPING STOPPED'); $label = $this->translate('FLAPPING STOPPED');
break; break;
case 'hard_state': case 'hard_state':
if ((int) $event->state === 0) {
$icon = 'thumbs-up';
} else {
$icon = 'warning-empty';
}
$iconTitle = $this->translate('Hard state', 'tooltip');
$label = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true); $label = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true);
$stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
break; break;
case 'soft_state': case 'soft_state':
$icon = 'spinner';
$iconTitle = $this->translate('Soft state', 'tooltip');
$label = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true); $label = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true);
$stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state);
break; break;
case 'dt_start': case 'dt_start':
$icon = 'plug'; $icon = 'plug';
$iconTitle = $this->translate('Downtime started', 'tooltip');
$label = $this->translate('DOWNTIME START'); $label = $this->translate('DOWNTIME START');
break; break;
case 'dt_end': case 'dt_end':
$icon = 'plug'; $icon = 'plug';
$iconCssClass = 'icon-strikethrough'; $iconCssClass = 'icon-strikethrough';
$iconTitle = $this->translate('Downtime ended', 'tooltip');
$label = $this->translate('DOWNTIME END'); $label = $this->translate('DOWNTIME END');
break; break;
} ?> } ?>
@ -157,7 +176,7 @@ $lastDate = null;
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>
<p class="overview-plugin-output"><?php if ($icon) { <p class="overview-plugin-output"><?php if ($icon) {
echo $this->icon($icon, null, $iconCssClass ? array('class' => $iconCssClass) : array()); echo $this->icon($icon, $iconTitle, $iconCssClass ? array('class' => $iconCssClass) : array());
} ?><?= $this->nl2br($this->createTicketLinks($this->escapeComment($msg))) } ?><?= $this->nl2br($this->createTicketLinks($this->escapeComment($msg)))
// TODO(ak): this allows only a[href] in messages, but plugin output allows more // TODO(ak): this allows only a[href] in messages, but plugin output allows more
?></p> ?></p>