From 13b509bf4b9d04b91f3639878b0d0e15fe147b9c Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 12 Mar 2014 16:48:24 +0100 Subject: [PATCH] Do not display hosts without any services in the servicematrix refs #4180 --- library/Icinga/Data/PivotTable.php | 26 ++++++------------- .../views/scripts/list/servicematrix.phtml | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/library/Icinga/Data/PivotTable.php b/library/Icinga/Data/PivotTable.php index 4d102b636..8bd5a777d 100644 --- a/library/Icinga/Data/PivotTable.php +++ b/library/Icinga/Data/PivotTable.php @@ -4,7 +4,6 @@ namespace Icinga\Data; -use \stdClass; use Icinga\Data\BaseQuery; class PivotTable @@ -142,26 +141,17 @@ class PivotTable $yAxis = $this->fetchYAxis(); $this->query->where($this->xAxisColumn, $xAxis)->where($this->yAxisColumn, $yAxis); - if (!$this->query->hasOrder()) { - $this->query->order($this->xAxisColumn)->order($this->yAxisColumn); - } - - $emptyrow = new stdClass(); - foreach ($this->query->getColumns() as $col) { - $emptyrow->{$col} = null; - } $pivot = array(); - foreach ($xAxis as $x) { - foreach ($yAxis as $y) { - $row = clone($emptyrow); - $row->{$this->xAxisColumn} = $x; - $row->{$this->yAxisColumn} = $y; - $pivot[$y][$x] = $row; - } - } - foreach ($this->query->fetchAll() as $row) { + if (!array_key_exists($row->{$this->yAxisColumn}, $pivot)) { + $defaults = array(); + foreach ($xAxis as $label) { + $defaults[$label] = null; + } + $pivot[$row->{$this->yAxisColumn}] = $defaults; + } + $pivot[$row->{$this->yAxisColumn}][$row->{$this->xAxisColumn}] = $row; } diff --git a/modules/monitoring/application/views/scripts/list/servicematrix.phtml b/modules/monitoring/application/views/scripts/list/servicematrix.phtml index 78dec4517..c6dd5c3f0 100644 --- a/modules/monitoring/application/views/scripts/list/servicematrix.phtml +++ b/modules/monitoring/application/views/scripts/list/servicematrix.phtml @@ -29,7 +29,7 @@ -service_state !== null): ?> +