PHTML hotfix

This commit is contained in:
Alexander Klimov 2014-03-07 11:30:23 +01:00
parent 73f2bf18d0
commit 75096dd65b
3 changed files with 67 additions and 101 deletions

View File

@ -80,7 +80,7 @@ foreach ($services as $service):
<?php endif ?> <?php endif ?>
<?php if ($service->service_icon_image): ?> <?php if ($service->service_icon_image): ?>
<?= $this->img($this->resolveMacros($service->service_icon_image, $service), array('align' => 'left')) ?> <?= $this->icon($this->resolveMacros($service->service_icon_image, $service)) ?>
<?php endif ?> <?php endif ?>
<a href="<?= $serviceLink ?>"><?= $service->service_display_name ?></a> on <a href="<?= $hostLink ?>"><?= $service->host_name; ?> <a href="<?= $serviceLink ?>"><?= $service->service_display_name ?></a> on <a href="<?= $hostLink ?>"><?= $service->host_name; ?>
<?php if ($service->host_state != 0): ?> <?php if ($service->host_state != 0): ?>

View File

@ -1,6 +1,5 @@
<?php <?php
/** @var Zend_View_Helper_CommandForm $cf */
$cf = $this->getHelper('CommandForm'); $cf = $this->getHelper('CommandForm');
$data = array('host' => $object->host_name); $data = array('host' => $object->host_name);
@ -8,59 +7,43 @@ if ($object->service_description) {
$data['service'] = $object->service_description; $data['service'] = $object->service_description;
} }
?> $list = array();
<div> foreach ($object->comments as $comment) {
<div class="panel-heading">
<div class="panel-hostname">
Comments
<?php
?>
<div class="pull-right">
<a rel="tooltip" title="Add a comment" href="<?= $this->href('monitoring/command/addComment', $data) ?>" class="btn-common btn-small button"><?=
$this->icon('comment.png')
?></a>
<a rel="tooltip" title="Send custom notification" href="<?= $this->href('monitoring/command/sendCustomNotification', $data
) ?>" class="btn-common btn-small button">
<?= $this->icon('notification.png') ?>
</a>
</div>
</div>
</div>
<hr class="separator" />
<div class="panel-body">
<table class="table table-condensed table-detail">
<tbody>
<?php if (empty($object->comments)): ?>
<tr>
<td>No comments</td>
</tr>
<?php endif; ?>
<?php foreach ($object->comments as $comment): ?>
<tr>
<td>
<div class="pull-right">
<?php
$deleteData = $data;
$deleteData['commentid'] = $comment->comment_internal_id;
echo $cf->iconSubmitForm( // Ticket hook sample
'img/icons/remove.png', $text = $this->tickets ? preg_replace_callback(
'Remove comment', $this->tickets->getPattern(),
'btn-small', array($this->tickets, 'createLink'),
'removecomment', $this->escape($comment->comment_data)
$deleteData ) : $this->escape($comment->comment_data);
);
?> $deleteData = $data;
</div> $deleteData['commentid'] = $object->comment_internal_id;
<?= $this->escape($comment->comment_author); ?>, <?= $comment->comment_type; ?>
(<?= $this->format()->timeSince($comment->comment_timestamp); ?>) $iconForm = $cf->iconSubmitForm(
<div class="small-row"> 'img/icons/remove.png',
<?= $this->escape($comment->comment_data); ?> 'Remove comment',
</div> 'btn-small',
</td> 'removecomment',
</tr> $deleteData
<?php endforeach; ?> );
</tbody>
</table> $list[] = sprintf(
</div> "<br />%s [%s] %s (%s): %s\n",
</div> //'<input type="submit" value="x" style="width: 2em" />',
'<a href="#">' . $this->icon('remove_petrol.png') . '</a>' . $iconForm, // Test
$this->escape($comment->comment_author),
$this->timeSince($comment->comment_timestamp),
$comment->comment_type,
$text
);
}
?>
<tr>
<th><?= $this->translate('Comments') ?></th>
<td>
<a href="<?= $this->href('monitoring/command/addComment', $data) ?>"><?= $this->icon('comment_petrol.png') ?> <?= $this->translate('Add comment') ?></a>
<?= implode('', $list) ?>
</td>
</tr>

View File

@ -1,66 +1,49 @@
<?php <?php
$o = $this->object;
$isService = (isset($o->service_description)) ? true : false; use Icinga\Module\Monitoring\Object\Service;
$obj = new \stdClass();
$obj->handled = $o = $this->object;
($isService) ? $o->service_handled : $o->host_handled;
$obj->state = $isService = $o instanceof Service;
($isService) ? $o->service_state : $o->host_state; $obj = new \stdClass();
$obj->acknowledged = $obj->handled =
($isService) ? $o->service_acknowledged : $o->host_acknowledged; ($isService) ? $o->service_handled : $o->host_handled;
$obj->in_downtime = $obj->state =
($isService) ? $o->in_downtime : $o->host_in_downtime; ($isService) ? $o->service_state : $o->host_state;
$obj->is_flapping = $obj->acknowledged =
($isService) ? $o->is_flapping : $o->host_is_flapping; ($isService) ? $o->service_acknowledged : $o->host_acknowledged;
$obj->notifications_enabled = $obj->in_downtime =
($isService) ? $o->notifications_enabled : $o->service_notifications_enabled; ($isService) ? $o->in_downtime : $o->host_in_downtime;
$obj->active_checks_enabled = $obj->notifications_enabled =
($isService) ? $o->active_checks_enabled : $o->host_active_checks_enabled; ($isService) ? $o->notifications_enabled : $o->service_notifications_enabled;
$obj->passive_checks_enabled = $obj->active_checks_enabled =
($isService) ? $o->passive_checks_enabled : $o->host_passive_checks_enabled; ($isService) ? $o->active_checks_enabled : $o->host_active_checks_enabled;
$obj->last_comment = $obj->passive_checks_enabled =
($isService) ? $o->last_comment : $o->host_last_comment; ($isService) ? $o->passive_checks_enabled : $o->host_passive_checks_enabled;
$i = array(); $i = array();
if (! $obj->handled && $obj->state > 0) { if (! $obj->handled && $obj->state > 0) {
$i[] = $this->img('img/icons/unhandled.png', array('title' => 'Unhandled')); $i[] = $this->icon('unhandled.png', 'Unhandled');
} }
if ($obj->acknowledged && ! $obj->in_downtime) { if ($obj->acknowledged && ! $obj->in_downtime) {
$i[] = $this->icon('acknowledgement.png', 'Acknowledged'); $i[] = $this->icon('acknowledgement.png', 'Acknowledged');
} }
if ($obj->is_flapping) {
$i[] = $this->icon('flapping.png', 'Flapping');
}
if (!$obj->notifications_enabled) { if (!$obj->notifications_enabled) {
$i[] = $this->img('img/icons/notification_disabled.png', array('title' => 'Notifications Disabled')); $i[] = $this->icon('notification_disabled.png', 'Notifications Disabled');
} }
if ($obj->in_downtime) { if ($obj->in_downtime) {
$i[] = $this->img('img/icons/in_downtime.png', array('title' => 'In Downtime')); $i[] = $this->icon('in_downtime.png', 'In Downtime');
} }
if (! $obj->active_checks_enabled) { if (! $obj->active_checks_enabled) {
if ($obj->passive_checks_enabled) { if ($obj->passive_checks_enabled) {
$i[] = $this->img( $i[] = $this->icon('active_checks_disabled.png', 'Active Checks Disabled');
'img/icons/active_checks_disabled.png',
array('title' => 'Active Checks Disabled')
);
} else { } else {
$i[] = $this->img( $i[] = $this->icon('active_passive_checks_disabled.png', 'Active And Passive Checks Disabled');
'img/icons/active_passive_checks_disabled.png',
array('title' => 'Active And Passive Checks Disabled')
);
} }
} }
if ($obj->last_comment !== null) { ?><?= implode("\n", $i) ?>
$i[] = $this->icon('comment.png', 'Comments');
}
?><span>
<?= implode("\n ", $i) . "\n" ?>
</span>