Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/Icingadb/Common/Icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
23 changes: 19 additions & 4 deletions library/Icingadb/View/BaseHostAndServiceRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand All @@ -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');
}
Expand Down Expand Up @@ -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')])
);
}

Expand Down Expand Up @@ -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;
}
}
Loading