ServicesetController: Add hosts view to serviceSets
So you can see and access hosts the serviceset is added to. refs #12891
This commit is contained in:
parent
ae70de9755
commit
cc34de9b4d
|
@ -24,6 +24,11 @@ class ServicesetController extends ObjectController
|
|||
'urlParams' => array('name' => $this->object->object_name),
|
||||
'label' => 'Services'
|
||||
));
|
||||
$tabs->add('hosts', array(
|
||||
'url' => 'director/serviceset/hosts',
|
||||
'urlParams' => array('name' => $this->object->object_name),
|
||||
'label' => 'Hosts'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,6 +79,26 @@ class ServicesetController extends ObjectController
|
|||
$this->setViewScript('objects/table');
|
||||
}
|
||||
|
||||
public function hostsAction()
|
||||
{
|
||||
$db = $this->db();
|
||||
$set = $this->object;
|
||||
|
||||
$this->view->stayHere = true;
|
||||
|
||||
$this->getTabs()->activate('hosts');
|
||||
$this->view->title = sprintf(
|
||||
$this->translate('Hosts using this set: %s'),
|
||||
$set->object_name
|
||||
);
|
||||
|
||||
$this->view->table = $table = $this->loadTable('IcingaServiceSetHost')
|
||||
->setServiceSet($set)
|
||||
->setConnection($db);
|
||||
|
||||
$this->setViewScript('objects/table');
|
||||
}
|
||||
|
||||
protected function loadObject()
|
||||
{
|
||||
if ($this->object === null) {
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Objects\IcingaServiceSet;
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
|
||||
class IcingaServiceSetHostTable extends QuickTable
|
||||
{
|
||||
protected $set;
|
||||
|
||||
protected $searchColumns = array(
|
||||
'host',
|
||||
);
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'id' => 'h.id',
|
||||
'host' => 'h.object_name',
|
||||
'object_type' => 'h.object_type',
|
||||
);
|
||||
}
|
||||
|
||||
public function setServiceSet(IcingaServiceSet $set)
|
||||
{
|
||||
$this->set = $set;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
$params = array(
|
||||
'name' => $row->host
|
||||
);
|
||||
|
||||
return $this->url('director/host/services', $params);
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$view = $this->view();
|
||||
return array(
|
||||
'host' => $view->translate('Hostname'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getUnfilteredQuery()
|
||||
{
|
||||
return $this->db()->select()->from(
|
||||
array('h' => 'icinga_host'),
|
||||
array()
|
||||
)->joinLeft(
|
||||
array('ssh' => 'icinga_service_set'),
|
||||
'ssh.host_id = h.id',
|
||||
array()
|
||||
)->joinLeft(
|
||||
array('ssih' => 'icinga_service_set_inheritance'),
|
||||
'ssih.service_set_id = ssh.id',
|
||||
array()
|
||||
)->order('h.object_name');
|
||||
}
|
||||
|
||||
public function getBaseQuery()
|
||||
{
|
||||
return $this->getUnfilteredQuery()->where(
|
||||
'ssih.parent_service_set_id = ?',
|
||||
$this->set->id
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue