From 2ee611a927943fe0804698f7559fba70711b7cb5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Nov 2015 11:21:14 +0100 Subject: [PATCH] monitoring: Don't show host and service links in the detail history Further, eventhistory and detail-history now use the introduced event-history partial. refs #10317 --- .../views/scripts/list/eventhistory.phtml | 122 +----------- .../views/scripts/object/detail-history.phtml | 150 +-------------- .../scripts/partials/event-history.phtml | 179 ++++++++++++++++++ public/css/icinga/main.less | 4 + 4 files changed, 189 insertions(+), 266 deletions(-) create mode 100644 modules/monitoring/application/views/scripts/partials/event-history.phtml diff --git a/modules/monitoring/application/views/scripts/list/eventhistory.phtml b/modules/monitoring/application/views/scripts/list/eventhistory.phtml index 288bb692eb..039a197835 100644 --- a/modules/monitoring/application/views/scripts/list/eventhistory.phtml +++ b/modules/monitoring/application/views/scripts/list/eventhistory.phtml @@ -1,14 +1,4 @@ url(); -$limit = (int) $url->getParam('limit', 25); -if (! $url->hasParam('page') || ($page = (int) $url->getParam('page')) < 1) { - $page = 1; -} - -$history->limit($limit * $page); if (! $this->compact): ?>
@@ -20,110 +10,8 @@ if (! $this->compact): ?> filterEditor ?>
-
- - - peekAhead() as $event): - $icon = 'help'; - $msg = $event->output; - $title = $event->type; - $stateName = 'invalid'; - $isService = isset($event->service_description); - switch ($event->type) { - case 'notify': - $icon = 'bell'; - $title = $this->translate('Notification'); - $msg = $msg ?: $this->translate('This notification was not sent out to any contact.'); - break; - case 'comment': - $icon = 'comment'; - $title = $this->translate('Comment'); - break; - case 'ack': - $icon = 'ok'; - $title = $this->translate('Acknowledgement'); - break; - case 'dt_comment': - $icon = 'plug'; - $title = $this->translate('In Downtime'); - break; - case 'flapping': - $icon = 'flapping'; - $title = $this->translate('Flapping'); - break; - case 'flapping_deleted': - $icon = 'ok'; - $title = $this->translate('Flapping Stopped'); - break; - case 'hard_state': - $icon = $isService ? 'service' : 'host'; - $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - $title = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true); - break; - case 'soft_state': - $icon = 'lightbulb'; - $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - $title = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true); - break; - case 'dt_start': - $icon = 'starttime'; - $title = $this->translate('Downtime Start'); - break; - case 'dt_end': - $icon = 'endtime'; - $title = $this->translate('Downtime End'); - break; - } ?> - - - - - - -
- getIteratorPosition() % $limit === 0): ?> - - - escape($title) ?> -

timeAgo($event->timestamp, $this->compact) ?>

-
- icon($icon, $title) ?> - - link()->service( - $event->service_description, $event->service_display_name, $event->host_name, $event->host_display_name, 'rowaction' - ) ?> - - link()->host($event->host_name, $event->host_display_name) ?> - -

- createTicketLinks($this->escape($msg)), false) ?> -

-
-hasResult()): ?> - translate('No history events found matching the filter') ?> -hasMore()): ?> -compact): ?> - qlink( - $this->translate('Show More'), - $url->without(array('view', 'limit')), - null, - array( - 'data-base-target' => '_next', - 'class' => 'pull-right action-link' - ) - ) ?> - - qlink( - $this->translate('Load More'), - $url->setAnchor('page-' . ($page + 1)), - array( - 'page' => $page + 1, - ), - array( - 'id' => 'load-more', - 'class' => 'pull-right action-link' - ) - ) ?> - - -
+partial( + 'partials/event-history.phtml', + array('compact' => $this->compact, 'history' => $history, 'isOverview' => true, 'tableCssClass' => 'action-table') +) ?> + diff --git a/modules/monitoring/application/views/scripts/object/detail-history.phtml b/modules/monitoring/application/views/scripts/object/detail-history.phtml index 2e51dc12a8..692d3e4ee7 100644 --- a/modules/monitoring/application/views/scripts/object/detail-history.phtml +++ b/modules/monitoring/application/views/scripts/object/detail-history.phtml @@ -1,29 +1,4 @@ qlink( - $contact, - 'monitoring/show/contact', - array('contact_name' => $contact), - array('title' => sprintf($view->translate('Show detailed information about %s'), $contact)) - ); - } - return '[' . implode(', ', $links) . ']'; -} - -$self = $this; - -$url = $this->url(); -$limit = (int) $url->getParam('limit', 25); -if (! $url->hasParam('page') || ($page = (int) $url->getParam('page')) < 1) { - $page = 1; -} - -$history->limit($limit * $page); if (! $this->compact): ?>
@@ -35,127 +10,4 @@ if (! $this->compact): ?> } ?>
-
-hasResult()): ?> -

translate('No historical events found matching the filter.') ?>

-
- - - - peekAhead() as $event): - $icon = ''; - $iconCssClass = ''; - $isService = isset($event->service_description); - $msg = $event->output; - $stateName = 'no-state'; - switch ($event->type) { - case 'notify': - $icon = 'bell-alt'; - $label = $this->translate('NOTIFICATION'); - $msg = $msg ? preg_replace_callback( - '/^\[([^\]]+)\]/', - function($match) use ($self) { return contactsLink($match, $self); }, - $msg - ) : $this->translate('This notification was not sent out to any contact.'); - $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - break; - case 'comment': - $icon = 'comment'; - $label = $this->translate('COMMENT'); - break; - case 'comment_deleted': - $icon = 'cancel'; - $label = $this->translate('COMMENT DELETED'); - break; - case 'ack': - $icon = 'ok'; - $label = $this->translate('ACKNOWLEDGED'); - break; - case 'ack_deleted': - $icon = 'ok'; - $iconCssClass = 'icon-strikethrough'; - $label = $this->translate('ACKNOWLEDGEMENT REMOVED'); - break; - case 'dt_comment': - // TODO(el): Does not appear in history - $icon = 'plug'; - $label = $this->translate('SCHEDULED DOWNTIME'); - break; - case 'dt_comment_deleted': - // TODO(el): Does not appear in history - $icon = 'plug'; - $iconCssClass = 'icon-strikethrough'; - $label = $this->translate('DOWNTIME DELETED'); - break; - case 'flapping': - // TODO(el): Icon - $label = $this->translate('FLAPPING'); - break; - case 'flapping_deleted': - // TODO(el): Icon - $label = $this->translate('FLAPPING STOPPED'); - break; - case 'hard_state': - $label = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true); - $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - break; - case 'soft_state': - $label = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true); - $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); - break; - case 'dt_start': - $icon = 'plug'; - $label = $this->translate('DOWNTIME START'); - break; - case 'dt_end': - $icon = 'plug'; - $iconCssClass = 'icon-strikethrough'; - $label = $this->translate('DOWNTIME END'); - break; - } ?> - - - - - - -
- getIteratorPosition() % $limit === 0): ?> - - -
escape($label) ?>
-
timeAgo($event->timestamp, $this->compact) ?>
-
- icon($icon, null, $iconCssClass ? array('class' => $iconCssClass) : array()); - } ?> - escape($event->host_name) ?>: - qlink( - $event->service_display_name, - 'monitoring/service/show', - array( - 'host' => $event->host_name, - 'service' => $event->service_description - ), - array('title' => sprintf( - $this->translate('Show detailed information for service %s on host %s'), - $event->service_display_name, - $event->host_display_name - )) - ) ?> - -

- createTicketLinks($this->escape($msg)), false) ?> -

-
-hasMore()): ?> - - - +render('partials/event-history.phtml') ?> diff --git a/modules/monitoring/application/views/scripts/partials/event-history.phtml b/modules/monitoring/application/views/scripts/partials/event-history.phtml new file mode 100644 index 0000000000..d8f0b720c2 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/event-history.phtml @@ -0,0 +1,179 @@ +qlink( + $contact, + 'monitoring/show/contact', + array('contact_name' => $contact), + array('title' => sprintf($view->translate('Show detailed information about %s'), $contact)) + ); + } + return '[' . implode(', ', $links) . ']'; +} + +$self = $this; + +$url = $this->url(); +$limit = (int) $url->getParam('limit', 25); +if (! $url->hasParam('page') || ($page = (int) $url->getParam('page')) < 1) { + $page = 1; +} + +/** @var \Icinga\Module\Monitoring\DataView\EventHistory $history */ +$history->limit($limit * $page); +?> +
+hasResult()): ?> +

translate('No historical events found matching the filter.') ?>

+
+ + class=""> + + peekAhead() as $event): + $icon = ''; + $iconCssClass = ''; + $isService = isset($event->service_description); + $msg = $event->output; + $stateName = 'no-state'; + switch ($event->type) { + case 'notify': + $icon = 'bell-alt'; + $label = $this->translate('NOTIFICATION'); + $msg = $msg ? preg_replace_callback( + '/^\[([^\]]+)\]/', + function($match) use ($self) { return contactsLink($match, $self); }, + $msg + ) : $this->translate('This notification was not sent out to any contact.'); + $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + break; + case 'comment': + $icon = 'comment'; + $label = $this->translate('COMMENT'); + break; + case 'comment_deleted': + $icon = 'cancel'; + $label = $this->translate('COMMENT DELETED'); + break; + case 'ack': + $icon = 'ok'; + $label = $this->translate('ACKNOWLEDGED'); + break; + case 'ack_deleted': + $icon = 'ok'; + $iconCssClass = 'icon-strikethrough'; + $label = $this->translate('ACKNOWLEDGEMENT REMOVED'); + break; + case 'dt_comment': + // TODO(el): Does not appear in history + $icon = 'plug'; + $label = $this->translate('SCHEDULED DOWNTIME'); + break; + case 'dt_comment_deleted': + // TODO(el): Does not appear in history + $icon = 'plug'; + $iconCssClass = 'icon-strikethrough'; + $label = $this->translate('DOWNTIME DELETED'); + break; + case 'flapping': + // TODO(el): Icon + $label = $this->translate('FLAPPING'); + break; + case 'flapping_deleted': + // TODO(el): Icon + $label = $this->translate('FLAPPING STOPPED'); + break; + case 'hard_state': + $label = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true); + $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + break; + case 'soft_state': + $label = $isService ? Service::getStateText($event->state, true) : Host::getStateText($event->state, true); + $stateName = $isService ? Service::getStateText($event->state) : Host::getStateText($event->state); + break; + case 'dt_start': + $icon = 'plug'; + $label = $this->translate('DOWNTIME START'); + break; + case 'dt_end': + $icon = 'plug'; + $iconCssClass = 'icon-strikethrough'; + $label = $this->translate('DOWNTIME END'); + break; + } ?> + + + + + + +
+ getIteratorPosition() % $limit === 0): ?> + + +
escape($label) ?>
+
timeAgo($event->timestamp, $this->compact) ?>
+
+ isOverview): ?> + qlink( + $event->host_display_name, + 'monitoring/host/show', + array( + 'host' => $event->host_name, + ), + array('title' => sprintf( + $this->translate('Show detailed information for host %s'), + $event->host_display_name + )) + ) ?>: + qlink( + $event->service_display_name, + 'monitoring/service/show', + array( + 'host' => $event->host_name, + 'service' => $event->service_description + ), + array( + 'class' => 'rowaction', + 'title' => sprintf( + $this->translate('Show detailed information for service %s on host %s'), + $event->service_display_name, + $event->host_display_name + ) + ) + ) ?> + + +

+ icon($icon, null, $iconCssClass ? array('class' => $iconCssClass) : array()); + } ?> + createTicketLinks($this->escape($msg)), false) ?> +

+
+hasMore()): ?> + + + diff --git a/public/css/icinga/main.less b/public/css/icinga/main.less index f4319f77e0..13016c88d5 100644 --- a/public/css/icinga/main.less +++ b/public/css/icinga/main.less @@ -17,6 +17,10 @@ width: 28px; } +.icon-strikethrough { + text-decoration: line-through; +} + .pull-left { float: left; }