Improve notifications view component for objects

The old view did not show a hyphen if the user lacked the permissions to send a notification and if viewing a host or service not currently in a problem state.
Further the tooltip for send notification was bad English and the view generated a superfluous <br>.
This commit is contained in:
Eric Lippmann 2015-04-10 10:46:19 +02:00
parent 5efc343f03
commit df3caa61e9

View File

@ -1,37 +1,46 @@
<tr> <tr>
<th><?= $this->translate('Notifications') ?></th> <th><?= $this->translate('Notifications') ?></th>
<td> <td>
<?php if ($this->hasPermission('monitoring/command/send-custom-notification')) { <?php
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
if ($this->hasPermission('monitoring/command/send-custom-notification')) {
if ($object->getType() === $object::TYPE_HOST) { if ($object->getType() === $object::TYPE_HOST) {
$ackLink = $this->href( /** @var \Icinga\Module\Monitoring\Object\Host $object */
'monitoring/host/send-custom-notification', echo $this->qlink(
array('host' => $object->getName())
);
} else {
$ackLink = $this->href(
'monitoring/service/send-custom-notification',
array('host' => $object->getHost()->getName(), 'service' => $object->getName())
);
}
?>
<?= $this->qlink(
$this->translate('Send notification'), $this->translate('Send notification'),
$ackLink, 'monitoring/host/send-custom-notification',
null, array('host' => $object->getName()),
array( array(
'icon' => 'bell', 'icon' => 'bell',
'data-base-target' => '_self', 'data-base-target' => '_self',
'title' => $this->translate( 'title' => $this->translate(
'Send a custom notification, share information about the' 'Send a custom notification to contacts responsible for this host'
. ' object to contacts.'
) )
) )
) ?><br /> );
<?php } ?> } else {
<?php /** @var \Icinga\Module\Monitoring\Object\Service $object */
// We are not interested in notifications for OK or pending objects echo $this->qlink(
if (! in_array((int) $object->state, array(0, 99))) { $this->translate('Send notification'),
'monitoring/service/send-custom-notification',
array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
array(
'icon' => 'bell',
'data-base-target' => '_self',
'title' => $this->translate(
'Send a custom notification to contacts responsible for this service'
)
)
);
}
if (! in_array((int) $object->state, array(0, 99))) {
echo '<br />';
}
} elseif (in_array((int) $object->state, array(0, 99))) {
echo '&#45;';
}
// We are not interested in notifications for OK or pending objects
if (! in_array((int) $object->state, array(0, 99))) {
if ($object->current_notification_number > 0) { if ($object->current_notification_number > 0) {
if ((int) $object->current_notification_number === 1) { if ((int) $object->current_notification_number === 1) {
$msg = sprintf( $msg = sprintf(
@ -47,13 +56,11 @@ if (! in_array((int) $object->state, array(0, 99))) {
$this->timeAgo($object->last_notification) $this->timeAgo($object->last_notification)
); );
} }
echo $msg;
} else { } else {
echo '(' $msg = $this->translate('No notification has been sent for this issue.');
. $this->translate('No notification has been sent for this issue.')
. ')';
} }
} echo $msg;
?> }
?>
</td> </td>
</tr> </tr>