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()
|
||||
{
|
||||
return $this->getFilterColumns('host.', [
|
||||
return $this->getFilterColumns('service.', [
|
||||
$this->translate('Service properties'),
|
||||
$this->translate('Host properties'),
|
||||
$this->translate('Host Custom variables'),
|
||||
|
|
|
@ -29,7 +29,7 @@ class IcingaDependencyForm extends DirectorObjectForm
|
|||
->addBooleanElements()
|
||||
->addPeriodElement()
|
||||
->addAssignmentElements()
|
||||
->addEventFilterElements(array('states'))
|
||||
->addEventFilterElements(['states'])
|
||||
->groupMainProperties()
|
||||
->setButtons();
|
||||
}
|
||||
|
@ -67,23 +67,20 @@ class IcingaDependencyForm extends DirectorObjectForm
|
|||
|
||||
$applyTo = $this->getSentOrObjectValue('apply_to');
|
||||
|
||||
if ($applyTo === 'host') {
|
||||
$columns = IcingaHost::enumProperties($this->db, 'host.');
|
||||
} elseif ($applyTo === 'service') {
|
||||
// TODO: Also add host properties
|
||||
$columns = IcingaService::enumProperties($this->db, 'service.');
|
||||
} else {
|
||||
if (! $applyTo) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->addAssignFilter(array(
|
||||
'columns' => $columns,
|
||||
$suggestionContext = ucfirst($applyTo) . 'FilterColumns';
|
||||
$this->addAssignFilter([
|
||||
'suggestionContext' => $suggestionContext,
|
||||
'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;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Objects\IcingaHost;
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaHostGroupForm extends DirectorObjectForm
|
||||
|
@ -11,11 +10,11 @@ class IcingaHostGroupForm extends DirectorObjectForm
|
|||
{
|
||||
$this->addHidden('object_type', 'object');
|
||||
|
||||
$this->addElement('text', 'object_name', array(
|
||||
$this->addElement('text', 'object_name', [
|
||||
'label' => $this->translate('Hostgroup'),
|
||||
'required' => true,
|
||||
'description' => $this->translate('Icinga object name for this host group')
|
||||
));
|
||||
]);
|
||||
|
||||
$this->addGroupDisplayNameElement()
|
||||
->addAssignmentElements()
|
||||
|
@ -24,14 +23,14 @@ class IcingaHostGroupForm extends DirectorObjectForm
|
|||
|
||||
protected function addAssignmentElements()
|
||||
{
|
||||
$this->addAssignFilter(array(
|
||||
'columns' => IcingaHost::enumProperties($this->db, 'host.'),
|
||||
$this->addAssignFilter([
|
||||
'suggestionContext' => 'HostFilterColumns',
|
||||
'required' => false,
|
||||
'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;
|
||||
}
|
||||
|
|
|
@ -92,23 +92,20 @@ class IcingaNotificationForm extends DirectorObjectForm
|
|||
|
||||
$applyTo = $this->getSentOrObjectValue('apply_to');
|
||||
|
||||
if ($applyTo === 'host') {
|
||||
$columns = IcingaHost::enumProperties($this->db, 'host.');
|
||||
} elseif ($applyTo === 'service') {
|
||||
// TODO: Also add host properties
|
||||
$columns = IcingaService::enumProperties($this->db, 'service.');
|
||||
} else {
|
||||
if (! $applyTo) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->addAssignFilter(array(
|
||||
'columns' => $columns,
|
||||
$suggestionContext = ucfirst($applyTo) . 'FilterColumns';
|
||||
$this->addAssignFilter([
|
||||
'required' => true,
|
||||
'suggestionContext' => $suggestionContext,
|
||||
'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;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Objects\IcingaService;
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaServiceGroupForm extends DirectorObjectForm
|
||||
|
@ -11,11 +10,11 @@ class IcingaServiceGroupForm extends DirectorObjectForm
|
|||
{
|
||||
$this->addHidden('object_type', 'object');
|
||||
|
||||
$this->addElement('text', 'object_name', array(
|
||||
$this->addElement('text', 'object_name', [
|
||||
'label' => $this->translate('Servicegroup'),
|
||||
'required' => true,
|
||||
'description' => $this->translate('Icinga object name for this service group')
|
||||
));
|
||||
]);
|
||||
|
||||
$this->addGroupDisplayNameElement()
|
||||
->addAssignmentElements()
|
||||
|
@ -24,14 +23,14 @@ class IcingaServiceGroupForm extends DirectorObjectForm
|
|||
|
||||
protected function addAssignmentElements()
|
||||
{
|
||||
$this->addAssignFilter(array(
|
||||
'columns' => IcingaService::enumProperties($this->db, 'service.'),
|
||||
$this->addAssignFilter([
|
||||
'suggestionContext' => 'ServiceFilterColumns',
|
||||
'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;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Objects\IcingaHost;
|
||||
use Icinga\Module\Director\Objects\IcingaServiceSet;
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaServiceSetForm extends DirectorObjectForm
|
||||
|
@ -111,15 +110,15 @@ class IcingaServiceSetForm extends DirectorObjectForm
|
|||
|
||||
protected function addAssignmentElements()
|
||||
{
|
||||
$this->addAssignFilter(array(
|
||||
'columns' => IcingaHost::enumProperties($this->db, 'host.'),
|
||||
$this->addAssignFilter([
|
||||
'suggestionContext' => 'HostFilterColumns',
|
||||
'description' => $this->translate(
|
||||
'This allows you to configure an assignment filter. Please feel'
|
||||
. ' free to combine as many nested operators as you want. You'
|
||||
. ' might also want to skip this, define it later and/or just'
|
||||
. ' add this set of services to single hosts'
|
||||
)
|
||||
));
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
|||
|
||||
private $query;
|
||||
|
||||
private $suggestionContext;
|
||||
|
||||
/**
|
||||
* Generates an 'extensible set' element.
|
||||
*
|
||||
|
@ -49,6 +51,11 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
|||
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
|
||||
// array use attribs? class etc? disabled?
|
||||
// override _getInfo?
|
||||
|
@ -338,6 +345,16 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
|||
return $this;
|
||||
}
|
||||
|
||||
protected function getSuggestionContext()
|
||||
{
|
||||
return $this->suggestionContext;
|
||||
}
|
||||
|
||||
protected function setSuggestionContext($context)
|
||||
{
|
||||
$this->suggestionContext = $context;
|
||||
}
|
||||
|
||||
protected function selectColumn(FilterExpression $filter = null)
|
||||
{
|
||||
$active = $filter === null ? null : $filter->getColumn();
|
||||
|
@ -345,41 +362,41 @@ class Zend_View_Helper_FormDataFilter extends Zend_View_Helper_FormElement
|
|||
$active = $filter->getExpression();
|
||||
}
|
||||
|
||||
if (! $this->hasColumnList()) {
|
||||
if ($context = $this->getSuggestionContext()) {
|
||||
return $this->view->formText(
|
||||
$this->elementId('column', $filter),
|
||||
$active,
|
||||
array('class' => 'column autosubmit')
|
||||
[
|
||||
'class' => 'column autosubmit director-suggest',
|
||||
'data-suggestion-context' => $context,
|
||||
]
|
||||
);
|
||||
}
|
||||
if ($this->hasColumnList()) {
|
||||
$cols = $this->getColumnList();
|
||||
if ($active && !isset($cols[$active])) {
|
||||
$cols[$active] = str_replace(
|
||||
'_',
|
||||
' ',
|
||||
ucfirst(ltrim($active, '_'))
|
||||
); // ??
|
||||
}
|
||||
|
||||
$cols = $this->optionalEnum($cols);
|
||||
|
||||
return $this->view->formText(
|
||||
$this->elementId('column', $filter),
|
||||
$active,
|
||||
[
|
||||
'class' => 'column autosubmit director-suggest',
|
||||
'data-suggestion-context' => 'HostFilterColumns',
|
||||
]
|
||||
);
|
||||
|
||||
$cols = $this->getColumnList();
|
||||
if ($active && !isset($cols[$active])) {
|
||||
$cols[$active] = str_replace(
|
||||
'_',
|
||||
' ',
|
||||
ucfirst(ltrim($active, '_'))
|
||||
); // ??
|
||||
return $this->select(
|
||||
$this->elementId('column', $filter),
|
||||
$cols,
|
||||
$active,
|
||||
['class' => 'column autosubmit']
|
||||
);
|
||||
} else {
|
||||
return $this->view->formText(
|
||||
$this->elementId('column', $filter),
|
||||
$active,
|
||||
['class' => 'column autosubmit']
|
||||
);
|
||||
}
|
||||
|
||||
$cols = $this->optionalEnum($cols);
|
||||
|
||||
return $this->select(
|
||||
$this->elementId('column', $filter),
|
||||
$cols,
|
||||
$active,
|
||||
array('class' => 'column autosubmit')
|
||||
);
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
-----
|
||||
### New requirements
|
||||
|
|
Loading…
Reference in New Issue