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)
|
||||
{
|
||||
$all = IcingaService::enumProperties($this->db(), $prefix);
|
||||
if ($prefix === 'host.') {
|
||||
$all = IcingaHost::enumProperties($this->db(), $prefix);
|
||||
} else {
|
||||
$all = IcingaService::enumProperties($this->db(), $prefix);
|
||||
}
|
||||
$res = [];
|
||||
foreach ($keys as $key) {
|
||||
if (array_key_exists($key, $all)) {
|
||||
|
|
|
@ -406,14 +406,14 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||
|
||||
protected function addAssignmentElements()
|
||||
{
|
||||
$this->addAssignFilter(array(
|
||||
'columns' => IcingaHost::enumProperties($this->db, 'host.'),
|
||||
$this->addAssignFilter([
|
||||
'suggestionContext' => 'HostFilterColumns',
|
||||
'required' => true,
|
||||
'description' => $this->translate(
|
||||
'This allows you to configure an assignment filter. Please feel'
|
||||
. ' free to combine as many nested operators as you want'
|
||||
)
|
||||
));
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ class IcingaHost extends IcingaObject
|
|||
if ($filter === null) {
|
||||
$filter = new PropertiesFilter();
|
||||
}
|
||||
$realProperties = static::create()->listProperties();
|
||||
$realProperties = array_merge(['templates'], static::create()->listProperties());
|
||||
sort($realProperties);
|
||||
|
||||
if ($filter->match(PropertiesFilter::$HOST_PROPERTY, 'name')) {
|
||||
|
|
|
@ -206,6 +206,10 @@ abstract class ObjectApplyMatches
|
|||
{
|
||||
$this->object = $object;
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue