IcingaServiceForm: adjust overrides for host-...

...generated services
This commit is contained in:
Thomas Gelf 2016-09-08 13:10:42 +00:00
parent b8fb0d4267
commit f8ed937ffa
2 changed files with 17 additions and 14 deletions

View File

@ -132,16 +132,21 @@ class HostController extends ObjectController
$parent = IcingaService::create(array(
'object_type' => 'template',
'object_name' => $this->translate('Host'),
'vars' => $props->vars->getValue(),
), $db);
if (isset($props->vars)) {
$parent->vars = $props->vars->getValue();
}
$service = IcingaService::create(array(
'object_type' => 'apply',
'object_name' => $serviceName,
'host_id' => $host->id,
'vars' => $host->getOverriddenServiceVars($serviceName),
), $db);
if ($templates = $props->templates->getValue()) {
if (isset($props->templates) && $templates = $props->templates->getValue()) {
$imports = $templates;
} else {
$imports = $serviceName;
@ -152,7 +157,7 @@ class HostController extends ObjectController
}
// TODO: Validation for $imports? They might not exist!
array_unshift($imports, $parent);
array_push($imports, $parent);
$service->imports = $imports;
$this->view->title = sprintf(

View File

@ -83,29 +83,27 @@ class IcingaServiceForm extends DirectorObjectForm
protected function setupHostGenerated()
{
$this->addNameElement()
->addImportsElement()
->addDisabledElement();
$msg = $this->translate(
'This service has been generated from host properties.'
);
$this->addHtmlHint($msg);
$this->setSubmitLabel(
$this->translate('Override vars')
);
foreach (array('object_name', 'imports') as $name) {
$this->getElement($name)->setAttrib('disabled', 'disabled');
$this->getElement($name)->setRequired(false);
}
}
protected function setupInherited()
{
$msg = $this->translate(
$view = $this->getView();
$msg = $view->escape($this->translate(
'This service has been inherited from %s. Still, you might want'
. ' to change the following properties for this host only.'
);
));
$name = $this->inheritedFrom;
$link = $this->getView()->qlink(
$link = $view->qlink(
$name,
'director/service',
array(