diff --git a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php index ed4f02b4c..6a3bdc110 100644 --- a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php +++ b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php @@ -4,17 +4,13 @@ namespace Icinga\Module\Icingadb\Widget\ItemList; -use Icinga\Module\Icingadb\Common\Auth; use Icinga\Module\Icingadb\Common\Database; use Icinga\Module\Icingadb\Common\ListItemCommonLayout; use Icinga\Module\Icingadb\Model\RedundancyGroup; use Icinga\Module\Icingadb\Model\RedundancyGroupSummary; use Icinga\Module\Icingadb\Model\RedundancyGroupState; -use Icinga\Module\Icingadb\Util\PluginOutput; -use Icinga\Module\Icingadb\Widget\PluginOutputContainer; use Icinga\Module\Icingadb\Widget\DependencyNodeStatistics; use ipl\Html\BaseHtmlElement; -use ipl\Sql\Expression; use ipl\Stdlib\Filter; use ipl\Web\Widget\StateBall; use ipl\Html\HtmlElement; @@ -30,36 +26,13 @@ class RedundancyGroupListItem extends StateListItem { use ListItemCommonLayout; - use Auth; use Database; protected $defaultAttributes = ['class' => ['list-item', 'redundancy-group-list-item']]; - /** @var RedundancyGroupSummary Objects state summary */ - protected $summary; - /** @var RedundancyGroupState */ protected $state; - /** @var bool Whether the redundancy group has been handled */ - protected $isHandled = false; - - protected function init(): void - { - parent::init(); - - $this->summary = RedundancyGroupSummary::on($this->getDb()) - ->filter(Filter::equal('id', $this->item->id)) - ->first(); - - $this->isHandled = $this->state->failed - && ( - $this->summary->nodes_problem_handled - || $this->summary->nodes_unknown_handled - || $this->summary->nodes_warning_handled - ); - } - protected function getStateBallSize(): string { return StateBall::SIZE_LARGE; @@ -81,71 +54,16 @@ protected function createSubject(): BaseHtmlElement protected function assembleVisual(BaseHtmlElement $visual): void { - $stateBall = new StateBall($this->state->getStateText(), $this->getStateBallSize()); - if ($this->isHandled) { - $stateBall->getAttributes()->add('class', 'handled'); - } - - $visual->addHtml($stateBall); + $visual->addHtml(new StateBall($this->state->getStateText(), $this->getStateBallSize())); } protected function assembleCaption(BaseHtmlElement $caption): void { - $members = RedundancyGroup::on($this->getDb()) - ->columns([ - 'id' => 'id', - 'nodes_output' => new Expression( - 'CASE WHEN redundancy_group_from_to_service.id IS NOT NULL' - . ' THEN redundancy_group_from_to_service_state.output' - . ' ELSE redundancy_group_from_to_host_state.output END' - ), - 'nodes_long_output' => new Expression( - 'CASE WHEN redundancy_group_from_to_service.id IS NOT NULL' - . ' THEN redundancy_group_from_to_service_state.long_output' - . ' ELSE redundancy_group_from_to_host_state.long_output END' - ), - 'nodes_checkcommand_name' => new Expression( - 'CASE WHEN redundancy_group_from_to_service.id IS NOT NULL' - . ' THEN redundancy_group_from_to_service.checkcommand_name' - . ' ELSE redundancy_group_from_to_host.checkcommand_name END' - ), - 'nodes_last_state_change' => new Expression( - 'CASE WHEN redundancy_group_from_to_service.id IS NOT NULL' - . ' THEN redundancy_group_from_to_service_state.last_state_change' - . ' ELSE redundancy_group_from_to_host_state.last_state_change END' - ), - 'nodes_severity' => new Expression( - 'CASE WHEN redundancy_group_from_to_service.id IS NOT NULL' - . ' THEN redundancy_group_from_to_service_state.severity' - . ' ELSE redundancy_group_from_to_host_state.severity END' - ) - ]) - ->with([ - 'from', - 'from.to.host', - 'from.to.host.state', - 'from.to.service', - 'from.to.service.state' - ]) - ->filter(Filter::equal('id', $this->item->id)) - ->orderBy([ - 'nodes_severity', - 'nodes_last_state_change', - ], SORT_DESC); - - $this->applyRestrictions($members); - - /** @var RedundancyGroup $data */ - $data = $members->first(); - - if ($data) { - $caption->addHtml(new PluginOutputContainer( - (new PluginOutput($data->nodes_output . "\n" . $data->nodes_long_output)) - ->setCommandName($data->nodes_checkcommand_name) - )); - } - - $caption->addHtml(new DependencyNodeStatistics($this->summary)); + $caption->addHtml(new DependencyNodeStatistics( + RedundancyGroupSummary::on($this->getDb()) + ->filter(Filter::equal('id', $this->item->id)) + ->first() + )); } protected function assembleTitle(BaseHtmlElement $title): void diff --git a/public/css/list/redundancy-group-list-item.less b/public/css/list/redundancy-group-list-item.less index 1c8fff2d0..3c6093549 100644 --- a/public/css/list/redundancy-group-list-item.less +++ b/public/css/list/redundancy-group-list-item.less @@ -1,19 +1,7 @@ .redundancy-group-list-item { .caption { - display: flex; - align-items: baseline; - - .plugin-output { - // Allows the plugin output width to grow or shrink based on the width of object statistics - flex: 1 1 auto; - // Since caption is not -webkit-box anymore, its line-clamp rule will not be inherited - // and hence applied here directly - .line-clamp(2); - } - .object-statistics { - // Prevents the wrapping effect caused by changing caption to a flexbox - flex: 0 0 auto; + justify-content: end; } } }