2015-06-03 08:56:23 -04:00
|
|
|
|
<?php
|
2015-08-03 04:58:57 -04:00
|
|
|
|
$addLink = false;
|
2015-06-03 08:56:23 -04:00
|
|
|
|
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(
|
2015-09-24 11:58:33 -04:00
|
|
|
|
'class' => 'action-link',
|
2015-06-03 08:56:23 -04:00
|
|
|
|
'data-base-target' => '_self',
|
2016-11-25 09:05:46 -05:00
|
|
|
|
'icon' => 'comment-empty',
|
2015-06-03 08:56:23 -04:00
|
|
|
|
'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(
|
2015-09-24 11:58:33 -04:00
|
|
|
|
'class' => 'action-link',
|
2015-06-03 08:56:23 -04:00
|
|
|
|
'data-base-target' => '_self',
|
2016-11-25 09:05:46 -05:00
|
|
|
|
'icon' => 'comment-empty',
|
2015-06-03 08:56:23 -04:00
|
|
|
|
'title' => $this->translate('Add a new comment to this service')
|
|
|
|
|
|
)
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (empty($object->comments) && ! $addLink) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
?>
|
2014-09-12 10:52:45 -04:00
|
|
|
|
<tr>
|
2015-06-03 08:56:23 -04:00
|
|
|
|
<th><?php
|
|
|
|
|
|
echo $this->translate('Comments');
|
|
|
|
|
|
if (! empty($object->comments) && $addLink) {
|
2015-10-27 11:05:43 -04:00
|
|
|
|
echo '<br>' . $addLink;
|
2015-06-03 08:56:23 -04:00
|
|
|
|
}
|
|
|
|
|
|
?></th>
|
2022-02-07 08:47:03 -05:00
|
|
|
|
<td data-base-target="_self">
|
2015-08-03 04:58:57 -04:00
|
|
|
|
<?php if (empty($object->comments)):
|
|
|
|
|
|
echo $addLink;
|
|
|
|
|
|
else: ?>
|
2015-10-27 11:05:43 -04:00
|
|
|
|
<dl class="comment-list">
|
|
|
|
|
|
<?php foreach ($object->comments as $comment): ?>
|
2015-11-20 09:46:08 -05:00
|
|
|
|
<dt>
|
2022-02-07 08:47:03 -05:00
|
|
|
|
<a data-base-target="_next" href="<?= $this->href('monitoring/comment/show', array('comment_id' => $comment->id)) ?>">
|
2015-09-25 04:58:45 -04:00
|
|
|
|
<?= $this->escape($comment->author) ?>
|
2015-11-20 09:46:08 -05:00
|
|
|
|
<span class="comment-time">
|
2015-10-27 11:05:43 -04:00
|
|
|
|
<?= $this->translate('commented') ?>
|
|
|
|
|
|
<?= $this->timeAgo($comment->timestamp) ?>
|
2020-11-30 11:24:57 -05:00
|
|
|
|
<?php if ($comment->expiration): ?>
|
|
|
|
|
|
<span aria-hidden="true">ǀ</span>
|
|
|
|
|
|
<?= sprintf(
|
|
|
|
|
|
$this->translate('Expires %s'),
|
|
|
|
|
|
$this->timeUntil($comment->expiration)
|
|
|
|
|
|
) ?>
|
|
|
|
|
|
<?php endif ?>
|
2015-10-27 11:05:43 -04:00
|
|
|
|
</span>
|
2022-02-07 08:47:03 -05:00
|
|
|
|
</a>
|
2015-11-20 09:46:08 -05:00
|
|
|
|
<?= $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,
|
2016-09-08 09:15:53 -04:00
|
|
|
|
'comment_is_service' => isset($comment->service_description),
|
|
|
|
|
|
'comment_name' => $comment->name
|
2015-11-20 09:46:08 -05:00
|
|
|
|
)
|
|
|
|
|
|
);
|
|
|
|
|
|
echo $deleteButton;
|
|
|
|
|
|
} ?>
|
2015-09-25 04:58:45 -04:00
|
|
|
|
</dt>
|
2015-11-20 09:46:08 -05:00
|
|
|
|
<dd>
|
2021-10-01 10:10:16 -04:00
|
|
|
|
<?= $this->nl2br($this->createTicketLinks($this->markdownLine($comment->comment, [ 'class' => 'caption']))) ?>
|
2015-09-25 04:58:45 -04:00
|
|
|
|
</dd>
|
2015-08-03 04:58:57 -04:00
|
|
|
|
<?php endforeach ?>
|
2015-09-25 04:58:45 -04:00
|
|
|
|
</dl>
|
2015-08-03 04:58:57 -04:00
|
|
|
|
<?php endif ?>
|
2015-06-03 08:56:23 -04:00
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|