show/history: link notification contacts, show state

This commit is contained in:
Thomas Gelf 2014-09-05 18:20:35 +02:00
parent fe6a1b1f0f
commit d1dae46fae

View File

@ -11,6 +11,16 @@
</div> </div>
<?php return; endif ?> <?php return; endif ?>
<?php
function contactsLink($match, $self) {
$links = array();
foreach (preg_split('/,\s/', $match[1]) as $contact) {
$links[] = $self->qlink($contact, 'monitoring/show/contact', array('contact' => $contact));
}
return '[' . implode(', ', $links) . ']';
}
?>
<table data-base-target="_next" class="action objecthistory"> <table data-base-target="_next" class="action objecthistory">
<tbody> <tbody>
<?php foreach ($history as $event): ?> <?php foreach ($history as $event): ?>
@ -21,51 +31,61 @@
case 'notify': case 'notify':
$icon = 'notification'; $icon = 'notification';
$title = $this->translate('Notification'); $title = $this->translate('Notification');
$msg = $event->output; $stateClass = (
$isService
? strtolower($this->util()->getServiceStateName($event->state))
: strtolower($this->util()->getHostStateName($event->state))
);
$msg = preg_replace_callback(
'/^\[([^\]]+)\]/',
function($match) { return contactsLink($match, $this); },
$this->escape($event->output)
);
break; break;
case 'comment': case 'comment':
$icon = 'comment'; $icon = 'comment';
$title = $this->translate('Comment'); $title = $this->translate('Comment');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
case 'comment_deleted': case 'comment_deleted':
$icon = 'remove'; $icon = 'remove';
$title = $this->translate('Comment deleted'); $title = $this->translate('Comment deleted');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
case 'ack': case 'ack':
$icon = 'acknowledgement'; $icon = 'acknowledgement';
$title = $this->translate('Acknowledge'); $title = $this->translate('Acknowledge');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
case 'ack_deleted': case 'ack_deleted':
$icon = 'remove'; $icon = 'remove';
$title = $this->translate('Ack removed'); $title = $this->translate('Ack removed');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
case 'dt_comment': case 'dt_comment':
$icon = 'in_downtime'; $icon = 'in_downtime';
$title = $this->translate('In Downtime'); $title = $this->translate('In Downtime');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
case 'dt_comment_deleted': case 'dt_comment_deleted':
$icon = 'remove'; $icon = 'remove';
$title = $this->translate('Downtime removed'); $title = $this->translate('Downtime removed');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
case 'flapping': case 'flapping':
$icon = 'flapping'; $icon = 'flapping';
$title = $this->translate('Flapping'); $title = $this->translate('Flapping');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
case 'flapping_deleted': case 'flapping_deleted':
$icon = 'remove'; $icon = 'remove';
$title = $this->translate('Flapping stopped'); $title = $this->translate('Flapping stopped');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
case 'hard_state': case 'hard_state':
$icon = $isService ? 'service' : 'host'; $icon = $isService ? 'service' : 'host';
$msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $event->output; $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output);
$stateClass = ( $stateClass = (
$isService $isService
? strtolower($this->util()->getServiceStateName($event->state)) ? strtolower($this->util()->getServiceStateName($event->state))
@ -75,7 +95,7 @@
break; break;
case 'soft_state': case 'soft_state':
$icon = 'softstate'; $icon = 'softstate';
$msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $event->output; $msg = '[ ' . $event->attempt . '/' . $event->max_attempts . ' ] ' . $this->escape($event->output);
$stateClass = ( $stateClass = (
$isService $isService
? strtolower($this->util()->getServiceStateName($event->state)) ? strtolower($this->util()->getServiceStateName($event->state))
@ -86,12 +106,12 @@
case 'dt_start': case 'dt_start':
$icon = 'downtime_start'; $icon = 'downtime_start';
$title = $this->translate('Downtime Start'); $title = $this->translate('Downtime Start');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
case 'dt_end': case 'dt_end':
$icon = 'downtime_end'; $icon = 'downtime_end';
$title = $this->translate('Downtime End'); $title = $this->translate('Downtime End');
$msg = $event->output; $msg = $this->escape($event->output);
break; break;
} }
?> ?>
@ -106,8 +126,8 @@
$output = $this->tickets ? preg_replace_callback( $output = $this->tickets ? preg_replace_callback(
$this->tickets->getPattern(), $this->tickets->getPattern(),
array($this->tickets, 'createLink'), array($this->tickets, 'createLink'),
$this->escape($msg) $msg
) : $this->escape($msg); ) : $msg;
?> ?>
<?php if ($isService): ?> <?php if ($isService): ?>