diff --git a/library/Icingadb/Widget/Detail/CheckStatistics.php b/library/Icingadb/Widget/Detail/CheckStatistics.php index b2a31506..31e79ad9 100644 --- a/library/Icingadb/Widget/Detail/CheckStatistics.php +++ b/library/Icingadb/Widget/Detail/CheckStatistics.php @@ -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') + ) + )); + } + } } diff --git a/public/css/widget/check-statistics.less b/public/css/widget/check-statistics.less index e2b5ac02..6e1a43d1 100644 --- a/public/css/widget/check-statistics.less +++ b/public/css/widget/check-statistics.less @@ -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); + } + } }