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