From 4a1348f60a6c505e5dd024f441264110edf616b6 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 28 Nov 2024 10:38:49 +0100 Subject: [PATCH] ui: Change visualization of redundancy group states They can now be unreachable, thus get the same icon as others. The state then isn't about reachability anymore, so it's just critical or ok. --- .../Icingadb/Model/RedundancyGroupState.php | 26 +++++++++++++++++-- .../Widget/Detail/RedundancyGroupHeader.php | 5 +++- .../ItemList/RedundancyGroupListItem.php | 5 +++- public/css/common.less | 10 ------- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/library/Icingadb/Model/RedundancyGroupState.php b/library/Icingadb/Model/RedundancyGroupState.php index b38ee930f..e37327939 100644 --- a/library/Icingadb/Model/RedundancyGroupState.php +++ b/library/Icingadb/Model/RedundancyGroupState.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Icingadb\Model; use DateTime; +use Icinga\Module\Icingadb\Common\Icons; use ipl\Orm\Behavior\Binary; use ipl\Orm\Behavior\BoolCast; use ipl\Orm\Behavior\MillisecondTimestamp; @@ -12,6 +13,7 @@ use ipl\Orm\Model; use ipl\Orm\Query; use ipl\Orm\Relations; +use ipl\Web\Widget\Icon; /** * Redundancy group state model. @@ -66,9 +68,29 @@ public function createRelations(Relations $relations): void $relations->belongsTo('redundancy_group', RedundancyGroup::class); } + /** + * Get the state text for the redundancy group state + * + * Do not use this method to label the state of a redundancy group. + * + * @return string + */ public function getStateText(): string { - // The method should only be called to fake state balls and not to show the group's state - return $this->failed ? 'unreachable' : 'reachable'; + return $this->failed ? 'critical' : 'ok'; + } + + /** + * Get the state icon + * + * @return ?Icon + */ + public function getIcon(): ?Icon + { + if (! $this->is_reachable) { + return new Icon(Icons::UNREACHABLE); + } + + return null; } } diff --git a/library/Icingadb/Widget/Detail/RedundancyGroupHeader.php b/library/Icingadb/Widget/Detail/RedundancyGroupHeader.php index 12154c348..d98c7b0f5 100644 --- a/library/Icingadb/Widget/Detail/RedundancyGroupHeader.php +++ b/library/Icingadb/Widget/Detail/RedundancyGroupHeader.php @@ -29,7 +29,10 @@ public function __construct(RedundancyGroup $object, RedundancyGroupSummary $sum protected function assembleVisual(BaseHtmlElement $visual): void { - $visual->addHtml(new StateBall($this->object->state->getStateText(), $this->getStateBallSize())); + $stateBall = new StateBall($this->object->state->getStateText(), $this->getStateBallSize()); + $stateBall->add($this->object->state->getIcon()); + + $visual->addHtml($stateBall); } protected function assembleTitle(BaseHtmlElement $title): void diff --git a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php index eca3c9271..7b56f5cac 100644 --- a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php +++ b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php @@ -62,7 +62,10 @@ protected function createSubject(): Link protected function assembleVisual(BaseHtmlElement $visual): void { - $visual->addHtml(new StateBall($this->state->getStateText(), $this->getStateBallSize())); + $stateBall = new StateBall($this->state->getStateText(), $this->getStateBallSize()); + $stateBall->add($this->state->getIcon()); + + $visual->addHtml($stateBall); } protected function assembleCaption(BaseHtmlElement $caption): void diff --git a/public/css/common.less b/public/css/common.less index 3a28d03b0..8d314741a 100644 --- a/public/css/common.less +++ b/public/css/common.less @@ -412,13 +412,3 @@ form[name="form_confirm_removal"] { padding: 0 0.25em; .rounded-corners(); } - -.state-ball { - &.state-unreachable { - background-color: @color-critical; - } - - &.state-reachable { - background-color: @color-ok; - } -}