mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 09:14:09 +02:00
IcingaServiceForm: allow to define apply rules...
...based on templates. fixes #1359
This commit is contained in:
parent
193c575e3a
commit
2045f98016
@ -234,7 +234,11 @@ class SuggestController extends ActionController
|
|||||||
|
|
||||||
protected function getFilterColumns($prefix, $keys)
|
protected function getFilterColumns($prefix, $keys)
|
||||||
{
|
{
|
||||||
$all = IcingaService::enumProperties($this->db(), $prefix);
|
if ($prefix === 'host.') {
|
||||||
|
$all = IcingaHost::enumProperties($this->db(), $prefix);
|
||||||
|
} else {
|
||||||
|
$all = IcingaService::enumProperties($this->db(), $prefix);
|
||||||
|
}
|
||||||
$res = [];
|
$res = [];
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
if (array_key_exists($key, $all)) {
|
if (array_key_exists($key, $all)) {
|
||||||
|
@ -406,14 +406,14 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||||||
|
|
||||||
protected function addAssignmentElements()
|
protected function addAssignmentElements()
|
||||||
{
|
{
|
||||||
$this->addAssignFilter(array(
|
$this->addAssignFilter([
|
||||||
'columns' => IcingaHost::enumProperties($this->db, 'host.'),
|
'suggestionContext' => 'HostFilterColumns',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'This allows you to configure an assignment filter. Please feel'
|
'This allows you to configure an assignment filter. Please feel'
|
||||||
. ' free to combine as many nested operators as you want'
|
. ' free to combine as many nested operators as you want'
|
||||||
)
|
)
|
||||||
));
|
]);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ class IcingaHost extends IcingaObject
|
|||||||
if ($filter === null) {
|
if ($filter === null) {
|
||||||
$filter = new PropertiesFilter();
|
$filter = new PropertiesFilter();
|
||||||
}
|
}
|
||||||
$realProperties = static::create()->listProperties();
|
$realProperties = array_merge(['templates'], static::create()->listProperties());
|
||||||
sort($realProperties);
|
sort($realProperties);
|
||||||
|
|
||||||
if ($filter->match(PropertiesFilter::$HOST_PROPERTY, 'name')) {
|
if ($filter->match(PropertiesFilter::$HOST_PROPERTY, 'name')) {
|
||||||
|
@ -206,6 +206,10 @@ abstract class ObjectApplyMatches
|
|||||||
{
|
{
|
||||||
$this->object = $object;
|
$this->object = $object;
|
||||||
$this->flatObject = $object->toPlainObject(true, false);
|
$this->flatObject = $object->toPlainObject(true, false);
|
||||||
|
// Sure, we are flat - but we might still want to match templates.
|
||||||
|
// TODO: Flatten the whole tree
|
||||||
|
unset($this->flatObject->imports);
|
||||||
|
$this->flatObject->templates = $object->imports()->listImportNames();
|
||||||
static::flattenVars($this->flatObject);
|
static::flattenVars($this->flatObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user