mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +02:00
IcingaServiceSetServiceTable: support inherited...
...sets. They should be shown and link to the related parent. Variable overrides should be possible, deleting the set should not. fixes #740
This commit is contained in:
parent
13918f7337
commit
ac3ea09133
@ -133,7 +133,7 @@ class HostController extends ObjectController
|
||||
|
||||
$this->addHostServiceSetTables($host, $tables);
|
||||
foreach ($parents as $parent) {
|
||||
$this->addHostServiceSetTables($host, $tables);
|
||||
$this->addHostServiceSetTables($parent, $tables, $host);
|
||||
}
|
||||
|
||||
$title = $this->translate('Applied services');
|
||||
@ -149,9 +149,12 @@ class HostController extends ObjectController
|
||||
$this->view->tables = $tables;
|
||||
}
|
||||
|
||||
protected function addHostServiceSetTables(IcingaHost $host, & $tables)
|
||||
protected function addHostServiceSetTables(IcingaHost $host, & $tables, IcingaHost $affectedHost = null)
|
||||
{
|
||||
$db = $this->db();
|
||||
if ($affectedHost === null) {
|
||||
$affectedHost = $host;
|
||||
}
|
||||
|
||||
$query = $db->getDbAdapter()->select()
|
||||
->from(
|
||||
@ -168,12 +171,12 @@ class HostController extends ObjectController
|
||||
)->where('hs.host_id = ?', $host->id);
|
||||
|
||||
$sets = IcingaServiceSet::loadAll($db, $query, 'object_name');
|
||||
|
||||
foreach ($sets as $name => $set) {
|
||||
$title = sprintf($this->translate('%s (Service set)'), $name);
|
||||
$table = $this->loadTable('IcingaServiceSetService')
|
||||
->setServiceSet($set)
|
||||
->setHost($host)
|
||||
->setAffectedHost($affectedHost)
|
||||
->setTitle($title)
|
||||
->setConnection($db);
|
||||
|
||||
|
@ -15,6 +15,8 @@ class IcingaServiceSetServiceTable extends QuickTable
|
||||
/** @var IcingaHost */
|
||||
protected $host;
|
||||
|
||||
protected $affectedHost;
|
||||
|
||||
protected $searchColumns = array(
|
||||
'service',
|
||||
);
|
||||
@ -43,6 +45,12 @@ class IcingaServiceSetServiceTable extends QuickTable
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAffectedHost(IcingaHost $host)
|
||||
{
|
||||
$this->affectedHost = $host;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setServiceSet(IcingaServiceSet $set)
|
||||
{
|
||||
$this->set = $set;
|
||||
@ -62,7 +70,7 @@ class IcingaServiceSetServiceTable extends QuickTable
|
||||
{
|
||||
if ($this->host) {
|
||||
$params = array(
|
||||
'name' => $this->host->getObjectName(),
|
||||
'name' => $this->affectedHost->getObjectName(),
|
||||
'service' => $row->service,
|
||||
'set' => $row->service_set
|
||||
);
|
||||
@ -93,20 +101,38 @@ class IcingaServiceSetServiceTable extends QuickTable
|
||||
$title = $view->escape(array_shift($row));
|
||||
|
||||
$htm = "<thead>\n <tr>\n";
|
||||
|
||||
$deleteLink = $view->qlink(
|
||||
$view->translate('Remove'),
|
||||
'director/host/removeset',
|
||||
array(
|
||||
'name' => $this->host->getObjectName(),
|
||||
'setId' => $this->set->id
|
||||
),
|
||||
array(
|
||||
'class' => 'icon-cancel',
|
||||
'style' => 'float: right; font-weight: normal',
|
||||
'title' => $view->translate('Remove this set from this host')
|
||||
)
|
||||
);
|
||||
if ($this->affectedHost->id !== $this->host->id) {
|
||||
$deleteLink = $view->qlink(
|
||||
$this->host->getObjectName(),
|
||||
'director/host/services',
|
||||
array(
|
||||
'name' => $this->host->getObjectName(),
|
||||
),
|
||||
array(
|
||||
'class' => 'icon-paste',
|
||||
'style' => 'float: right; font-weight: normal',
|
||||
'data-base-target' => '_next',
|
||||
'title' => sprintf(
|
||||
$view->translate('This set has been inherited from %s'),
|
||||
$this->host->getObjectName()
|
||||
)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$deleteLink = $view->qlink(
|
||||
$view->translate('Remove'),
|
||||
'director/host/removeset',
|
||||
array(
|
||||
'name' => $this->host->getObjectName(),
|
||||
'setId' => $this->set->id
|
||||
),
|
||||
array(
|
||||
'class' => 'icon-cancel',
|
||||
'style' => 'float: right; font-weight: normal',
|
||||
'title' => $view->translate('Remove this set from this host')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$htm .= ' <th>' . $view->escape($title) . "$deleteLink</th>\n";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user