diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index 997b46da..bc6368af 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -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; } diff --git a/application/tables/IcingaHostServiceSetTable.php b/application/tables/IcingaHostServiceSetTable.php new file mode 100644 index 00000000..60197096 --- /dev/null +++ b/application/tables/IcingaHostServiceSetTable.php @@ -0,0 +1,79 @@ + '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(); + } +}