diff --git a/modules/monitoring/application/controllers/CommentController.php b/modules/monitoring/application/controllers/CommentController.php new file mode 100644 index 0000000000..8d700770bb --- /dev/null +++ b/modules/monitoring/application/controllers/CommentController.php @@ -0,0 +1,88 @@ +params->get('comment_id'); + + $this->comment = $this->backend->select()->from('comment', array( + 'id' => 'comment_internal_id', + 'objecttype' => 'comment_objecttype', + 'comment' => 'comment_data', + 'author' => 'comment_author_name', + 'timestamp' => 'comment_timestamp', + 'type' => 'comment_type', + 'persistent' => 'comment_is_persistent', + 'expiration' => 'comment_expiration', + 'host_name', + 'service_description', + 'host_display_name', + 'service_display_name' + ))->where('comment_internal_id', $commentId)->getQuery()->fetchRow(); + + if (false === $this->comment) { + throw new Zend_Controller_Action_Exception($this->translate('Comment not found')); + } + + $this->getTabs() + ->add( + 'comment', + array( + 'title' => $this->translate( + 'Display detailed information about a comment.' + ), + 'icon' => 'comment', + 'label' => $this->translate('Comment'), + 'url' =>'monitoring/comments/show' + ) + )->activate('comment')->extend(new DashboardAction()); + } + + public function showAction() + { + $this->view->comment = $this->comment; + if ($this->hasPermission('monitoring/command/comment/delete')) { + $this->view->delCommentForm = $this->createDelCommentForm(); + } + } + + private function createDelCommentForm() + { + $this->assertPermission('monitoring/command/comment/delete'); + + $delCommentForm = new DeleteCommentCommandForm(); + $delCommentForm->setAction( + Url::fromPath('monitoring/comment/show') + ->setParam('comment_id', $this->comment->id) + ); + $delCommentForm->populate( + array( + 'redirect' => Url::fromPath('monitoring/list/comments'), + 'comment_id' => $this->comment->id + ) + ); + $delCommentForm->handleRequest(); + return $delCommentForm; + } +} diff --git a/modules/monitoring/application/views/scripts/comment/show.phtml b/modules/monitoring/application/views/scripts/comment/show.phtml new file mode 100644 index 0000000000..c5492a1cfb --- /dev/null +++ b/modules/monitoring/application/views/scripts/comment/show.phtml @@ -0,0 +1,76 @@ +
+ compact): ?> + tabs; ?> + + + render('partials/comment/comment-header.phtml'); ?> +
+
+ +

translate('Comment detail information') ?>

+ + + + comment->objecttype === 'service'): ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
translate('Service') ?> + icon('service', $this->translate('Service')); ?> + link()->service( + $this->comment->service_description, + $this->comment->service_display_name, + $this->comment->host_name, + $this->comment->host_display_name + ); ?> + translate('Host') ?> + icon('host', $this->translate('Host')); ?> + link()->host( + $this->comment->host_name, + $this->comment->host_display_name + ); ?> +
translate('Author') ?>icon('user', $this->translate('User')) ?> escape($this->comment->author) ?>
translate('Persistent') ?>escape($this->comment->persistent) ? $this->translate('Yes') : $this->translate('No') ?>
translate('Created') ?>escape($this->comment->timestamp)) ?>
translate('Expires') ?> + comment->expiration ? sprintf( + $this->translate('This comment expires on %s at %s.'), + date('d.m.y', $this->comment->expiration), + date('H:i', $this->comment->expiration) + ) : $this->translate('This comment does not expire.'); ?> +
translate('Commands') ?> + +
+ +
+ diff --git a/modules/monitoring/application/views/scripts/list/comments.phtml b/modules/monitoring/application/views/scripts/list/comments.phtml index 9f383345c6..8810c6e674 100644 --- a/modules/monitoring/application/views/scripts/list/comments.phtml +++ b/modules/monitoring/application/views/scripts/list/comments.phtml @@ -15,7 +15,10 @@ if (count($comments) === 0) { return; } ?> - +
objecttype === 'service'): ?> icon('service', $this->translate('Service')); ?> - link()->service( - $comment->service_description, - $comment->service_display_name, - $comment->host_name, - $comment->host_display_name - ); ?> + + qlink( + sprintf( + $this->translate('%s on %s', 'Service running on host'), + $comment->service_display_name, + $comment->host_display_name + ), + 'monitoring/comment/show', + array('comment_id' => $comment->id), + array('title' => sprintf( + $this->translate('Show detailed information for comment on %s for %s'), + $comment->service_display_name, + $comment->host_display_name + ))) ?> icon('host', $this->translate('Host')); ?> - link()->host($comment->host_name, $comment->host_display_name); ?> + + qlink( + $comment->host_display_name, + 'monitoring/comment/show', + array('comment_id' => $comment->id), + array('title' => sprintf( + $this->translate('Show detailed information for comment on %s'), + $comment->host_display_name + ))) ?>
icon('comment', $this->translate('Comment')); ?> author) diff --git a/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml b/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml new file mode 100644 index 0000000000..6b9a5c53e1 --- /dev/null +++ b/modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml @@ -0,0 +1,57 @@ +
+ + + + + +
+ + type) { + case 'flapping': + $icon = 'flapping'; + $title = $this->translate('Flapping'); + $tooltip = $this->translate('Comment was caused by a flapping host or service.'); + break; + case 'comment': + $icon = 'user'; + $title = $this->translate('User Comment'); + $tooltip = $this->translate('Comment was created by an user.'); + break; + case 'downtime': + $icon = 'plug'; + $title = $this->translate('Downtime'); + $tooltip = $this->translate('Comment was caused by a downtime.'); + break; + case 'ack': + $icon = 'ok'; + $title = $this->translate('Acknowledgement'); + $tooltip = $this->translate('Comment was caused by an acknowledgement.'); + break; + } + ?> + + escape($title); ?> +
+ icon($icon, $tooltip) ?> + prefixedTimeSince($comment->timestamp); ?> +
+ objecttype === 'service'): ?> + icon('service', $this->translate('Service')); ?> + link()->service( + $comment->service_description, + $comment->service_display_name, + $comment->host_name, + $comment->host_display_name + ); ?> + + icon('host', $this->translate('Host')); ?> + link()->host($comment->host_name, $comment->host_display_name); ?> + + +
+ icon('comment', $this->translate('Comment')); ?> author) + ? '[' . $comment->author . '] ' + : ''; + ?>escape($comment->comment); ?> +