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);
|
$this->addHostServiceSetTables($host, $tables);
|
||||||
foreach ($parents as $parent) {
|
foreach ($parents as $parent) {
|
||||||
$this->addHostServiceSetTables($host, $tables);
|
$this->addHostServiceSetTables($parent, $tables, $host);
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = $this->translate('Applied services');
|
$title = $this->translate('Applied services');
|
||||||
@ -149,9 +149,12 @@ class HostController extends ObjectController
|
|||||||
$this->view->tables = $tables;
|
$this->view->tables = $tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addHostServiceSetTables(IcingaHost $host, & $tables)
|
protected function addHostServiceSetTables(IcingaHost $host, & $tables, IcingaHost $affectedHost = null)
|
||||||
{
|
{
|
||||||
$db = $this->db();
|
$db = $this->db();
|
||||||
|
if ($affectedHost === null) {
|
||||||
|
$affectedHost = $host;
|
||||||
|
}
|
||||||
|
|
||||||
$query = $db->getDbAdapter()->select()
|
$query = $db->getDbAdapter()->select()
|
||||||
->from(
|
->from(
|
||||||
@ -168,12 +171,12 @@ class HostController extends ObjectController
|
|||||||
)->where('hs.host_id = ?', $host->id);
|
)->where('hs.host_id = ?', $host->id);
|
||||||
|
|
||||||
$sets = IcingaServiceSet::loadAll($db, $query, 'object_name');
|
$sets = IcingaServiceSet::loadAll($db, $query, 'object_name');
|
||||||
|
|
||||||
foreach ($sets as $name => $set) {
|
foreach ($sets as $name => $set) {
|
||||||
$title = sprintf($this->translate('%s (Service set)'), $name);
|
$title = sprintf($this->translate('%s (Service set)'), $name);
|
||||||
$table = $this->loadTable('IcingaServiceSetService')
|
$table = $this->loadTable('IcingaServiceSetService')
|
||||||
->setServiceSet($set)
|
->setServiceSet($set)
|
||||||
->setHost($host)
|
->setHost($host)
|
||||||
|
->setAffectedHost($affectedHost)
|
||||||
->setTitle($title)
|
->setTitle($title)
|
||||||
->setConnection($db);
|
->setConnection($db);
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ class IcingaServiceSetServiceTable extends QuickTable
|
|||||||
/** @var IcingaHost */
|
/** @var IcingaHost */
|
||||||
protected $host;
|
protected $host;
|
||||||
|
|
||||||
|
protected $affectedHost;
|
||||||
|
|
||||||
protected $searchColumns = array(
|
protected $searchColumns = array(
|
||||||
'service',
|
'service',
|
||||||
);
|
);
|
||||||
@ -43,6 +45,12 @@ class IcingaServiceSetServiceTable extends QuickTable
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setAffectedHost(IcingaHost $host)
|
||||||
|
{
|
||||||
|
$this->affectedHost = $host;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setServiceSet(IcingaServiceSet $set)
|
public function setServiceSet(IcingaServiceSet $set)
|
||||||
{
|
{
|
||||||
$this->set = $set;
|
$this->set = $set;
|
||||||
@ -62,7 +70,7 @@ class IcingaServiceSetServiceTable extends QuickTable
|
|||||||
{
|
{
|
||||||
if ($this->host) {
|
if ($this->host) {
|
||||||
$params = array(
|
$params = array(
|
||||||
'name' => $this->host->getObjectName(),
|
'name' => $this->affectedHost->getObjectName(),
|
||||||
'service' => $row->service,
|
'service' => $row->service,
|
||||||
'set' => $row->service_set
|
'set' => $row->service_set
|
||||||
);
|
);
|
||||||
@ -93,20 +101,38 @@ class IcingaServiceSetServiceTable extends QuickTable
|
|||||||
$title = $view->escape(array_shift($row));
|
$title = $view->escape(array_shift($row));
|
||||||
|
|
||||||
$htm = "<thead>\n <tr>\n";
|
$htm = "<thead>\n <tr>\n";
|
||||||
|
if ($this->affectedHost->id !== $this->host->id) {
|
||||||
$deleteLink = $view->qlink(
|
$deleteLink = $view->qlink(
|
||||||
$view->translate('Remove'),
|
$this->host->getObjectName(),
|
||||||
'director/host/removeset',
|
'director/host/services',
|
||||||
array(
|
array(
|
||||||
'name' => $this->host->getObjectName(),
|
'name' => $this->host->getObjectName(),
|
||||||
'setId' => $this->set->id
|
),
|
||||||
),
|
array(
|
||||||
array(
|
'class' => 'icon-paste',
|
||||||
'class' => 'icon-cancel',
|
'style' => 'float: right; font-weight: normal',
|
||||||
'style' => 'float: right; font-weight: normal',
|
'data-base-target' => '_next',
|
||||||
'title' => $view->translate('Remove this set from this host')
|
'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";
|
$htm .= ' <th>' . $view->escape($title) . "$deleteLink</th>\n";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user