From 717b5c65f27d9992d4e2f3a542e923d043f6d9ea Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 5 Jul 2023 10:36:11 +0200 Subject: [PATCH] tactical: Properly process base filter on state badges fixes #795 --- library/Icingadb/Widget/HostSummaryDonut.php | 13 ++++++++++--- library/Icingadb/Widget/ServiceSummaryDonut.php | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/library/Icingadb/Widget/HostSummaryDonut.php b/library/Icingadb/Widget/HostSummaryDonut.php index cab374af1..7a677700b 100644 --- a/library/Icingadb/Widget/HostSummaryDonut.php +++ b/library/Icingadb/Widget/HostSummaryDonut.php @@ -14,6 +14,7 @@ use ipl\Html\TemplateString; use ipl\Html\Text; use ipl\Stdlib\BaseFilter; +use ipl\Stdlib\Filter; use ipl\Web\Common\Card; use ipl\Web\Filter\QueryString; @@ -33,6 +34,14 @@ public function __construct(HoststateSummary $summary) protected function assembleBody(BaseHtmlElement $body) { + $labelBigUrlFilter = Filter::all( + Filter::equal('host.state.soft_state', 1), + Filter::equal('host.state.is_handled', 'n') + ); + if ($this->hasBaseFilter()) { + $labelBigUrlFilter->add($this->getBaseFilter()); + } + $donut = (new Donut()) ->addSlice($this->summary->hosts_up, ['class' => 'slice-state-ok']) ->addSlice($this->summary->hosts_down_handled, ['class' => 'slice-state-critical-handled']) @@ -41,9 +50,7 @@ protected function assembleBody(BaseHtmlElement $body) ->addSlice($this->summary->hosts_unreachable_unhandled, ['class' => 'slice-state-unreachable']) ->addSlice($this->summary->hosts_pending, ['class' => 'slice-state-pending']) ->setLabelBig($this->summary->hosts_down_unhandled) - ->setLabelBigUrl(Links::hosts()->setQueryString(QueryString::render($this->getBaseFilter()))->addParams([ - 'host.state.soft_state' => 1, - 'host.state.is_handled' => 'n', + ->setLabelBigUrl(Links::hosts()->setQueryString(QueryString::render($labelBigUrlFilter))->addParams([ 'sort' => 'host.state.last_state_change' ])) ->setLabelBigEyeCatching($this->summary->hosts_down_unhandled > 0) diff --git a/library/Icingadb/Widget/ServiceSummaryDonut.php b/library/Icingadb/Widget/ServiceSummaryDonut.php index 98566ca6e..71eb78107 100644 --- a/library/Icingadb/Widget/ServiceSummaryDonut.php +++ b/library/Icingadb/Widget/ServiceSummaryDonut.php @@ -14,6 +14,7 @@ use ipl\Html\TemplateString; use ipl\Html\Text; use ipl\Stdlib\BaseFilter; +use ipl\Stdlib\Filter; use ipl\Web\Common\Card; use ipl\Web\Filter\QueryString; @@ -33,6 +34,14 @@ public function __construct(ServicestateSummary $summary) protected function assembleBody(BaseHtmlElement $body) { + $labelBigUrlFilter = Filter::all( + Filter::equal('service.state.soft_state', 2), + Filter::equal('service.state.is_handled', 'n') + ); + if ($this->hasBaseFilter()) { + $labelBigUrlFilter->add($this->getBaseFilter()); + } + $donut = (new Donut()) ->addSlice($this->summary->services_ok, ['class' => 'slice-state-ok']) ->addSlice($this->summary->services_warning_handled, ['class' => 'slice-state-warning-handled']) @@ -43,9 +52,7 @@ protected function assembleBody(BaseHtmlElement $body) ->addSlice($this->summary->services_unknown_unhandled, ['class' => 'slice-state-unknown']) ->addSlice($this->summary->services_pending, ['class' => 'slice-state-pending']) ->setLabelBig($this->summary->services_critical_unhandled) - ->setLabelBigUrl(Links::services()->setQueryString(QueryString::render($this->getBaseFilter()))->addParams([ - 'service.state.soft_state' => 2, - 'service.state.is_handled' => 'n', + ->setLabelBigUrl(Links::services()->setQueryString(QueryString::render($labelBigUrlFilter))->addParams([ 'sort' => 'service.state.last_state_change' ])) ->setLabelBigEyeCatching($this->summary->services_critical_unhandled > 0)