mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
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:
parent
5efc343f03
commit
df3caa61e9
@ -1,59 +1,66 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th><?= $this->translate('Notifications') ?></th>
|
<th><?= $this->translate('Notifications') ?></th>
|
||||||
<td>
|
<td>
|
||||||
<?php if ($this->hasPermission('monitoring/command/send-custom-notification')) {
|
<?php
|
||||||
if ($object->getType() === $object::TYPE_HOST) {
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
$ackLink = $this->href(
|
if ($this->hasPermission('monitoring/command/send-custom-notification')) {
|
||||||
'monitoring/host/send-custom-notification',
|
if ($object->getType() === $object::TYPE_HOST) {
|
||||||
array('host' => $object->getName())
|
/** @var \Icinga\Module\Monitoring\Object\Host $object */
|
||||||
);
|
echo $this->qlink(
|
||||||
} else {
|
$this->translate('Send notification'),
|
||||||
$ackLink = $this->href(
|
'monitoring/host/send-custom-notification',
|
||||||
'monitoring/service/send-custom-notification',
|
array('host' => $object->getName()),
|
||||||
array('host' => $object->getHost()->getName(), 'service' => $object->getName())
|
array(
|
||||||
);
|
'icon' => 'bell',
|
||||||
}
|
'data-base-target' => '_self',
|
||||||
?>
|
'title' => $this->translate(
|
||||||
<?= $this->qlink(
|
'Send a custom notification to contacts responsible for this host'
|
||||||
$this->translate('Send notification'),
|
)
|
||||||
$ackLink,
|
)
|
||||||
null,
|
);
|
||||||
array(
|
} else {
|
||||||
'icon' => 'bell',
|
/** @var \Icinga\Module\Monitoring\Object\Service $object */
|
||||||
'data-base-target' => '_self',
|
echo $this->qlink(
|
||||||
'title' => $this->translate(
|
$this->translate('Send notification'),
|
||||||
'Send a custom notification, share information about the'
|
'monitoring/service/send-custom-notification',
|
||||||
. ' object to contacts.'
|
array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
|
||||||
)
|
array(
|
||||||
)
|
'icon' => 'bell',
|
||||||
) ?><br />
|
'data-base-target' => '_self',
|
||||||
<?php } ?>
|
'title' => $this->translate(
|
||||||
<?php
|
'Send a custom notification to contacts responsible for this service'
|
||||||
// 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 ((int) $object->current_notification_number === 1) {
|
if (! in_array((int) $object->state, array(0, 99))) {
|
||||||
$msg = sprintf(
|
echo '<br />';
|
||||||
$this->translate('A notification has been sent for this issue %s.'),
|
}
|
||||||
$this->timeAgo($object->last_notification)
|
} elseif (in_array((int) $object->state, array(0, 99))) {
|
||||||
);
|
echo '-';
|
||||||
} else {
|
|
||||||
$msg = sprintf(
|
|
||||||
$this->translate('%d notifications have been sent for this issue.'),
|
|
||||||
$object->current_notification_number
|
|
||||||
) . '<br />' . sprintf(
|
|
||||||
$this->translate('The last one was sent %s.'),
|
|
||||||
$this->timeAgo($object->last_notification)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
echo $msg;
|
// We are not interested in notifications for OK or pending objects
|
||||||
} else {
|
if (! in_array((int) $object->state, array(0, 99))) {
|
||||||
echo '('
|
if ($object->current_notification_number > 0) {
|
||||||
. $this->translate('No notification has been sent for this issue.')
|
if ((int) $object->current_notification_number === 1) {
|
||||||
. ')';
|
$msg = sprintf(
|
||||||
}
|
$this->translate('A notification has been sent for this issue %s.'),
|
||||||
}
|
$this->timeAgo($object->last_notification)
|
||||||
?>
|
);
|
||||||
</td>
|
} else {
|
||||||
|
$msg = sprintf(
|
||||||
|
$this->translate('%d notifications have been sent for this issue.'),
|
||||||
|
$object->current_notification_number
|
||||||
|
) . '<br />' . sprintf(
|
||||||
|
$this->translate('The last one was sent %s.'),
|
||||||
|
$this->timeAgo($object->last_notification)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$msg = $this->translate('No notification has been sent for this issue.');
|
||||||
|
}
|
||||||
|
echo $msg;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user