monitoring: Fix mess in the downtimes-header view script
This commit is contained in:
parent
2f47791a70
commit
568c0f0955
|
@ -1,39 +1,56 @@
|
||||||
|
<?php
|
||||||
|
use Icinga\Module\Monitoring\Object\Host;
|
||||||
|
use Icinga\Module\Monitoring\Object\Service;
|
||||||
|
?>
|
||||||
<table class="action" data-base-target="_next">
|
<table class="action" data-base-target="_next">
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php $i = 0; foreach ($downtimes as $downtime):
|
<?php
|
||||||
if (++ $i > 5) {
|
foreach ($this->downtimes as $i => $downtime):
|
||||||
|
if ($i > 5) {
|
||||||
break;
|
break;
|
||||||
} ?>
|
}
|
||||||
<tr class="state <?= $downtime->stateText ?>">
|
if ($downtime->objecttype === 'service') {
|
||||||
|
$isService = true;
|
||||||
|
$stateText = Service::getStateText($downtime->service_state);
|
||||||
|
} else {
|
||||||
|
$isService = false;
|
||||||
|
$stateText = Host::getStateText($downtime->host_state);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<tr class="state <?= $stateText . ($downtime->is_in_effect ? ' handled' : '') ?>">
|
||||||
<td class="state">
|
<td class="state">
|
||||||
<?php if ($downtime->start <= time() && ! $downtime->is_in_effect): ?>
|
<?php if ($downtime->start <= time() && ! $downtime->is_in_effect): ?>
|
||||||
<strong><?= $this->translate('Ends'); ?></strong>
|
<strong><?= $this->translate('Ends') ?></strong>
|
||||||
<br>
|
<br>
|
||||||
<?= $this->timeUntil($downtime->is_flexible ? $downtime->scheduled_end : $downtime->end, $this->compact) ?>
|
<?= $this->timeUntil(
|
||||||
|
$downtime->is_flexible ? $downtime->scheduled_end : $downtime->end, $this->compact
|
||||||
|
) ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<strong><?= $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts'); ?></strong>
|
<strong>
|
||||||
|
<?= $downtime->is_in_effect ? $this->translate('Expires') : $this->translate('Starts') ?>
|
||||||
|
</strong>
|
||||||
<br>
|
<br>
|
||||||
<?= $this->timeUntil($downtime->is_in_effect ? $downtime->end : $downtime->start, $this->compact) ?>
|
<?= $this->timeUntil($downtime->is_in_effect ? $downtime->end : $downtime->start, $this->compact) ?>
|
||||||
<?php endif; ?>
|
<?php endif ?>
|
||||||
</td>
|
</td>
|
||||||
<td class="name oneline">
|
<td class="name oneline">
|
||||||
<?php if ($downtime->isService): ?>
|
<?php if ($isService): ?>
|
||||||
<?= $this->icon('service', $this->translate('Service')) ?>
|
<?= $this->icon('service', $this->translate('Service')) ?>
|
||||||
<?= $this->link()->service(
|
<?= $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
|
||||||
); ?>
|
) ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= $this->icon('host', $this->translate('Host')) ?>
|
<?= $this->icon('host', $this->translate('Host')) ?>
|
||||||
<?= $this->link()->host($downtime->host_name, $downtime->host_display_name); ?>
|
<?= $this->link()->host($downtime->host_name, $downtime->host_display_name) ?>
|
||||||
<?php endif; ?>
|
<?php endif ?>
|
||||||
<br>
|
<br>
|
||||||
<?php if ($downtime->is_flexible): ?>
|
<?php if ($downtime->is_flexible): ?>
|
||||||
<?php if ($downtime->is_in_effect): ?>
|
<?php if ($downtime->is_in_effect): ?>
|
||||||
<?= sprintf(
|
<?= sprintf(
|
||||||
$downtime->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.'),
|
||||||
$this->formatDate($downtime->start),
|
$this->formatDate($downtime->start),
|
||||||
|
@ -41,55 +58,54 @@
|
||||||
$this->formatDuration($downtime->duration),
|
$this->formatDuration($downtime->duration),
|
||||||
$this->formatDate($downtime->end),
|
$this->formatDate($downtime->end),
|
||||||
$this->formatTime($downtime->end)
|
$this->formatTime($downtime->end)
|
||||||
); ?>
|
) ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= sprintf(
|
<?= sprintf(
|
||||||
$downtime->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.'),
|
||||||
$this->formatDateTime($downtime->scheduled_start),
|
$this->formatDateTime($downtime->scheduled_start),
|
||||||
$this->formatDateTime($downtime->scheduled_end),
|
$this->formatDateTime($downtime->scheduled_end),
|
||||||
$this->formatDuration($downtime->duration)
|
$this->formatDuration($downtime->duration)
|
||||||
); ?>
|
) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php if ($downtime->is_in_effect): ?>
|
<?php if ($downtime->is_in_effect): ?>
|
||||||
<?= sprintf(
|
<?= sprintf(
|
||||||
$downtime->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.'),
|
||||||
$this->formatDate($downtime->start),
|
$this->formatDate($downtime->start),
|
||||||
$this->formatTime($downtime->start),
|
$this->formatTime($downtime->start),
|
||||||
$this->formatDate($downtime->end),
|
$this->formatDate($downtime->end),
|
||||||
$this->formatTime($downtime->end)
|
$this->formatTime($downtime->end)
|
||||||
); ?>
|
) ?>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?= sprintf(
|
<?= sprintf(
|
||||||
$downtime->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.'),
|
||||||
$this->formatDate($downtime->scheduled_start),
|
$this->formatDate($downtime->scheduled_start),
|
||||||
$this->formatTime($downtime->scheduled_start),
|
$this->formatTime($downtime->scheduled_start),
|
||||||
$this->formatDate($downtime->scheduled_end),
|
$this->formatDate($downtime->scheduled_end),
|
||||||
$this->formatTime($downtime->scheduled_end)
|
$this->formatTime($downtime->scheduled_end)
|
||||||
); ?>
|
) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<?php if ($downtimes->count() > 5): ?>
|
||||||
<?php if (count($downtimes) > 5): ?>
|
|
||||||
<p>
|
<p>
|
||||||
<?= $this->qlink(
|
<?= $this->qlink(
|
||||||
sprintf($this->translate('List all %d downtimes'), $i),
|
sprintf($this->translate('List all %d downtimes'), $downtimes->count()),
|
||||||
$listAllLink,
|
$listAllLink,
|
||||||
null,
|
null,
|
||||||
array(
|
array(
|
||||||
'icon' => 'down-open',
|
'data-base-target' => '_next',
|
||||||
'data-base-target' => "_next"
|
'icon' => 'down-open'
|
||||||
)
|
)
|
||||||
) ?>
|
) ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue