monitoring: Fix duration, date and time formatting for downtimes

refs #6778
This commit is contained in:
Eric Lippmann 2015-05-22 10:06:55 +02:00
parent de9be044b3
commit da97523fa0
4 changed files with 75 additions and 75 deletions

View File

@ -1,13 +1,13 @@
<div class="controls"> <div class="controls">
<?php if (! $this->compact): ?> <?php if (! $this->compact): ?>
<?= $this->tabs; ?> <?= $this->tabs; ?>
<?php endif ?> <?php endif ?>
<?= $this->render('partials/downtime/downtime-header.phtml'); ?> <?= $this->render('partials/downtime/downtime-header.phtml'); ?>
</div> </div>
<div class="content"> <div class="content">
<h3><?= $this->translate('Downtime detail information') ?></h3> <h3><?= $this->translate('Downtime detail information') ?></h3>
<table class="avp"> <table class="avp">
<tbody> <tbody>
<tr> <tr>
<th> <th>
@ -15,17 +15,17 @@
</th> </th>
<td data-base-target="_next"> <td data-base-target="_next">
<?php if ($this->isService): ?> <?php if ($this->isService): ?>
<?php <?php
$link = $this->link()->service( $link = $this->link()->service(
$downtime->service_description, $downtime->service_description,
$downtime->service_display_name, $downtime->service_display_name,
$downtime->host_name, $downtime->host_name,
$downtime->host_display_name $downtime->host_display_name
); );
$icon = $this->icon('service', $this->translate('Service')); $icon = $this->icon('service', $this->translate('Service'));
?> ?>
<?php else: ?> <?php else: ?>
<?php <?php
$icon = $this->icon('host', $this->translate('Host')); $icon = $this->icon('host', $this->translate('Host'));
$link = $this->link()->host($downtime->host_name, $downtime->host_display_name) $link = $this->link()->host($downtime->host_name, $downtime->host_display_name)
?> ?>
@ -33,7 +33,7 @@
<?= $icon ?> <?= $icon ?>
<?= $link ?> <?= $link ?>
</td> </td>
</tr> </tr>
<tr title="<?= $this->translate('The name of the person who scheduled this downtime'); ?>"> <tr title="<?= $this->translate('The name of the person who scheduled this downtime'); ?>">
<th><?= $this->translate('Author') ?></th> <th><?= $this->translate('Author') ?></th>
<td><?= $this->icon('user', $this->translate('User')) ?> <?= $this->escape($this->downtime->author_name) ?></td> <td><?= $this->icon('user', $this->translate('User')) ?> <?= $this->escape($this->downtime->author_name) ?></td>
@ -44,19 +44,19 @@
</tr> </tr>
<tr title="<?= $this->translate('Date and time this downtime was entered'); ?>"> <tr title="<?= $this->translate('Date and time this downtime was entered'); ?>">
<th><?= $this->translate('Entry Time') ?></th> <th><?= $this->translate('Entry Time') ?></th>
<td> <?= date('d.m.y H:i' ,$this->escape($this->downtime->entry_time)) ?></td> <td><?= $this->formatDateTime($this->downtime->entry_time) ?></td>
</tr> </tr>
<tr class="newsection"> <tr class="newsection">
<th><?= $this->escape( <th><?= $this->escape(
$this->downtime->is_flexible ? $this->downtime->is_flexible ?
$this->translate('Flexible') : $this->translate('Fixed') $this->translate('Flexible') : $this->translate('Fixed')
); ?></th> ); ?></th>
<td> <td>
<?= $this->escape( <?= $this->escape(
$this->downtime->is_flexible ? $this->downtime->is_flexible ?
$this->translate('Flexible downtimes have a hard start and end time,' $this->translate('Flexible downtimes have a hard start and end time,'
. ' but also an additional restriction on the duration in which ' . ' but also an additional restriction on the duration in which '
. ' the host or service may actually be down.') : . ' the host or service may actually be down.') :
$this->translate('Fixed downtimes have a static start and end time.') $this->translate('Fixed downtimes have a static start and end time.')
); ?> ); ?>
</td> </td>
@ -66,14 +66,14 @@
. 'this refers to the earliest possible time that the downtime' . 'this refers to the earliest possible time that the downtime'
. ' can start'); ?>"> . ' can start'); ?>">
<th><?= $this->translate('Scheduled start') ?></th> <th><?= $this->translate('Scheduled start') ?></th>
<td><?= date('d.m.y H:i', $this->downtime->scheduled_start) ?></td> <td><?= $this->formatDateTime($this->downtime->scheduled_start) ?></td>
</tr> </tr>
<tr title="<?= $this->translate('The date/time the scheduled downtime is ' <tr title="<?= $this->translate('The date/time the scheduled downtime is '
. 'supposed to end. If this is a flexible (non-fixed) downtime, ' . 'supposed to end. If this is a flexible (non-fixed) downtime, '
. 'this refers to the last possible time that the downtime can ' . 'this refers to the last possible time that the downtime can '
. 'start'); ?>"> . 'start'); ?>">
<th><?= $this->translate('Scheduled end') ?></th> <th><?= $this->translate('Scheduled end') ?></th>
<td><?= date('d.m.y H:i', $this->downtime->scheduled_end) ?></td> <td><?= $this->formatDateTime($this->downtime->scheduled_end) ?></td>
</tr> </tr>
<?php if ($this->downtime->is_flexible): ?> <?php if ($this->downtime->is_flexible): ?>
<tr title="<?= $this->translate('Indicates the number of seconds that the ' <tr title="<?= $this->translate('Indicates the number of seconds that the '
@ -81,31 +81,31 @@
. ' this is a flexible downtime, which can start at a variable ' . ' this is a flexible downtime, which can start at a variable '
. 'time, but lasts for the specified duration'); ?>"> . 'time, but lasts for the specified duration'); ?>">
<th tit><?= $this->translate('Duration') ?></th> <th tit><?= $this->translate('Duration') ?></th>
<td><?= $this->format()->duration($this->escape($this->downtime->duration)); ?></td> <td><?= $this->formatDuration($this->downtime->duration) ?></td>
</tr> </tr>
<tr title="<?= $this->translate('he date/time the scheduled downtime was' <tr title="<?= $this->translate('he date/time the scheduled downtime was'
. ' actually started'); ?>"> . ' actually started'); ?>">
<th><?= $this->translate('Actual start time') ?></th> <th><?= $this->translate('Actual start time') ?></th>
<td><?= date('d.m.y H:i', $downtime->start); ?></td> <td><?= $this->formatDateTime($downtime->start) ?></td>
</tr> </tr>
<tr title="<?= $this->translate('The date/time the scheduled downtime ' <tr title="<?= $this->translate('The date/time the scheduled downtime '
. 'actually ended'); ?>"> . 'actually ended'); ?>">
<th><?= $this->translate('Actual end time') ?></th> <th><?= $this->translate('Actual end time') ?></th>
<td><?= date('d.m.y H:i', $downtime->end); ?></td> <td><?= $this->formatDateTime($downtime->end) ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<tr class="newsection"> <tr class="newsection">
<th><?= $this->translate('In effect') ?></th> <th><?= $this->translate('In effect') ?></th>
<td> <td>
<?= $this->escape( <?= $this->escape(
$this->downtime->is_in_effect ? $this->downtime->is_in_effect ?
$this->translate('Yes') : $this->translate('No') $this->translate('Yes') : $this->translate('No')
); );
?> ?>
</td> </td>
</tr> </tr>
<?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 ?>
<tr class="newsection"> <tr class="newsection">
<th><?= $this->translate('Commands') ?></th> <th><?= $this->translate('Commands') ?></th>

View File

@ -26,8 +26,8 @@ if (count($downtimes) === 0) {
return; return;
} }
?> ?>
<table data-base-target="_next" <table data-base-target="_next"
class="action multiselect" class="action multiselect"
data-icinga-multiselect-url="/icingaweb2/monitoring/downtimes/show" data-icinga-multiselect-url="/icingaweb2/monitoring/downtimes/show"
data-icinga-multiselect-data="downtime_id"> data-icinga-multiselect-data="downtime_id">
<tbody> <tbody>
@ -48,12 +48,12 @@ if (count($downtimes) === 0) {
<?= $downtime->is_in_effect ? $this->timeSince($downtime->start, $this->compact) : $this->timeUntil($downtime->start, $this->compact) ?> <?= $downtime->is_in_effect ? $this->timeSince($downtime->start, $this->compact) : $this->timeUntil($downtime->start, $this->compact) ?>
</td> </td>
<td> <td>
<?php <?php
if ($isService) { if ($isService) {
echo $this->icon('service'); echo $this->icon('service');
} else { } else {
echo $this->icon('host'); echo $this->icon('host');
} }
?> ?>
<?= $this->qlink( <?= $this->qlink(
sprintf($this->translate('%s on %s', 'Service running on host'), $downtime->service_display_name, $downtime->host_display_name), sprintf($this->translate('%s on %s', 'Service running on host'), $downtime->service_display_name, $downtime->host_display_name),
@ -74,20 +74,20 @@ if (count($downtimes) === 0) {
$isService $isService
? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.')
: $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'),
date('d.m.y', $downtime->start), $this->formatDate($downtime->start),
date('H:i', $downtime->start), $this->formatTime($downtime->start),
$this->format()->duration($downtime->duration), $this->formatDuration($downtime->duration),
date('d.m.y', $downtime->end), $this->formatDate($downtime->end),
date('H:i', $downtime->end) $this->formatTime($downtime->end)
); ?> ); ?>
<?php else: ?> <?php else: ?>
<?= sprintf( <?= sprintf(
$isService $isService
? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.')
: $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'),
date('d.m.y H:i', $downtime->scheduled_start), $this->formatDateTime($downtime->scheduled_start),
date('d.m.y H:i', $downtime->scheduled_end), $this->formatDateTime($downtime->scheduled_end),
$this->format()->duration($downtime->duration) $this->formatDuration($downtime->duration)
); ?> ); ?>
<?php endif ?> <?php endif ?>
<?php else: ?> <?php else: ?>
@ -96,20 +96,20 @@ if (count($downtimes) === 0) {
$isService $isService
? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.')
: $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'),
date('d.m.y', $downtime->start), $this->formatDate($downtime->start),
date('H:i', $downtime->start), $this->formatTime($downtime->start),
date('d.m.y', $downtime->end), $this->formatDate($downtime->end),
date('H:i', $downtime->end) $this->formatTime($downtime->end)
); ?> ); ?>
<?php else: ?> <?php else: ?>
<?= sprintf( <?= sprintf(
$isService $isService
? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.')
: $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
date('d.m.y', $downtime->scheduled_start), $this->formatDate($downtime->start),
date('H:i', $downtime->scheduled_start), $this->formatTime($downtime->start),
date('d.m.y', $downtime->scheduled_end), $this->formatDate($downtime->end),
date('H:i', $downtime->scheduled_end) $this->formatTime($downtime->end)
); ?> ); ?>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>

View File

@ -13,20 +13,20 @@
$this->isService $this->isService
? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.')
: $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'),
date('d.m.y', $downtime->start), $this->formatDate($downtime->start),
date('H:i', $downtime->start), $this->formatTime($downtime->start),
$this->format()->duration($downtime->duration), $this->formatDuration($downtime->duration),
date('d.m.y', $downtime->end), $this->formatDate($downtime->end),
date('H:i', $downtime->end) $this->formatTime($downtime->end)
); ?> ); ?>
<?php else: ?> <?php else: ?>
<?= sprintf( <?= sprintf(
$this->isService $this->isService
? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.')
: $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'),
date('d.m.y H:i', $downtime->scheduled_start), $this->formatDateTime($downtime->scheduled_start),
date('d.m.y H:i', $downtime->scheduled_end), $this->formatDateTime($downtime->scheduled_end),
$this->format()->duration($downtime->duration) $this->formatDuration($downtime->duration)
); ?> ); ?>
<?php endif ?> <?php endif ?>
<?php else: ?> <?php else: ?>
@ -35,20 +35,20 @@
$this->isService $this->isService
? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.')
: $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'),
date('d.m.y', $downtime->start), $this->formatDate($downtime->start),
date('H:i', $downtime->start), $this->formatTime($downtime->start),
date('d.m.y', $downtime->end), $this->formatDate($downtime->end),
date('H:i', $downtime->end) $this->formatTime($downtime->end)
); ?> ); ?>
<?php else: ?> <?php else: ?>
<?= sprintf( <?= sprintf(
$this->isService $this->isService
? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.')
: $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
date('d.m.y', $downtime->scheduled_start), $this->formatDate($downtime->start),
date('H:i', $downtime->scheduled_start), $this->formatTime($downtime->start),
date('d.m.y', $downtime->scheduled_end), $this->formatDate($downtime->end),
date('H:i', $downtime->scheduled_end) $this->formatTime($downtime->end)
); ?> ); ?>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>

View File

@ -25,20 +25,20 @@
$this->isService $this->isService
? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.') ? $this->translate('This flexible service downtime was started on %s at %s and lasts for %s until %s at %s.')
: $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'), : $this->translate('This flexible host downtime was started on %s at %s and lasts for %s until %s at %s.'),
date('d.m.y', $downtime->start), $this->formatDate($downtime->start),
date('H:i', $downtime->start), $this->formatTime($downtime->start),
$this->format()->duration($downtime->duration), $this->formatDuration($downtime->duration),
date('d.m.y', $downtime->end), $this->formatDate($downtime->end),
date('H:i', $downtime->end) $this->formatTime($downtime->end)
); ?> ); ?>
<?php else: ?> <?php else: ?>
<?= sprintf( <?= sprintf(
$this->isService $this->isService
? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.') ? $this->translate('This flexible service downtime has been scheduled to start between %s - %s and to last for %s.')
: $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'), : $this->translate('This flexible host downtime has been scheduled to start between %s - %s and to last for %s.'),
date('d.m.y H:i', $downtime->scheduled_start), $this->formatDateTime($downtime->scheduled_start),
date('d.m.y H:i', $downtime->scheduled_end), $this->formatDateTime($downtime->scheduled_end),
$this->format()->duration($downtime->duration) $this->formatDuration($downtime->duration)
); ?> ); ?>
<?php endif ?> <?php endif ?>
<?php else: ?> <?php else: ?>
@ -47,20 +47,20 @@
$this->isService $this->isService
? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.') ? $this->translate('This fixed service downtime was started on %s at %s and expires on %s at %s.')
: $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'), : $this->translate('This fixed host downtime was started on %s at %s and expires on %s at %s.'),
date('d.m.y', $downtime->start), $this->formatDate($downtime->start),
date('H:i', $downtime->start), $this->formatTime($downtime->start),
date('d.m.y', $downtime->end), $this->formatDate($downtime->end),
date('H:i', $downtime->end) $this->formatTime($downtime->end)
); ?> ); ?>
<?php else: ?> <?php else: ?>
<?= sprintf( <?= sprintf(
$this->isService $this->isService
? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.') ? $this->translate('This fixed service downtime has been scheduled to start on %s at %s and to end on %s at %s.')
: $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'), : $this->translate('This fixed host downtime has been scheduled to start on %s at %s and to end on %s at %s.'),
date('d.m.y', $downtime->scheduled_start), $this->formatDate($downtime->start),
date('H:i', $downtime->scheduled_start), $this->formatTime($downtime->start),
date('d.m.y', $downtime->scheduled_end), $this->formatDate($downtime->end),
date('H:i', $downtime->scheduled_end) $this->formatTime($downtime->end)
); ?> ); ?>
<?php endif ?> <?php endif ?>
<?php endif ?> <?php endif ?>