Skip to content

Commit 4c6da51

Browse files
committed
Add more state pictograms to state balls
Now also add pictograms to state ball in the following cases: - Disabled active checks - Disabled notifications
1 parent 6a39bfc commit 4c6da51

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

library/Icingadb/Common/Icons.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ class Icons
2222

2323
const NOTIFICATION = 'bell';
2424

25+
const NO_NOTIFICATIONS = 'bell-slash';
26+
27+
const NO_ACTIVE_CHECKS = 'eye-slash';
28+
2529
const REMOVE = 'trash';
2630

2731
const USER = 'user';

library/Icingadb/View/BaseHostAndServiceRenderer.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function assembleVisual($item, HtmlDocument $visual, string $layout): voi
9696
}
9797
}
9898

99-
$stateChange->setIcon($item->state->getIcon());
99+
$stateChange->setIcon($this->getStateBallIcon($item));
100100
$stateChange->setHandled(
101101
$item->state->is_problem && ($item->state->is_handled || ! $item->state->is_reachable)
102102
);
@@ -109,7 +109,7 @@ public function assembleVisual($item, HtmlDocument $visual, string $layout): voi
109109
$ballSize = $layout === 'minimal' ? StateBall::SIZE_BIG : StateBall::SIZE_LARGE;
110110

111111
$stateBall = new StateBall($item->state->getStateText(), $ballSize);
112-
$stateBall->add($item->state->getIcon());
112+
$stateBall->add($this->getStateBallIcon($item));
113113
if ($item->state->is_problem && ($item->state->is_handled || ! $item->state->is_reachable)) {
114114
$stateBall->getAttributes()->add('class', 'handled');
115115
}
@@ -274,13 +274,13 @@ public function assembleFooter($item, HtmlDocument $footer, string $layout): voi
274274

275275
if (! $item->notifications_enabled) {
276276
$statusIcons->addHtml(
277-
new Icon('bell-slash', ['title' => $this->translate('Notifications disabled')])
277+
new Icon(Icons::NO_NOTIFICATIONS, ['title' => $this->translate('Notifications disabled')])
278278
);
279279
}
280280

281281
if (! $item->active_checks_enabled) {
282282
$statusIcons->addHtml(
283-
new Icon('eye-slash', ['title' => $this->translate('Active checks disabled')])
283+
new Icon(Icons::NO_ACTIVE_CHECKS, ['title' => $this->translate('Active checks disabled')])
284284
);
285285
}
286286

@@ -336,4 +336,19 @@ public function assemble($item, string $name, HtmlDocument $element, string $lay
336336

337337
return false;
338338
}
339+
340+
protected function getStateBallIcon($item): ?Icon
341+
{
342+
$icon = $item->state->getIcon();
343+
344+
if ($icon === null) {
345+
if (! $item->notifications_enabled) {
346+
$icon = new Icon(Icons::NO_NOTIFICATIONS, ['title' => $this->translate('Notifications disabled')]);
347+
} elseif (! $item->active_checks_enabled) {
348+
$icon = new Icon(Icons::NO_ACTIVE_CHECKS, ['title' => $this->translate('Active checks disabled')]);
349+
}
350+
}
351+
352+
return $icon;
353+
}
339354
}

0 commit comments

Comments
 (0)