Forms: suggest Service properties...
...where applicable. Also, remove some obsolete overhead fixes #1207
This commit is contained in:
parent
fb72a6e293
commit
adb9cc47a4
|
@ -220,7 +220,7 @@ class SuggestController extends ActionController
|
||||||
|
|
||||||
protected function suggestServiceFilterColumns()
|
protected function suggestServiceFilterColumns()
|
||||||
{
|
{
|
||||||
return $this->getFilterColumns('host.', [
|
return $this->getFilterColumns('service.', [
|
||||||
$this->translate('Service properties'),
|
$this->translate('Service properties'),
|
||||||
$this->translate('Host properties'),
|
$this->translate('Host properties'),
|
||||||
$this->translate('Host Custom variables'),
|
$this->translate('Host Custom variables'),
|
||||||
|
|
|
@ -29,7 +29,7 @@ class IcingaDependencyForm extends DirectorObjectForm
|
||||||
->addBooleanElements()
|
->addBooleanElements()
|
||||||
->addPeriodElement()
|
->addPeriodElement()
|
||||||
->addAssignmentElements()
|
->addAssignmentElements()
|
||||||
->addEventFilterElements(array('states'))
|
->addEventFilterElements(['states'])
|
||||||
->groupMainProperties()
|
->groupMainProperties()
|
||||||
->setButtons();
|
->setButtons();
|
||||||
}
|
}
|
||||||
|
@ -67,23 +67,20 @@ class IcingaDependencyForm extends DirectorObjectForm
|
||||||
|
|
||||||
$applyTo = $this->getSentOrObjectValue('apply_to');
|
$applyTo = $this->getSentOrObjectValue('apply_to');
|
||||||
|
|
||||||
if ($applyTo === 'host') {
|
if (! $applyTo) {
|
||||||
$columns = IcingaHost::enumProperties($this->db, 'host.');
|
|
||||||
} elseif ($applyTo === 'service') {
|
|
||||||
// TODO: Also add host properties
|
|
||||||
$columns = IcingaService::enumProperties($this->db, 'service.');
|
|
||||||
} else {
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addAssignFilter(array(
|
$suggestionContext = ucfirst($applyTo) . 'FilterColumns';
|
||||||
'columns' => $columns,
|
$this->addAssignFilter([
|
||||||
|
'suggestionContext' => $suggestionContext,
|
||||||
'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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Forms;
|
namespace Icinga\Module\Director\Forms;
|
||||||
|
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
|
||||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||||
|
|
||||||
class IcingaHostGroupForm extends DirectorObjectForm
|
class IcingaHostGroupForm extends DirectorObjectForm
|
||||||
|
@ -11,11 +10,11 @@ class IcingaHostGroupForm extends DirectorObjectForm
|
||||||
{
|
{
|
||||||
$this->addHidden('object_type', 'object');
|
$this->addHidden('object_type', 'object');
|
||||||
|
|
||||||
$this->addElement('text', 'object_name', array(
|
$this->addElement('text', 'object_name', [
|
||||||
'label' => $this->translate('Hostgroup'),
|
'label' => $this->translate('Hostgroup'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'description' => $this->translate('Icinga object name for this host group')
|
'description' => $this->translate('Icinga object name for this host group')
|
||||||
));
|
]);
|
||||||
|
|
||||||
$this->addGroupDisplayNameElement()
|
$this->addGroupDisplayNameElement()
|
||||||
->addAssignmentElements()
|
->addAssignmentElements()
|
||||||
|
@ -24,14 +23,14 @@ class IcingaHostGroupForm extends DirectorObjectForm
|
||||||
|
|
||||||
protected function addAssignmentElements()
|
protected function addAssignmentElements()
|
||||||
{
|
{
|
||||||
$this->addAssignFilter(array(
|
$this->addAssignFilter([
|
||||||
'columns' => IcingaHost::enumProperties($this->db, 'host.'),
|
'suggestionContext' => 'HostFilterColumns',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,23 +92,20 @@ class IcingaNotificationForm extends DirectorObjectForm
|
||||||
|
|
||||||
$applyTo = $this->getSentOrObjectValue('apply_to');
|
$applyTo = $this->getSentOrObjectValue('apply_to');
|
||||||
|
|
||||||
if ($applyTo === 'host') {
|
if (! $applyTo) {
|
||||||
$columns = IcingaHost::enumProperties($this->db, 'host.');
|
|
||||||
} elseif ($applyTo === 'service') {
|
|
||||||
// TODO: Also add host properties
|
|
||||||
$columns = IcingaService::enumProperties($this->db, 'service.');
|
|
||||||
} else {
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addAssignFilter(array(
|
$suggestionContext = ucfirst($applyTo) . 'FilterColumns';
|
||||||
'columns' => $columns,
|
$this->addAssignFilter([
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'suggestionContext' => $suggestionContext,
|
||||||
'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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Forms;
|
namespace Icinga\Module\Director\Forms;
|
||||||
|
|
||||||
use Icinga\Module\Director\Objects\IcingaService;
|
|
||||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||||
|
|
||||||
class IcingaServiceGroupForm extends DirectorObjectForm
|
class IcingaServiceGroupForm extends DirectorObjectForm
|
||||||
|
@ -11,11 +10,11 @@ class IcingaServiceGroupForm extends DirectorObjectForm
|
||||||
{
|
{
|
||||||
$this->addHidden('object_type', 'object');
|
$this->addHidden('object_type', 'object');
|
||||||
|
|
||||||
$this->addElement('text', 'object_name', array(
|
$this->addElement('text', 'object_name', [
|
||||||
'label' => $this->translate('Servicegroup'),
|
'label' => $this->translate('Servicegroup'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'description' => $this->translate('Icinga object name for this service group')
|
'description' => $this->translate('Icinga object name for this service group')
|
||||||
));
|
]);
|
||||||
|
|
||||||
$this->addGroupDisplayNameElement()
|
$this->addGroupDisplayNameElement()
|
||||||
->addAssignmentElements()
|
->addAssignmentElements()
|
||||||
|
@ -24,14 +23,14 @@ class IcingaServiceGroupForm extends DirectorObjectForm
|
||||||
|
|
||||||
protected function addAssignmentElements()
|
protected function addAssignmentElements()
|
||||||
{
|
{
|
||||||
$this->addAssignFilter(array(
|
$this->addAssignFilter([
|
||||||
'columns' => IcingaService::enumProperties($this->db, 'service.'),
|
'suggestionContext' => 'ServiceFilterColumns',
|
||||||
'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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace Icinga\Module\Director\Forms;
|
namespace Icinga\Module\Director\Forms;
|
||||||
|
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
use Icinga\Module\Director\Objects\IcingaHost;
|
||||||
use Icinga\Module\Director\Objects\IcingaServiceSet;
|
|
||||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||||
|
|
||||||
class IcingaServiceSetForm extends DirectorObjectForm
|
class IcingaServiceSetForm extends DirectorObjectForm
|
||||||
|
@ -111,15 +110,15 @@ class IcingaServiceSetForm extends DirectorObjectForm
|
||||||
|
|
||||||
protected function addAssignmentElements()
|
protected function addAssignmentElements()
|
||||||
{
|
{
|
||||||
$this->addAssignFilter(array(
|
$this->addAssignFilter([
|
||||||
'columns' => IcingaHost::enumProperties($this->db, 'host.'),
|
'suggestionContext' => 'HostFilterColumns',
|
||||||
'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. You'
|
. ' free to combine as many nested operators as you want. You'
|
||||||
. ' might also want to skip this, define it later and/or just'
|
. ' might also want to skip this, define it later and/or just'
|
||||||
. ' add this set of services to single hosts'
|
. ' add this set of services to single hosts'
|
||||||
)
|
)
|
||||||
));
|
]);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
||||||
|
|
||||||
private $query;
|
private $query;
|
||||||
|
|
||||||
|
private $suggestionContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates an 'extensible set' element.
|
* Generates an 'extensible set' element.
|
||||||
*
|
*
|
||||||
|
@ -49,6 +51,11 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
||||||
unset($attribs['columns']);
|
unset($attribs['columns']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('suggestionContext', $attribs)) {
|
||||||
|
$this->setSuggestionContext($attribs['suggestionContext']);
|
||||||
|
unset($attribs['suggestionContext']);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: check for columns in attribs, preserve & remove them from the
|
// TODO: check for columns in attribs, preserve & remove them from the
|
||||||
// array use attribs? class etc? disabled?
|
// array use attribs? class etc? disabled?
|
||||||
// override _getInfo?
|
// override _getInfo?
|
||||||
|
@ -338,6 +345,16 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getSuggestionContext()
|
||||||
|
{
|
||||||
|
return $this->suggestionContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setSuggestionContext($context)
|
||||||
|
{
|
||||||
|
$this->suggestionContext = $context;
|
||||||
|
}
|
||||||
|
|
||||||
protected function selectColumn(FilterExpression $filter = null)
|
protected function selectColumn(FilterExpression $filter = null)
|
||||||
{
|
{
|
||||||
$active = $filter === null ? null : $filter->getColumn();
|
$active = $filter === null ? null : $filter->getColumn();
|
||||||
|
@ -345,24 +362,17 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
||||||
$active = $filter->getExpression();
|
$active = $filter->getExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->hasColumnList()) {
|
if ($context = $this->getSuggestionContext()) {
|
||||||
return $this->view->formText(
|
|
||||||
$this->elementId('column', $filter),
|
|
||||||
$active,
|
|
||||||
array('class' => 'column autosubmit')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return $this->view->formText(
|
return $this->view->formText(
|
||||||
$this->elementId('column', $filter),
|
$this->elementId('column', $filter),
|
||||||
$active,
|
$active,
|
||||||
[
|
[
|
||||||
'class' => 'column autosubmit director-suggest',
|
'class' => 'column autosubmit director-suggest',
|
||||||
'data-suggestion-context' => 'HostFilterColumns',
|
'data-suggestion-context' => $context,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
if ($this->hasColumnList()) {
|
||||||
$cols = $this->getColumnList();
|
$cols = $this->getColumnList();
|
||||||
if ($active && !isset($cols[$active])) {
|
if ($active && !isset($cols[$active])) {
|
||||||
$cols[$active] = str_replace(
|
$cols[$active] = str_replace(
|
||||||
|
@ -378,8 +388,15 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
||||||
$this->elementId('column', $filter),
|
$this->elementId('column', $filter),
|
||||||
$cols,
|
$cols,
|
||||||
$active,
|
$active,
|
||||||
array('class' => 'column autosubmit')
|
['class' => 'column autosubmit']
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
return $this->view->formText(
|
||||||
|
$this->elementId('column', $filter),
|
||||||
|
$active,
|
||||||
|
['class' => 'column autosubmit']
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function optionalEnum($enum)
|
protected function optionalEnum($enum)
|
||||||
|
|
|
@ -32,6 +32,10 @@ before switching to a new version.
|
||||||
tasks. When granted more (but not infinite) memory however this had the effect
|
tasks. When granted more (but not infinite) memory however this had the effect
|
||||||
that he self-restricted himself to a lower limit.
|
that he self-restricted himself to a lower limit.
|
||||||
|
|
||||||
|
### User Interface
|
||||||
|
* FIX: Assignment filters suggested only Host properties, you have been required
|
||||||
|
to manually type Service property names
|
||||||
|
|
||||||
1.4.0
|
1.4.0
|
||||||
-----
|
-----
|
||||||
### New requirements
|
### New requirements
|
||||||
|
|
Loading…
Reference in New Issue