diff --git a/library/Icingadb/Common/Icons.php b/library/Icingadb/Common/Icons.php index 00f53a6dc..2790944ad 100644 --- a/library/Icingadb/Common/Icons.php +++ b/library/Icingadb/Common/Icons.php @@ -22,6 +22,10 @@ class Icons const NOTIFICATION = 'bell'; + const NO_NOTIFICATIONS = 'bell-slash'; + + const NO_ACTIVE_CHECKS = 'eye-slash'; + const REMOVE = 'trash'; const USER = 'user'; diff --git a/library/Icingadb/View/BaseHostAndServiceRenderer.php b/library/Icingadb/View/BaseHostAndServiceRenderer.php index 1007d12f1..ce058f90f 100644 --- a/library/Icingadb/View/BaseHostAndServiceRenderer.php +++ b/library/Icingadb/View/BaseHostAndServiceRenderer.php @@ -96,7 +96,7 @@ public function assembleVisual($item, HtmlDocument $visual, string $layout): voi } } - $stateChange->setIcon($item->state->getIcon()); + $stateChange->setIcon($this->getStateBallIcon($item)); $stateChange->setHandled( $item->state->is_problem && ($item->state->is_handled || ! $item->state->is_reachable) ); @@ -109,7 +109,7 @@ public function assembleVisual($item, HtmlDocument $visual, string $layout): voi $ballSize = $layout === 'minimal' ? StateBall::SIZE_BIG : StateBall::SIZE_LARGE; $stateBall = new StateBall($item->state->getStateText(), $ballSize); - $stateBall->add($item->state->getIcon()); + $stateBall->add($this->getStateBallIcon($item)); if ($item->state->is_problem && ($item->state->is_handled || ! $item->state->is_reachable)) { $stateBall->getAttributes()->add('class', 'handled'); } @@ -274,13 +274,13 @@ public function assembleFooter($item, HtmlDocument $footer, string $layout): voi if (! $item->notifications_enabled) { $statusIcons->addHtml( - new Icon('bell-slash', ['title' => $this->translate('Notifications disabled')]) + new Icon(Icons::NO_NOTIFICATIONS, ['title' => $this->translate('Notifications disabled')]) ); } if (! $item->active_checks_enabled) { $statusIcons->addHtml( - new Icon('eye-slash', ['title' => $this->translate('Active checks disabled')]) + new Icon(Icons::NO_ACTIVE_CHECKS, ['title' => $this->translate('Active checks disabled')]) ); } @@ -336,4 +336,19 @@ public function assemble($item, string $name, HtmlDocument $element, string $lay return false; } + + protected function getStateBallIcon($item): ?Icon + { + $icon = $item->state->getIcon(); + + if ($icon === null) { + if (! $item->notifications_enabled) { + $icon = new Icon(Icons::NO_NOTIFICATIONS, ['title' => $this->translate('Notifications disabled')]); + } elseif (! $item->active_checks_enabled) { + $icon = new Icon(Icons::NO_ACTIVE_CHECKS, ['title' => $this->translate('Active checks disabled')]); + } + } + + return $icon; + } }