monitoring: Use comment-list markup for downtimes instead of feed-list

refs #5543
This commit is contained in:
Eric Lippmann 2015-10-28 09:41:21 +01:00
parent bb33a43cb9
commit 0b332bba22
3 changed files with 52 additions and 49 deletions

View File

@ -30,7 +30,6 @@ if (! $this->compact): ?>
$this->stateName = Host::getStateText($downtime->host_state); $this->stateName = Host::getStateText($downtime->host_state);
} }
$this->downtime = $downtime; $this->downtime = $downtime;
$this->displayComment = true;
?> ?>
<tr href="<?= $this->href('monitoring/downtime/show', array('downtime_id' => $downtime->id)) ?>"> <tr href="<?= $this->href('monitoring/downtime/show', array('downtime_id' => $downtime->id)) ?>">
<?= $this->render('partials/downtime/downtime-header.phtml'); ?> <?= $this->render('partials/downtime/downtime-header.phtml'); ?>

View File

@ -8,7 +8,7 @@
<?php endif; ?> <?php endif; ?>
</td> </td>
<td> <td>
<span class="comment-header"> <div class="comment-header">
<?php if ($isService): ?> <?php if ($isService): ?>
<?= $this->icon('service', $this->translate('Service')); ?> <?= $this->qlink( <?= $this->icon('service', $this->translate('Service')); ?> <?= $this->qlink(
$downtime->host_display_name . ': ' . $downtime->service_display_name, $downtime->host_display_name . ': ' . $downtime->service_display_name,
@ -38,11 +38,10 @@
) )
); ?> ); ?>
<?php endif ?> <?php endif ?>
<span class="comment-meta">
<?= $this->translate('by') ?> <?= $this->translate('by') ?>
<?= $this->escape($downtime->author_name) ?> <?= $this->escape($downtime->author_name) ?>
<span class="meta-icons">
<span class="pull-right">
<?php if ($downtime->is_flexible): ?> <?php if ($downtime->is_flexible): ?>
<?= $this->icon('magic', $this->translate('This downtime is flexible')); ?> <?= $this->icon('magic', $this->translate('This downtime is flexible')); ?>
<?php endif ?> <?php endif ?>
@ -52,22 +51,23 @@
<?php endif ?> <?php endif ?>
<?php if (isset($delDowntimeForm)): // Form is unset if the current user lacks the respective permission ?> <?php if (isset($delDowntimeForm)): // Form is unset if the current user lacks the respective permission ?>
<?php <?php
$delDowntimeForm = clone $delDowntimeForm; $deleteButton = clone $delDowntimeForm;
$delDowntimeForm->populate( /** @var \Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm $deleteButton */
array( $deleteButton->setAttrib('class', $deleteButton->getAttrib('class') . ' remove-comment');
'downtime_id' => $downtime->id, $deleteButton->populate(
'downtime_is_service' => isset($downtime->service_description) array(
) 'downtime_id' => $downtime->id,
); 'downtime_is_service' => isset($downtime->service_description)
echo $delDowntimeForm; )
?> );
echo $deleteButton;
?>
<?php endif ?> <?php endif ?>
</span>
</span> </span>
</span> </div>
<?php if (isset ($displayComment) && $displayComment): ?> <p class="comment-text">
<p class="comment-text"> <?= $this->escape($downtime->comment) ?>
<?= $this->escape($downtime->comment) ?> </p>
</p>
<?php endif ?>
</td> </td>

View File

@ -40,14 +40,14 @@ if (empty($object->comments) && ! $addLink) {
<th><?php <th><?php
echo $this->translate('Downtimes'); echo $this->translate('Downtimes');
if (! empty($object->downtimes) && $addLink) { if (! empty($object->downtimes) && $addLink) {
echo '<br />' . $addLink; echo '<br>' . $addLink;
} }
?></th> ?></th>
<td data-base-target="_self"> <td data-base-target="_self">
<?php if (empty($object->downtimes)): <?php if (empty($object->downtimes)):
echo $addLink; echo $addLink;
else: ?> else: ?>
<dl class="feed-list"> <dl class="comment-list">
<?php foreach ($object->downtimes as $downtime): <?php foreach ($object->downtimes as $downtime):
if ((bool) $downtime->is_in_effect) { if ((bool) $downtime->is_in_effect) {
$state = sprintf( $state = sprintf(
@ -72,30 +72,34 @@ if (empty($object->comments) && ! $addLink) {
); );
} }
} }
// Form is unset if the current user lacks the respective permission ?>
if (isset($delDowntimeForm)) { <dt class="comment-header">
$deleteButton = clone($delDowntimeForm); <?= $this->escape($downtime->author_name) ?>
$deleteButton->setAttrib('class', $deleteButton->getAttrib('class') . ' pull-right'); <span class="comment-meta">
$deleteButton->populate( <?= $this->translate('created') ?>
array( <?= $this->timeAgo($downtime->entry_time) ?>
'downtime_id' => $downtime->id, <span aria-hidden="true">&#448;</span>
'downtime_is_service' => $object->getType() === $object::TYPE_SERVICE <?= $state ?>
) <?php if (isset($delDowntimeForm)): // Form is unset if the current user lacks the respective permission ?>
); <span class="meta-icons">
} else { <?php
$deleteButton = ''; $deleteButton = clone($delDowntimeForm);
} /** @var \Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm $deleteButton */
?> $deleteButton->setAttrib('class', $deleteButton->getAttrib('class') . ' remove-comment');
<dt class="clearfix feed-author"> $deleteButton->populate(
<span class="author"><?= $this->escape($downtime->author_name) ?></span> array(
<?= $this->timeAgo($downtime->entry_time) ?> 'downtime_id' => $downtime->id,
<?= $deleteButton ?> 'downtime_is_service' => $object->getType() === $object::TYPE_SERVICE
</dt> )
<dd class="comment-text"> );
<?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($downtime->comment)) ?> echo $deleteButton;
</dd> ?>
<dd class="text-small"> </span>
<?= $state ?> <?php endif ?>
</span>
</dt>
<dd class="comment-text">
<p><?= str_replace(array('\r\n', '\n'), '<br>', $this->createTicketLinks($downtime->comment)) ?></p>
</dd> </dd>
<?php endforeach ?> <?php endforeach ?>
</dl> </dl>