mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-06-09 00:32:05 -04:00
Fix negative next check value when both active and passive checks are disabled
This commit is contained in:
parent
80efce866f
commit
e1deb4209f
2 changed files with 78 additions and 6 deletions
|
|
@ -132,18 +132,30 @@ class CheckStatistics extends Card
|
|||
: (new EmptyState(t('n. a.')))->setTag('span')
|
||||
)
|
||||
);
|
||||
|
||||
if ($this->isChecksDisabled()) {
|
||||
$nextCheckBubbleContent = new VerticalKeyValue(
|
||||
t('Next Check'),
|
||||
t('n.a')
|
||||
);
|
||||
|
||||
$this->addAttributes(['class' => 'checks-disabled']);
|
||||
} else {
|
||||
$nextCheckBubbleContent = $this->object->state->is_overdue
|
||||
? new VerticalKeyValue(t('Overdue'), new TimeSince($nextCheckTime))
|
||||
: new VerticalKeyValue(
|
||||
t('Next Check'),
|
||||
$nextCheckTime !== null ? new TimeUntil($nextCheckTime) : t('PENDING')
|
||||
);
|
||||
}
|
||||
|
||||
$nextCheck = Html::tag(
|
||||
'li',
|
||||
['class' => 'end'],
|
||||
Html::tag(
|
||||
'div',
|
||||
['class' => 'bubble upwards'],
|
||||
$this->object->state->is_overdue
|
||||
? new VerticalKeyValue(t('Overdue'), new TimeSince($nextCheckTime))
|
||||
: new VerticalKeyValue(
|
||||
t('Next Check'),
|
||||
$nextCheckTime !== null ? new TimeUntil($nextCheckTime) : t('PENDING')
|
||||
)
|
||||
$nextCheckBubbleContent
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -163,6 +175,16 @@ class CheckStatistics extends Card
|
|||
$body->add([$above, $timeline, $below]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if both active and passive checks are disabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isChecksDisabled(): bool
|
||||
{
|
||||
return ! ($this->object->active_checks_enabled || $this->object->passive_checks_enabled);
|
||||
}
|
||||
|
||||
protected function assembleFooter(BaseHtmlElement $footer)
|
||||
{
|
||||
$footer->add(new HorizontalKeyValue(
|
||||
|
|
@ -231,4 +253,21 @@ class CheckStatistics extends Card
|
|||
|
||||
return $this->object->check_interval;
|
||||
}
|
||||
|
||||
protected function assemble()
|
||||
{
|
||||
parent::assemble();
|
||||
|
||||
if ($this->isChecksDisabled()) {
|
||||
$this->add(Html::tag(
|
||||
'div',
|
||||
['class' => 'checks-disabled-overlay'],
|
||||
Html::tag(
|
||||
'strong',
|
||||
['class' => 'notes'],
|
||||
t('active and passive checks are disabled')
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
.check-statistics {
|
||||
position: relative;
|
||||
.card();
|
||||
.progress-bar();
|
||||
.card-footer {
|
||||
|
|
@ -52,4 +53,36 @@
|
|||
background-color: @color-down;
|
||||
}
|
||||
}
|
||||
|
||||
&.checks-disabled.progress-bar {
|
||||
.timeline {
|
||||
.marker {
|
||||
&.start,
|
||||
&.end {
|
||||
background-color: @gray;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.checks-disabled-overlay {
|
||||
border-radius: 0.4em;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background-color: ~"@{disabled-gray}20";
|
||||
z-index: 1;
|
||||
|
||||
.notes {
|
||||
color: @text-color-light;
|
||||
margin-top: -4em;
|
||||
text-shadow: 0 0 1px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue