diff --git a/library/Icingadb/Common/Icons.php b/library/Icingadb/Common/Icons.php index c28127dfe..ca2734125 100644 --- a/library/Icingadb/Common/Icons.php +++ b/library/Icingadb/Common/Icons.php @@ -22,6 +22,10 @@ class Icons const NOTIFICATION = 'bell'; + const NOTIFICATIONS_DISABLED = 'bell-slash'; + + const ACTIVE_CHECKS_DISABLED = 'eye-slash'; + const REMOVE = 'trash'; const USER = 'user'; diff --git a/library/Icingadb/View/BaseHostAndServiceRenderer.php b/library/Icingadb/View/BaseHostAndServiceRenderer.php index a3f293817..0ea924214 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'); } @@ -275,15 +275,27 @@ public function assembleFooter($item, HtmlDocument $footer, string $layout): voi } if (! $item->notifications_enabled) { - $statusIcons->addHtml( - new Icon('bell-slash', ['title' => $this->translate('Notifications disabled')]) - ); + $title = $isService + ? sprintf( + $this->translate('Service "%s" on "%s" has notifications disabled'), + $item->display_name, + $item->host->display_name + ) + : sprintf($this->translate('Host "%s" has notifications disabled'), $item->display_name); + + $statusIcons->addHtml(new Icon(Icons::NOTIFICATIONS_DISABLED, ['title' => $title])); } if (! $item->active_checks_enabled) { - $statusIcons->addHtml( - new Icon('eye-slash', ['title' => $this->translate('Active checks disabled')]) - ); + $title = $isService + ? sprintf( + $this->translate('Service "%s" on "%s" has active checks disabled'), + $item->display_name, + $item->host->display_name + ) + : sprintf($this->translate('Host "%s" has active checks disabled'), $item->display_name); + + $statusIcons->addHtml(new Icon(Icons::ACTIVE_CHECKS_DISABLED, ['title' => $title])); } $performanceData = new HtmlElement('div', Attributes::create(['class' => 'performance-data'])); @@ -338,4 +350,31 @@ 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::NOTIFICATIONS_DISABLED, [ + 'title' => sprintf( + '%s (%s)', + strtoupper($item->state->getStateTextTranslated()), + $this->translate('has notifications disabled') + ) + ]); + } elseif (! $item->active_checks_enabled) { + $icon = new Icon(Icons::ACTIVE_CHECKS_DISABLED, [ + 'title' => sprintf( + '%s (%s)', + strtoupper($item->state->getStateTextTranslated()), + $this->translate('has active checks disabled') + ) + ]); + } + } + + return $icon; + } } diff --git a/library/Icingadb/Widget/ItemTable/StateRowItem.php b/library/Icingadb/Widget/ItemTable/StateRowItem.php index 8bd09571c..ebe3a56d9 100644 --- a/library/Icingadb/Widget/ItemTable/StateRowItem.php +++ b/library/Icingadb/Widget/ItemTable/StateRowItem.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Icingadb\Widget\ItemTable; use Icinga\Module\Icingadb\Common\HostStates; +use Icinga\Module\Icingadb\Common\Icons; use Icinga\Module\Icingadb\Common\ServiceStates; use Icinga\Module\Icingadb\Model\Host; use Icinga\Module\Icingadb\Util\PerfDataSet; @@ -31,8 +32,29 @@ abstract class StateRowItem extends BaseStateRowItem protected function assembleVisual(BaseHtmlElement $visual) { $stateBall = new StateBall($this->item->state->getStateText(), StateBall::SIZE_LARGE); - $stateBall->add($this->item->state->getIcon()); + $icon = $this->item->state->getIcon(); + if ($icon === null) { + if (! $this->item->notifications_enabled) { + $icon = new Icon(Icons::NOTIFICATIONS_DISABLED, [ + 'title' => sprintf( + '%s (%s)', + strtoupper($this->item->state->getStateTextTranslated()), + t('has notifications disabled') + ) + ]); + } elseif (! $this->item->active_checks_enabled) { + $icon = new Icon(Icons::ACTIVE_CHECKS_DISABLED, [ + 'title' => sprintf( + '%s (%s)', + strtoupper($this->item->state->getStateTextTranslated()), + t('has active checks disabled') + ) + ]); + } + } + + $stateBall->add($icon); $stateBall->setHandled($this->item->state->is_problem && ( $this->item->state->is_handled || ! $this->item->state->is_reachable ));