Do not display hosts without any services in the servicematrix

refs #4180
This commit is contained in:
Johannes Meyer 2014-03-12 16:48:24 +01:00
parent 5dc7d0dd56
commit 13b509bf4b
2 changed files with 9 additions and 19 deletions

View File

@ -4,7 +4,6 @@
namespace Icinga\Data; namespace Icinga\Data;
use \stdClass;
use Icinga\Data\BaseQuery; use Icinga\Data\BaseQuery;
class PivotTable class PivotTable
@ -142,26 +141,17 @@ class PivotTable
$yAxis = $this->fetchYAxis(); $yAxis = $this->fetchYAxis();
$this->query->where($this->xAxisColumn, $xAxis)->where($this->yAxisColumn, $yAxis); $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(); $pivot = array();
foreach ($xAxis as $x) { foreach ($this->query->fetchAll() as $row) {
foreach ($yAxis as $y) { if (!array_key_exists($row->{$this->yAxisColumn}, $pivot)) {
$row = clone($emptyrow); $defaults = array();
$row->{$this->xAxisColumn} = $x; foreach ($xAxis as $label) {
$row->{$this->yAxisColumn} = $y; $defaults[$label] = null;
$pivot[$y][$x] = $row;
} }
$pivot[$row->{$this->yAxisColumn}] = $defaults;
} }
foreach ($this->query->fetchAll() as $row) {
$pivot[$row->{$this->yAxisColumn}][$row->{$this->xAxisColumn}] = $row; $pivot[$row->{$this->yAxisColumn}][$row->{$this->xAxisColumn}] = $row;
} }

View File

@ -29,7 +29,7 @@
</a> </a>
</th> </th>
<?php foreach (array_values($serviceStates) as $service): ?> <?php foreach (array_values($serviceStates) as $service): ?>
<?php if ($service->service_state !== null): ?> <?php if ($service !== null): ?>
<td class="state_<?= $this->monitoringState($service, 'service'); ?> <?= $service->service_handled ? 'handled' : ''; ?>"> <td class="state_<?= $this->monitoringState($service, 'service'); ?> <?= $service->service_handled ? 'handled' : ''; ?>">
<a href="<?= $this->href( <a href="<?= $this->href(
'monitoring/show/service', 'monitoring/show/service',