IcingaHostTable: show imports in table

This commit is contained in:
Thomas Gelf 2015-07-28 15:20:39 +02:00
parent 2e0c636574
commit 6b96198235
1 changed files with 31 additions and 3 deletions

View File

@ -7,7 +7,6 @@ use Icinga\Module\Director\Web\Table\QuickTable;
class IcingaHostTable extends QuickTable
{
public function getColumns()
{
return array(
@ -15,6 +14,7 @@ class IcingaHostTable extends QuickTable
'host' => 'h.object_name',
'address' => 'h.address',
'zone' => 'z.object_name',
'parents' => "GROUP_CONCAT(ih.object_name ORDER BY hi.weight SEPARATOR ', ')"
);
}
@ -30,10 +30,11 @@ class IcingaHostTable extends QuickTable
'host' => $view->translate('Hostname'),
'address' => $view->translate('Address'),
'zone' => $view->translate('Zone'),
'parents' => $view->translate('Imports'),
);
}
public function getBaseQuery()
protected function getUnfilteredQuery()
{
$db = $this->connection()->getConnection();
$query = $db->select()->from(
@ -43,8 +44,35 @@ class IcingaHostTable extends QuickTable
array('z' => 'icinga_zone'),
'h.zone_id = z.id',
array()
)->order('h.object_name');
)->joinLeft(
array('hi' => 'icinga_host_inheritance'),
'hi.host_id = h.id',
array()
)->joinLeft(
array('ih' => 'icinga_host'),
'hi.parent_host_id = ih.id',
array()
)->group('h.id')
->order('h.object_name');
return $query;
}
public function count()
{
$db = $this->connection()->getConnection();
$sub = clone($this->getBaseQuery());
$sub->columns($this->getColumns());
$query = $db->select()->from(
array('sub' => $sub),
'COUNT(*)'
);
return $db->fetchOne($query);
}
public function getBaseQuery()
{
return $this->getUnfilteredQuery()->where('h.object_type = ?', 'object');
}
}