Deduplicate comment views
Move comment detail and description into separate partial to reduce code duplication
This commit is contained in:
parent
dedc175967
commit
32da02c162
|
@ -18,40 +18,14 @@ if (count($comments) === 0) {
|
|||
<table data-base-target="_next"
|
||||
class="action comments multiselect"
|
||||
data-icinga-multiselect-url="/icingaweb2/monitoring/comments/show"
|
||||
data-icinga-multiselect-data="downtime_id">
|
||||
data-icinga-multiselect-data="comment_id">
|
||||
<tbody>
|
||||
<?php foreach ($comments as $comment): ?>
|
||||
<?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;
|
||||
}
|
||||
?>
|
||||
<?php foreach ($comments as $comment):
|
||||
$this->comment = $comment; ?>
|
||||
|
||||
<tr class="state invalid">
|
||||
<td class="state" style="width: 12em;">
|
||||
<?= $this->icon($icon, $tooltip) ?>
|
||||
<br>
|
||||
<strong><?= $this->escape($title); ?></strong>
|
||||
<br>
|
||||
<?= $this->prefixedTimeSince($comment->timestamp); ?>
|
||||
<?= $this->render('partials/comment/comment-description.phtml'); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if ($comment->objecttype === 'service'): ?>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?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); ?>
|
|
@ -0,0 +1,18 @@
|
|||
<?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); ?>
|
|
@ -1,57 +1,10 @@
|
|||
<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); ?>
|
||||
<?= $this->render('partials/comment/comment-description.phtml'); ?>
|
||||
</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); ?>
|
||||
<?= $this->render('partials/comment/comment-detail.phtml'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
Loading…
Reference in New Issue