diff options
Diffstat (limited to 'modules/monitoring/application/views/scripts/show/components/comments.phtml')
-rw-r--r-- | modules/monitoring/application/views/scripts/show/components/comments.phtml | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/modules/monitoring/application/views/scripts/show/components/comments.phtml b/modules/monitoring/application/views/scripts/show/components/comments.phtml new file mode 100644 index 0000000..fd980ee --- /dev/null +++ b/modules/monitoring/application/views/scripts/show/components/comments.phtml @@ -0,0 +1,86 @@ +<?php +$addLink = false; +if ($this->hasPermission('monitoring/command/comment/add')) { + /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ + if ($object->getType() === $object::TYPE_HOST) { + $addLink = $this->qlink( + $this->translate('Add comment'), + 'monitoring/host/add-comment', + array('host' => $object->getName()), + array( + 'class' => 'action-link', + 'data-base-target' => '_self', + 'icon' => 'comment-empty', + 'title' => $this->translate('Add a new comment to this host') + ) + ); + } else { + $addLink = $this->qlink( + $this->translate('Add comment'), + 'monitoring/service/add-comment', + array('host' => $object->getHost()->getName(), 'service' => $object->getName()), + array( + 'class' => 'action-link', + 'data-base-target' => '_self', + 'icon' => 'comment-empty', + 'title' => $this->translate('Add a new comment to this service') + ) + ); + } +} +if (empty($object->comments) && ! $addLink) { + return; +} +?> +<tr> + <th><?php + echo $this->translate('Comments'); + if (! empty($object->comments) && $addLink) { + echo '<br>' . $addLink; + } + ?></th> + <td data-base-target="_self"> + <?php if (empty($object->comments)): + echo $addLink; + else: ?> + <dl class="comment-list"> + <?php foreach ($object->comments as $comment): ?> + <dt> + <a data-base-target="_next" href="<?= $this->href('monitoring/comment/show', array('comment_id' => $comment->id)) ?>"> + <?= $this->escape($comment->author) ?> + <span class="comment-time"> + <?= $this->translate('commented') ?> + <?= $this->timeAgo($comment->timestamp) ?> + <?php if ($comment->expiration): ?> + <span aria-hidden="true">ǀ</span> + <?= sprintf( + $this->translate('Expires %s'), + $this->timeUntil($comment->expiration) + ) ?> + <?php endif ?> + </span> + </a> + <?= $comment->persistent ? $this->icon('attach', 'This comment is persistent.') : '' ?> + <?php if (isset($delCommentForm)) { + // Form is unset if the current user lacks the respective permission + $deleteButton = clone($delCommentForm); + /** @var \Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm $deleteButton */ + $deleteButton->setAttrib('class', $deleteButton->getAttrib('class') . ' remove-action'); + $deleteButton->populate( + array( + 'comment_id' => $comment->id, + 'comment_is_service' => isset($comment->service_description), + 'comment_name' => $comment->name + ) + ); + echo $deleteButton; + } ?> + </dt> + <dd> + <?= $this->nl2br($this->createTicketLinks($this->markdownLine($comment->comment, [ 'class' => 'caption']))) ?> + </dd> + <?php endforeach ?> + </dl> + <?php endif ?> + </td> +</tr> |