parent
d8f02c8974
commit
348cb1aa63
|
@ -75,16 +75,28 @@ class IcingaCommandArgumentForm extends DirectorObjectForm
|
|||
'description' => $this->translate(
|
||||
'Whether the set_if parameter is a string (allowing macros like $host$)'
|
||||
. ' or an Icinga DSL lambda function (will be enclosed with {{ ... }}'
|
||||
)
|
||||
),
|
||||
'class' => 'autosubmit',
|
||||
));
|
||||
|
||||
$this->addElement('text', 'set_if', array(
|
||||
'label' => $this->translate('Condition (set_if)'),
|
||||
'description' => $this->translate(
|
||||
'Only set this parameter if the argument value resolves to a'
|
||||
. ' numeric value. String values are not supported'
|
||||
)
|
||||
));
|
||||
if ($this->getSentOrObjectValue('set_if_format') === 'expression') {
|
||||
$this->addElement('textarea', 'set_if', array(
|
||||
'label' => $this->translate('Condition (set_if)'),
|
||||
'description' => $this->translate(
|
||||
'An Icinga DSL expression that returns a boolean value, e.g.: var cmd = bool(macro("$cmd$"));'
|
||||
. ' return cmd ...'
|
||||
),
|
||||
'rows' => 3
|
||||
));
|
||||
} else {
|
||||
$this->addElement('text', 'set_if', array(
|
||||
'label' => $this->translate('Condition (set_if)'),
|
||||
'description' => $this->translate(
|
||||
'Only set this parameter if the argument value resolves to a'
|
||||
. ' numeric value. String values are not supported'
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
$this->addBoolean('repeat_key', array(
|
||||
'label' => $this->translate('Repeat key'),
|
||||
|
|
|
@ -124,6 +124,7 @@ class IcingaCommandArgument extends IcingaObject
|
|||
$data['argument_name'] = $this->argument_name;
|
||||
$data['argument_value'] = $this->argument_value;
|
||||
$data['argument_format'] = $this->argument_format;
|
||||
$data['set_if_format'] = $this->set_if_format;
|
||||
return (object) $data;
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +162,14 @@ class IcingaCommandArgument extends IcingaObject
|
|||
}
|
||||
|
||||
if ($this->set_if) {
|
||||
$data['set_if'] = c::renderString($this->set_if);
|
||||
switch ($this->set_if_format) {
|
||||
case 'string':
|
||||
$data['set_if'] = c::renderString($this->set_if);
|
||||
break;
|
||||
case 'expression':
|
||||
$data['set_if'] = c::renderExpression($this->set_if);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->required) {
|
||||
|
|
Loading…
Reference in New Issue