IcingaServiceSetServiceTable: add host support

This commit is contained in:
Thomas Gelf 2017-01-13 16:24:21 +01:00
parent 457fee77a4
commit 8dabfef378

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Tables; namespace Icinga\Module\Director\Tables;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Objects\IcingaServiceSet; use Icinga\Module\Director\Objects\IcingaServiceSet;
use Icinga\Module\Director\Web\Table\QuickTable; use Icinga\Module\Director\Web\Table\QuickTable;
@ -9,6 +10,11 @@ class IcingaServiceSetServiceTable extends QuickTable
{ {
protected $set; protected $set;
protected $title;
/** @var IcingaHost */
protected $host;
protected $searchColumns = array( protected $searchColumns = array(
'service', 'service',
); );
@ -18,33 +24,58 @@ class IcingaServiceSetServiceTable extends QuickTable
return array( return array(
'id' => 's.id', 'id' => 's.id',
'service_set_id' => 's.service_set_id', 'service_set_id' => 's.service_set_id',
'host_id' => 'ss.host_id',
'service_set' => 'ss.object_name', 'service_set' => 'ss.object_name',
'service' => 's.object_name', 'service' => 's.object_name',
'object_type' => 's.object_type', 'object_type' => 's.object_type',
); );
} }
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function setHost(IcingaHost $host)
{
$this->host = $host;
return $this;
}
public function setServiceSet(IcingaServiceSet $set) public function setServiceSet(IcingaServiceSet $set)
{ {
$this->set = $set; $this->set = $set;
$this->setId = $set->get('id');
return $this; return $this;
} }
protected function getActionUrl($row) protected function getActionUrl($row)
{ {
$params = array( if ($this->host) {
'name' => $row->service, $params = array(
'set' => $row->service_set 'name' => $this->host->getObjectName(),
); 'service' => $row->service,
'set' => $row->service_set
return $this->url('director/service', $params); );
return $this->url('director/host/servicesetservice', $params);
} else {
$params = array(
'name' => $row->service,
'set' => $row->service_set
);
return $this->url('director/service', $params);
}
} }
public function getTitles() public function getTitles()
{ {
$view = $this->view(); $view = $this->view();
return array( return array(
'service' => $view->translate('Servicename'), 'service' => $this->title ?: $view->translate('Servicename'),
); );
} }