diff --git a/library/Icingadb/Model/RedundancyGroupParentStateSummary.php b/library/Icingadb/Model/DependencyNodeSummary.php similarity index 58% rename from library/Icingadb/Model/RedundancyGroupParentStateSummary.php rename to library/Icingadb/Model/DependencyNodeSummary.php index 6cf4cf3a1..44984c03c 100644 --- a/library/Icingadb/Model/RedundancyGroupParentStateSummary.php +++ b/library/Icingadb/Model/DependencyNodeSummary.php @@ -13,65 +13,70 @@ /** * Redundancy group's parent nodes summary * - * @property int $objects_problem_handled - * @property int $objects_problem_unhandled - * @property int $objects_pending - * @property int $objects_total - * @property int $objects_ok - * @property int $objects_unknown_handled - * @property int $objects_unknown_unhandled - * @property int $objects_warning_handled - * @property int $objects_warning_unhandled + * @property int $nodes_problem_handled + * @property int $nodes_problem_unhandled + * @property int $nodes_pending + * @property int $nodes_total + * @property int $nodes_ok + * @property int $nodes_unknown_handled + * @property int $nodes_unknown_unhandled + * @property int $nodes_warning_handled + * @property int $nodes_warning_unhandled */ -class RedundancyGroupParentStateSummary extends RedundancyGroup +class DependencyNodeSummary extends RedundancyGroup { public function getSummaryColumns(): array { return [ - 'objects_problem_handled' => new Expression( - 'SUM(CASE WHEN redundancy_group_from_to_host_state.soft_state = 1' - . ' AND (redundancy_group_from_to_host_state.is_handled = \'y\'' - . ' OR redundancy_group_from_to_host_state.is_reachable = \'n\') THEN 1 ELSE 0 END' - . ' + CASE WHEN redundancy_group_from_to_service_state.soft_state = 2' + 'nodes_problem_handled' => new Expression( + 'SUM(CASE WHEN (redundancy_group_from_to_service.id IS NOT NULL' + . ' AND redundancy_group_from_to_service_state.soft_state = 2' . ' AND (redundancy_group_from_to_service_state.is_handled = \'y\'' - . ' OR redundancy_group_from_to_service_state.is_reachable = \'n\') THEN 1 ELSE 0 END)' + . ' OR redundancy_group_from_to_service_state.is_reachable = \'n\'))' + . ' OR (redundancy_group_from_to_host_state.soft_state = 1' + . ' AND (redundancy_group_from_to_host_state.is_handled = \'y\'' + . ' OR redundancy_group_from_to_host_state.is_reachable = \'n\')) THEN 1 ELSE 0 END)' ), - 'objects_problem_unhandled' => new Expression( - 'SUM(CASE WHEN redundancy_group_from_to_host_state.soft_state = 1' - . ' AND redundancy_group_from_to_host_state.is_handled = \'n\'' - . ' AND redundancy_group_from_to_host_state.is_reachable = \'y\' THEN 1 ELSE 0 END' - . ' + CASE WHEN redundancy_group_from_to_service_state.soft_state = 2' - . ' AND redundancy_group_from_to_service_state.is_handled = \'n\'' - . ' AND redundancy_group_from_to_service_state.is_reachable = \'y\' THEN 1 ELSE 0 END)' + 'nodes_problem_unhandled' => new Expression( + 'SUM(CASE WHEN (redundancy_group_from_to_service.id IS NOT NULL' + . ' AND redundancy_group_from_to_service_state.soft_state = 2' + . ' AND (redundancy_group_from_to_service_state.is_handled = \'n\'' + . ' OR redundancy_group_from_to_service_state.is_reachable = \'y\'))' + . ' OR (redundancy_group_from_to_host_state.soft_state = 1' + . ' AND (redundancy_group_from_to_host_state.is_handled = \'n\'' + . ' OR redundancy_group_from_to_host_state.is_reachable = \'y\')) THEN 1 ELSE 0 END)' ), - 'objects_pending' => new Expression( - 'SUM(CASE WHEN redundancy_group_from_to_host_state.soft_state = 99 THEN 1 ELSE 0 END' - . ' + CASE WHEN redundancy_group_from_to_service_state.soft_state = 99 THEN 1 ELSE 0 END)' + 'nodes_pending' => new Expression( + 'SUM(CASE WHEN (redundancy_group_from_to_service.id IS NOT NULL' + . ' AND redundancy_group_from_to_service_state.soft_state = 99)' + . ' OR redundancy_group_from_to_host_state.soft_state = 99 THEN 1 ELSE 0 END)' ), - 'objects_total' => new Expression( - 'SUM(CASE WHEN redundancy_group_from_to_host.id IS NOT NULL THEN 1 ELSE 0 END)' - . '+ SUM(CASE WHEN redundancy_group_from_to_service.id IS NOT NULL THEN 1 ELSE 0 END)' + 'nodes_total' => new Expression( + 'SUM(CASE WHEN redundancy_group_from_to_host.id IS NOT NULL' + . ' OR (redundancy_group_from_to_host.id IS NULL' + . ' AND redundancy_group_from_to_service.id) IS NOT NULL THEN 1 ELSE 0 END)' ), - 'objects_ok' => new Expression( - 'SUM(CASE WHEN redundancy_group_from_to_host_state.soft_state = 0 THEN 1 ELSE 0 END' - . ' + CASE WHEN redundancy_group_from_to_service_state.soft_state = 0 THEN 1 ELSE 0 END)' + 'nodes_ok' => new Expression( + 'SUM(CASE WHEN (redundancy_group_from_to_service.id IS NOT NULL' + . ' AND redundancy_group_from_to_service_state.soft_state = 0)' + . ' OR redundancy_group_from_to_service_state.soft_state = 0 THEN 1 ELSE 0 END)' ), - 'objects_unknown_handled' => new Expression( + 'nodes_unknown_handled' => new Expression( 'SUM(CASE WHEN redundancy_group_from_to_service_state.soft_state = 3' . ' AND (redundancy_group_from_to_service_state.is_handled = \'y\'' . ' OR redundancy_group_from_to_service_state.is_reachable = \'n\') THEN 1 ELSE 0 END)' ), - 'objects_unknown_unhandled' => new Expression( + 'nodes_unknown_unhandled' => new Expression( 'SUM(CASE WHEN redundancy_group_from_to_service_state.soft_state = 3' . ' AND redundancy_group_from_to_service_state.is_handled = \'n\'' . ' AND redundancy_group_from_to_service_state.is_reachable = \'y\' THEN 1 ELSE 0 END)' ), - 'objects_warning_handled' => new Expression( + 'nodes_warning_handled' => new Expression( 'SUM(CASE WHEN redundancy_group_from_to_service_state.soft_state = 1' . ' AND (redundancy_group_from_to_service_state.is_handled = \'y\'' . ' OR redundancy_group_from_to_service_state.is_reachable = \'n\') THEN 1 ELSE 0 END)' ), - 'objects_warning_unhandled' => new Expression( + 'nodes_warning_unhandled' => new Expression( 'SUM(CASE WHEN redundancy_group_from_to_service_state.soft_state = 1' . ' AND redundancy_group_from_to_service_state.is_handled = \'n\'' . ' AND redundancy_group_from_to_service_state.is_reachable = \'y\' THEN 1 ELSE 0 END)' diff --git a/library/Icingadb/Widget/ObjectsStateBadges.php b/library/Icingadb/Widget/DependencyNodeStateBadges.php similarity index 78% rename from library/Icingadb/Widget/ObjectsStateBadges.php rename to library/Icingadb/Widget/DependencyNodeStateBadges.php index 0a751ad4b..40c5ce5d6 100644 --- a/library/Icingadb/Widget/ObjectsStateBadges.php +++ b/library/Icingadb/Widget/DependencyNodeStateBadges.php @@ -9,21 +9,21 @@ /** * State badges for the objects */ -class ObjectsStateBadges extends StateBadges +class DependencyNodeStateBadges extends StateBadges { protected function getType(): string { - return 'objects'; + return 'nodes'; } protected function getPrefix(): string { - return 'objects'; + return 'nodes'; } protected function assemble(): void { - $this->addAttributes(['class' => 'objects-state-badges']); + $this->addAttributes(['class' => 'nodes-state-badges']); $this->add(array_filter([ $this->createGroup('problem'), diff --git a/library/Icingadb/Widget/DependencyNodeStatistics.php b/library/Icingadb/Widget/DependencyNodeStatistics.php new file mode 100644 index 000000000..ffc4403c2 --- /dev/null +++ b/library/Icingadb/Widget/DependencyNodeStatistics.php @@ -0,0 +1,51 @@ +summary = $summary; + } + + protected function createDonut(): ValidHtml + { + $donut = (new Donut()) + ->addSlice($this->summary->nodes_ok, ['class' => 'slice-state-ok']) + ->addSlice($this->summary->nodes_warning_handled, ['class' => 'slice-state-warning-handled']) + ->addSlice($this->summary->nodes_warning_unhandled, ['class' => 'slice-state-warning']) + ->addSlice($this->summary->nodes_problem_handled, ['class' => 'slice-state-critical-handled']) + ->addSlice($this->summary->nodes_problem_unhandled, ['class' => 'slice-state-critical']) + ->addSlice($this->summary->nodes_unknown_handled, ['class' => 'slice-state-unknown-handled']) + ->addSlice($this->summary->nodes_unknown_unhandled, ['class' => 'slice-state-unknown']) + ->addSlice($this->summary->nodes_pending, ['class' => 'slice-state-pending']); + + return HtmlString::create($donut->render()); + } + + protected function createTotal(): ValidHtml + { + return Text::create($this->shortenAmount($this->summary->nodes_total)); + } + + protected function createBadges(): ValidHtml + { + return new DependencyNodeStateBadges($this->summary); + } +} diff --git a/library/Icingadb/Widget/Detail/ObjectDetail.php b/library/Icingadb/Widget/Detail/ObjectDetail.php index 505fdb054..d893fb795 100644 --- a/library/Icingadb/Widget/Detail/ObjectDetail.php +++ b/library/Icingadb/Widget/Detail/ObjectDetail.php @@ -444,7 +444,7 @@ protected function createPluginOutput(): array 'div', [ 'id' => 'check-output-' . $this->object->checkcommand_name, - 'class' => ['collapsible', 'check-command-output'], + 'class' => 'collapsible', 'data-visible-height' => 100 ], $pluginOutput diff --git a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php index cf162f24a..8b1b0237f 100644 --- a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php +++ b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php @@ -8,12 +8,13 @@ use Icinga\Module\Icingadb\Common\Database; use Icinga\Module\Icingadb\Common\ListItemCommonLayout; use Icinga\Module\Icingadb\Model\RedundancyGroup; -use Icinga\Module\Icingadb\Model\RedundancyGroupParentStateSummary; +use Icinga\Module\Icingadb\Model\DependencyNodeSummary; use Icinga\Module\Icingadb\Model\RedundancyGroupState; use Icinga\Module\Icingadb\Util\PluginOutput; use Icinga\Module\Icingadb\Widget\PluginOutputContainer; -use Icinga\Module\Icingadb\Widget\ObjectsStatistics; +use Icinga\Module\Icingadb\Widget\DependencyNodeStatistics; use ipl\Html\BaseHtmlElement; +use ipl\I18n\Translation; use ipl\Sql\Expression; use ipl\Stdlib\Filter; use ipl\Web\Widget\StateBall; @@ -32,10 +33,11 @@ class RedundancyGroupListItem extends StateListItem use ListItemCommonLayout; use Auth; use Database; + use Translation; protected $baseAttributes = ['class' => ['list-item', 'redundancy-group-list-item']]; - /** @var RedundancyGroupParentStateSummary Objects state summary */ + /** @var DependencyNodeSummary Objects state summary */ protected $summary; /** @var RedundancyGroupState */ @@ -48,22 +50,15 @@ protected function init(): void { parent::init(); - $this->summary = RedundancyGroupParentStateSummary::on($this->getDb()) - ->with([ - 'from', - 'from.to.host', - 'from.to.host.state', - 'from.to.service', - 'from.to.service.state' - ]) + $this->summary = DependencyNodeSummary::on($this->getDb()) ->filter(Filter::equal('id', $this->item->id)) ->first(); $this->isHandled = $this->state->failed && ( - $this->summary->objects_problem_handled - || $this->summary->objects_unknown_handled - || $this->summary->objects_warning_handled + $this->summary->nodes_problem_handled + || $this->summary->nodes_unknown_handled + || $this->summary->nodes_warning_handled ); } @@ -101,28 +96,28 @@ protected function assembleCaption(BaseHtmlElement $caption): void $members = RedundancyGroup::on($this->getDb()) ->columns([ 'id' => 'id', - 'objects_output' => new Expression( - 'CASE WHEN redundancy_group_from_to_host_state.output IS NULL' + 'nodes_output' => new Expression( + 'CASE WHEN redundancy_group_from_to_host.id IS NULL' . ' THEN redundancy_group_from_to_service_state.output' . ' ELSE redundancy_group_from_to_host_state.output END' ), - 'objects_long_output' => new Expression( - 'CASE WHEN redundancy_group_from_to_host_state.long_output IS NULL' + 'nodes_long_output' => new Expression( + 'CASE WHEN redundancy_group_from_to_host.id IS NULL' . ' THEN redundancy_group_from_to_service_state.long_output' . ' ELSE redundancy_group_from_to_host_state.long_output END' ), - 'objects_checkcommand_name' => new Expression( - 'CASE WHEN redundancy_group_from_to_host.checkcommand_name IS NULL' + 'nodes_checkcommand_name' => new Expression( + 'CASE WHEN redundancy_group_from_to_host.id IS NULL' . ' THEN redundancy_group_from_to_service.checkcommand_name' . ' ELSE redundancy_group_from_to_host.checkcommand_name END' ), - 'objects_last_state_change' => new Expression( - 'CASE WHEN redundancy_group_from_to_host_state.last_state_change IS NULL' + 'nodes_last_state_change' => new Expression( + 'CASE WHEN redundancy_group_from_to_host.id IS NULL' . ' THEN redundancy_group_from_to_service_state.last_state_change' . ' ELSE redundancy_group_from_to_host_state.last_state_change END' ), - 'objects_severity' => new Expression( - 'CASE WHEN redundancy_group_from_to_host_state.severity IS NULL' + 'nodes_severity' => new Expression( + 'CASE WHEN redundancy_group_from_to_host.id IS NULL' . ' THEN redundancy_group_from_to_service_state.severity' . ' ELSE redundancy_group_from_to_host_state.severity END' ) @@ -136,8 +131,8 @@ protected function assembleCaption(BaseHtmlElement $caption): void ]) ->filter(Filter::equal('id', $this->item->id)) ->orderBy([ - 'objects_severity', - 'objects_last_state_change', + 'nodes_severity', + 'nodes_last_state_change', ], SORT_DESC); $this->applyRestrictions($members); @@ -147,21 +142,25 @@ protected function assembleCaption(BaseHtmlElement $caption): void if ($data) { $caption->addHtml(new PluginOutputContainer( - (new PluginOutput($data->objects_output . "\n" . $data->objects_long_output)) - ->setCommandName($data->objects_checkcommand_name) + (new PluginOutput($data->nodes_output . "\n" . $data->nodes_long_output)) + ->setCommandName($data->nodes_checkcommand_name) )); } - $caption->addHtml(new ObjectsStatistics($this->summary)); + $caption->addHtml(new DependencyNodeStatistics($this->summary)); } protected function assembleTitle(BaseHtmlElement $title): void { $title->addHtml($this->createSubject()); if ($this->state->failed) { - $title->addHtml(HtmlElement::create('span', null, Text::create(t('has no working objects')))); + $title->addHtml(HtmlElement::create( + 'span', + null, + Text::create($this->translate('has no working objects')) + )); } else { - $title->addHtml(HtmlElement::create('span', null, Text::create(t('has working objects')))); + $title->addHtml(HtmlElement::create('span', null, Text::create($this->translate('has working objects')))); } } diff --git a/library/Icingadb/Widget/ObjectsStatistics.php b/library/Icingadb/Widget/ObjectsStatistics.php deleted file mode 100644 index d32eb4b4b..000000000 --- a/library/Icingadb/Widget/ObjectsStatistics.php +++ /dev/null @@ -1,56 +0,0 @@ -summary = $summary; - } - - protected function createDonut(): ValidHtml - { - $donut = (new Donut()) - ->addSlice($this->summary->objects_ok, ['class' => 'slice-state-ok']) - ->addSlice($this->summary->objects_warning_handled, ['class' => 'slice-state-warning-handled']) - ->addSlice($this->summary->objects_warning_unhandled, ['class' => 'slice-state-warning']) - ->addSlice($this->summary->objects_problem_handled, ['class' => 'slice-state-critical-handled']) - ->addSlice($this->summary->objects_problem_unhandled, ['class' => 'slice-state-critical']) - ->addSlice($this->summary->objects_unknown_handled, ['class' => 'slice-state-unknown-handled']) - ->addSlice($this->summary->objects_unknown_unhandled, ['class' => 'slice-state-unknown']) - ->addSlice($this->summary->objects_pending, ['class' => 'slice-state-pending']); - - return HtmlString::create($donut->render()); - } - - protected function createTotal(): ValidHtml - { - return Text::create($this->shortenAmount($this->summary->objects_total)); - } - - protected function createBadges(): ValidHtml - { - $badges = new ObjectsStateBadges($this->summary); - if ($this->hasBaseFilter()) { - $badges->setBaseFilter($this->getBaseFilter()); - } - - return $badges; - } -} diff --git a/public/css/common.less b/public/css/common.less index a32600562..b7616f017 100644 --- a/public/css/common.less +++ b/public/css/common.less @@ -197,7 +197,7 @@ div.show-more { margin-left: 1em / 1.333em; // 1em / h2 font size } -.object-detail .check-command-output .plugin-output { +.object-detail :not(.caption) > .plugin-output { .rounded-corners(.25em); background-color: @gray-lighter; padding: .5em; diff --git a/public/css/list/redundancy-group-list-item.less b/public/css/list/redundancy-group-list-item.less index 431b44717..d3b1f32f2 100644 --- a/public/css/list/redundancy-group-list-item.less +++ b/public/css/list/redundancy-group-list-item.less @@ -1,11 +1,11 @@ -.redundancy-group-list-item.list-item { +.redundancy-group-list-item { .caption { display: flex; + min-width: 0; justify-content: space-between; .plugin-output { - vertical-align: middle; - .text-ellipsis(); + .line-clamp(2); } .object-statistics { diff --git a/public/css/widget/nodes-state-badges.less b/public/css/widget/nodes-state-badges.less new file mode 100644 index 000000000..4a0e16202 --- /dev/null +++ b/public/css/widget/nodes-state-badges.less @@ -0,0 +1,3 @@ +.nodes-state-badges { + .state-badges(); +} diff --git a/public/css/widget/objects-state-badges.less b/public/css/widget/objects-state-badges.less deleted file mode 100644 index ad369c66a..000000000 --- a/public/css/widget/objects-state-badges.less +++ /dev/null @@ -1,3 +0,0 @@ -.objects-state-badges { - .state-badges(); -}