mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 09:14:09 +02:00
HostController: show services for hosts created...
...in a branch
This commit is contained in:
parent
e3cae7c20a
commit
f77d5b8d0c
@ -207,12 +207,7 @@ class HostController extends ObjectController
|
||||
$host = $this->getHostObject();
|
||||
$this->addTitle($this->translate('Services: %s'), $host->getObjectName());
|
||||
$branch = $this->getBranch();
|
||||
if ($branch->isBranch() && $host->get('id') === null) {
|
||||
$this->content()->add(Hint::info(
|
||||
$this->translate('Managing services on new Hosts is possible only after they have been merged.')
|
||||
));
|
||||
return;
|
||||
}
|
||||
$hostHasBeenCreatedInBranch = $branch->isBranch() && $host->get('id');
|
||||
$content = $this->content();
|
||||
$table = (new ObjectsTableService($this->db()))->setAuth($this->Auth())->setHost($host)
|
||||
->setTitle($this->translate('Individual Service objects'));
|
||||
@ -242,7 +237,9 @@ class HostController extends ObjectController
|
||||
}
|
||||
}
|
||||
|
||||
$this->addHostServiceSetTables($host);
|
||||
if (! $hostHasBeenCreatedInBranch) {
|
||||
$this->addHostServiceSetTables($host);
|
||||
}
|
||||
foreach ($parents as $parent) {
|
||||
$this->addHostServiceSetTables($parent, $host);
|
||||
}
|
||||
@ -356,6 +353,9 @@ class HostController extends ObjectController
|
||||
if ($affectedHost === null) {
|
||||
$affectedHost = $host;
|
||||
}
|
||||
if ($host->get('id') === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$query = $db->getDbAdapter()->select()
|
||||
->from(
|
||||
|
@ -179,6 +179,7 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable
|
||||
protected function fetchAllApplyRules()
|
||||
{
|
||||
$db = $this->db;
|
||||
$hostId = $this->host->get('id');
|
||||
$query = $db->select()->from(
|
||||
['s' => 'icinga_service'],
|
||||
[
|
||||
@ -187,14 +188,17 @@ class IcingaHostAppliedServicesTable extends SimpleQueryBasedTable
|
||||
'assign_filter' => 's.assign_filter',
|
||||
'apply_for' => 's.apply_for',
|
||||
'disabled' => 's.disabled',
|
||||
'blacklisted' => "CASE WHEN hsb.service_id IS NULL THEN 'n' ELSE 'y' END",
|
||||
'blacklisted' => $hostId ? "CASE WHEN hsb.service_id IS NULL THEN 'n' ELSE 'y' END" : "('n')",
|
||||
]
|
||||
)->joinLeft(
|
||||
['hsb' => 'icinga_host_service_blacklist'],
|
||||
$db->quoteInto('s.id = hsb.service_id AND hsb.host_id = ?', $this->host->get('id')),
|
||||
[]
|
||||
)->where('object_type = ? AND assign_filter IS NOT NULL', 'apply')
|
||||
->order('s.object_name');
|
||||
if ($hostId) {
|
||||
$query->joinLeft(
|
||||
['hsb' => 'icinga_host_service_blacklist'],
|
||||
$db->quoteInto('s.id = hsb.service_id AND hsb.host_id = ?', $hostId),
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
return $db->fetchAll($query);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user