Host: show a related service set list
This commit is contained in:
parent
354d12946a
commit
4929f6b228
|
@ -69,6 +69,11 @@ class HostController extends ObjectController
|
|||
'director/service/add',
|
||||
array('host' => $host->object_name),
|
||||
array('class' => 'icon-plus')
|
||||
) . ' ' . $this->view->qlink(
|
||||
$this->translate('Add service set'),
|
||||
'director/serviceset/add',
|
||||
array('host' => $host->object_name),
|
||||
array('class' => 'icon-plus')
|
||||
);
|
||||
|
||||
$this->getTabs()->activate('services');
|
||||
|
@ -120,6 +125,14 @@ class HostController extends ObjectController
|
|||
$tables[$title] = $table->setTitle($title);
|
||||
}
|
||||
|
||||
$title = $this->translate('Service sets');
|
||||
$table = $this->loadTable('IcingaHostServiceSet')
|
||||
->setHost($host)
|
||||
->setTitle($title)
|
||||
->setConnection($db);
|
||||
|
||||
$tables[$title] = $table;
|
||||
|
||||
$this->view->tables = $tables;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Objects\IcingaHost;
|
||||
use Icinga\Module\Director\Web\Table\IcingaObjectTable;
|
||||
|
||||
class IcingaHostServiceSetTable extends IcingaObjectTable
|
||||
{
|
||||
protected $title;
|
||||
|
||||
protected $host;
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'id' => 'sset.id',
|
||||
'name' => 'sset.object_name',
|
||||
'object_type' => 'sset.object_type',
|
||||
'description' => 'sset.description',
|
||||
'host_name' => 'h.object_name',
|
||||
);
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'name' => $view->translate('Service set'),
|
||||
);
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHost(IcingaHost $host)
|
||||
{
|
||||
$this->host = $host;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
// TODO: Remove once we got a separate apply table
|
||||
if ($row->object_type === 'apply') {
|
||||
$params['id'] = $row->id;
|
||||
} else {
|
||||
$params = array('name' => $row->name);
|
||||
if ($row->host_name) {
|
||||
$params['host'] = $row->host_name;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->url('director/serviceset', $params);
|
||||
}
|
||||
|
||||
protected function getUnfilteredQuery()
|
||||
{
|
||||
$db = $this->connection()->getConnection();
|
||||
$query = $db->select()->from(
|
||||
array('sset' => 'icinga_service_set'),
|
||||
array()
|
||||
)->joinLeft(
|
||||
array('h' => 'icinga_host'),
|
||||
'h.id = sset.host_id',
|
||||
array()
|
||||
)->where('sset.host_id = ?', $this->host->id)->order('sset.object_name');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function getBaseQuery()
|
||||
{
|
||||
return $this->getUnfilteredQuery();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue