mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
IcingaServiceForm: allow empty name for apply rule
This commit is contained in:
parent
7c31b37f27
commit
1f660b514a
@ -212,7 +212,7 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||||||
{
|
{
|
||||||
$this->addElement('text', 'object_name', array(
|
$this->addElement('text', 'object_name', array(
|
||||||
'label' => $this->translate('Name'),
|
'label' => $this->translate('Name'),
|
||||||
'required' => true,
|
'required' => !$this->object()->isApplyRule(),
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'Name for the Icinga service you are going to create'
|
'Name for the Icinga service you are going to create'
|
||||||
)
|
)
|
||||||
|
@ -29,6 +29,20 @@ class DirectorActivityLog extends DbObject
|
|||||||
'parent_checksum' => null,
|
'parent_checksum' => null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @codingStandardsIgnoreStart
|
||||||
|
*/
|
||||||
|
protected function setObject_Name($name)
|
||||||
|
{
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
|
|
||||||
|
if ($name === null) {
|
||||||
|
$name = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->reallySet('object_name', $name);
|
||||||
|
}
|
||||||
|
|
||||||
protected static function username()
|
protected static function username()
|
||||||
{
|
{
|
||||||
if (Icinga::app()->isCli()) {
|
if (Icinga::app()->isCli()) {
|
||||||
|
@ -105,7 +105,7 @@ class IcingaHost extends IcingaObject
|
|||||||
if (substr($prop, -3) === '_id') {
|
if (substr($prop, -3) === '_id') {
|
||||||
$prop = substr($prop, 0, -3);
|
$prop = substr($prop, 0, -3);
|
||||||
}
|
}
|
||||||
|
|
||||||
$hostProperties[$prefix . $prop] = $prop;
|
$hostProperties[$prefix . $prop] = $prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +133,20 @@ class IcingaService extends IcingaObject
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @codingStandardsIgnoreStart
|
||||||
|
*/
|
||||||
|
protected function setObject_Name($name)
|
||||||
|
{
|
||||||
|
// @codingStandardsIgnoreEnd
|
||||||
|
|
||||||
|
if ($name === null && $this->isApplyRule()) {
|
||||||
|
$name = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->reallySet('object_name', $name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render host_id as host_name
|
* Render host_id as host_name
|
||||||
*
|
*
|
||||||
@ -158,11 +172,16 @@ class IcingaService extends IcingaObject
|
|||||||
&& !$this->hasBeenAssignedToHostTemplate()
|
&& !$this->hasBeenAssignedToHostTemplate()
|
||||||
&& $this->get('apply_for') !== null) {
|
&& $this->get('apply_for') !== null) {
|
||||||
|
|
||||||
|
$name = $this->getObjectName();
|
||||||
|
if ($name !== '') {
|
||||||
|
$name = ' ' . c::renderString($name);
|
||||||
|
}
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
"%s %s %s for (config in %s) {\n",
|
"%s %s%s for (config in %s) {\n",
|
||||||
$this->getObjectTypeName(),
|
$this->getObjectTypeName(),
|
||||||
$this->getType(),
|
$this->getType(),
|
||||||
c::renderString($this->getObjectName()),
|
$name,
|
||||||
$this->get('apply_for')
|
$this->get('apply_for')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user