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 NOTIFICATIONS_DISABLED = 'bell-slash';

const ACTIVE_CHECKS_DISABLED = 'eye-slash';

const REMOVE = 'trash';

const USER = 'user';
Expand Down
55 changes: 47 additions & 8 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 @@ -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']));
Expand Down Expand Up @@ -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;
}
}
24 changes: 23 additions & 1 deletion library/Icingadb/Widget/ItemTable/StateRowItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
));
Expand Down
Loading