IcingaHostForm: use choices and suggestions
This commit is contained in:
parent
90e0d1a50b
commit
65ddbb02ab
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Restriction\BetaHostgroupRestriction;
|
||||
use Icinga\Module\Director\Restriction\HostgroupRestriction;
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaHostForm extends DirectorObjectForm
|
||||
|
@ -18,6 +18,7 @@ class IcingaHostForm extends DirectorObjectForm
|
|||
$this->addElement('text', 'object_name', array(
|
||||
'label' => $this->translate('Hostname'),
|
||||
'required' => true,
|
||||
'spellcheck' => 'false',
|
||||
'description' => $this->translate(
|
||||
'Icinga object name for this host. This is usually a fully qualified host name'
|
||||
. ' but it could basically be any kind of string. To make things easier for your'
|
||||
|
@ -35,6 +36,7 @@ class IcingaHostForm extends DirectorObjectForm
|
|||
|
||||
$this->addGroupsElement()
|
||||
->addImportsElement()
|
||||
->addChoices('host')
|
||||
->addDisplayNameElement()
|
||||
->addAddressElements()
|
||||
->addDisabledElement()
|
||||
|
@ -133,6 +135,7 @@ class IcingaHostForm extends DirectorObjectForm
|
|||
*/
|
||||
protected function addGroupsElement()
|
||||
{
|
||||
// TODO:
|
||||
if ($this->hasHostGroupRestriction()) {
|
||||
return $this;
|
||||
}
|
||||
|
@ -144,8 +147,8 @@ class IcingaHostForm extends DirectorObjectForm
|
|||
|
||||
$this->addElement('extensibleSet', 'groups', array(
|
||||
'label' => $this->translate('Groups'),
|
||||
'multiOptions' => $this->optionallyAddFromEnum($groups),
|
||||
'positional' => false,
|
||||
// 'multiOptions' => $this->optionallyAddFromEnum($groups),
|
||||
'suggest' => 'hostgroupnames',
|
||||
'description' => $this->translate(
|
||||
'Hostgroups that should be directly assigned to this node. Hostgroups can be useful'
|
||||
. ' for various reasons. You might assign service checks based on assigned hostgroup.'
|
||||
|
@ -160,15 +163,7 @@ class IcingaHostForm extends DirectorObjectForm
|
|||
|
||||
protected function hasHostGroupRestriction()
|
||||
{
|
||||
foreach ($this->getObjectRestrictions() as $restriction) {
|
||||
if ($restriction instanceof BetaHostgroupRestriction) {
|
||||
if ($restriction->isRestricted()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return $this->getAuth()->getRestrictions('director/filter/hostgroups');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -207,6 +202,7 @@ class IcingaHostForm extends DirectorObjectForm
|
|||
|
||||
$this->addElement('text', 'display_name', array(
|
||||
'label' => $this->translate('Display name'),
|
||||
'spellcheck' => 'false',
|
||||
'description' => $this->translate(
|
||||
'Alternative name for this host. Might be a host alias or and kind'
|
||||
. ' of string helping your users to identify this host'
|
||||
|
|
Loading…
Reference in New Issue