Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #8903
- Loading branch information
Showing
4 changed files
with
248 additions
and
8 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
modules/monitoring/application/controllers/CommentController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ | ||
|
||
use Icinga\Module\Monitoring\Controller; | ||
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; | ||
use Icinga\Web\Url; | ||
use Icinga\Web\Widget\Tabextension\DashboardAction; | ||
|
||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
/** | ||
* Display detailed information about a comment | ||
*/ | ||
class Monitoring_CommentController extends Controller | ||
{ | ||
protected $comment; | ||
|
||
/** | ||
* Add tabs | ||
*/ | ||
public function init() | ||
{ | ||
$commentId = $this->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; | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
modules/monitoring/application/views/scripts/comment/show.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<div class="controls"> | ||
<?php if (! $this->compact): ?> | ||
<?= $this->tabs; ?> | ||
<?php endif ?> | ||
|
||
<?= $this->render('partials/comment/comment-header.phtml'); ?> | ||
</div> | ||
<div class="content"> | ||
|
||
<h3><?= $this->translate('Comment detail information') ?></h3> | ||
<table class="avp"> | ||
<tbody> | ||
<tr> | ||
<?php if ($this->comment->objecttype === 'service'): ?> | ||
<th> <?= $this->translate('Service') ?> </th> | ||
<td> | ||
<?= $this->icon('service', $this->translate('Service')); ?> | ||
<?= $this->link()->service( | ||
$this->comment->service_description, | ||
$this->comment->service_display_name, | ||
$this->comment->host_name, | ||
$this->comment->host_display_name | ||
); ?> | ||
</td> | ||
<?php else: ?> | ||
<th> <?= $this->translate('Host') ?> </th> | ||
<td> | ||
<?= $this->icon('host', $this->translate('Host')); ?> | ||
<?= $this->link()->host( | ||
$this->comment->host_name, | ||
$this->comment->host_display_name | ||
); ?> | ||
</td> | ||
<?php endif ?> | ||
</tr> | ||
|
||
<tr> | ||
<th><?= $this->translate('Author') ?></th> | ||
<td><?= $this->icon('user', $this->translate('User')) ?> <?= $this->escape($this->comment->author) ?></td> | ||
</tr> | ||
|
||
<tr> | ||
<th><?= $this->translate('Persistent') ?></th> | ||
<td><?= $this->escape($this->comment->persistent) ? $this->translate('Yes') : $this->translate('No') ?></td> | ||
</tr> | ||
|
||
<tr> | ||
<th><?= $this->translate('Created') ?></th> | ||
<td><?= date('d.m.y H:i' ,$this->escape($this->comment->timestamp)) ?></td> | ||
</tr> | ||
|
||
<tr> | ||
<th><?= $this->translate('Expires') ?></th> | ||
<td> | ||
<?= $this->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.'); ?> | ||
</td> | ||
</tr> | ||
|
||
<?php if (isset($delCommentForm)): // Form is unset if the current user lacks the respective permission ?> | ||
<tr class="newsection"> | ||
<th><?= $this->translate('Commands') ?></th> | ||
<td> | ||
<?= $delCommentForm ?> | ||
</td> | ||
</tr> | ||
<?php endif ?> | ||
|
||
</tbody> | ||
</table> | ||
|
||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
modules/monitoring/application/views/scripts/partials/comment/comment-header.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<table class="action"> | ||
<tr class="state invalid"> | ||
<td class="state"> | ||
|
||
<?php | ||
switch ($comment->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; | ||
} | ||
?> | ||
|
||
<strong><?= $this->escape($title); ?></strong> | ||
<br> | ||
<?= $this->icon($icon, $tooltip) ?> | ||
<?= $this->prefixedTimeSince($comment->timestamp); ?> | ||
</td> | ||
|
||
<td> | ||
<?php if ($comment->objecttype === 'service'): ?> | ||
<?= $this->icon('service', $this->translate('Service')); ?> | ||
<?= $this->link()->service( | ||
$comment->service_description, | ||
$comment->service_display_name, | ||
$comment->host_name, | ||
$comment->host_display_name | ||
); ?> | ||
<?php else: ?> | ||
<?= $this->icon('host', $this->translate('Host')); ?> | ||
<?= $this->link()->host($comment->host_name, $comment->host_display_name); ?> | ||
<?php endif ?> | ||
|
||
<br> | ||
<?= $this->icon('comment', $this->translate('Comment')); ?> <?= isset($comment->author) | ||
? '[' . $comment->author . '] ' | ||
: ''; | ||
?><?= $this->escape($comment->comment); ?> | ||
</td> | ||
</tr> | ||
</table> |