IcingaServiceForm: show a warning and no...
...override details for blacklisted services
This commit is contained in:
parent
7efeab674c
commit
6790ff1c30
|
@ -32,15 +32,20 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||
|
||||
private $inheritedFrom;
|
||||
|
||||
/** @var bool|null */
|
||||
private $blacklisted;
|
||||
|
||||
public function setApplyGenerated(IcingaService $applyGenerated)
|
||||
{
|
||||
$this->applyGenerated = $applyGenerated;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setInheritedFrom($hostname)
|
||||
{
|
||||
$this->inheritedFrom = $hostname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -61,6 +66,7 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||
|
||||
if ($this->host && $this->set) {
|
||||
$this->setupOnHostForSet();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -119,20 +125,29 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||
return;
|
||||
}
|
||||
|
||||
if ($this->hasBeenBlacklisted()) {
|
||||
$this->addHtml(
|
||||
Html::tag(
|
||||
'p',
|
||||
['class' => 'warning'],
|
||||
$this->translate('This Service has been blacklisted on this host')
|
||||
),
|
||||
['name' => 'HINT_blacklisted']
|
||||
);
|
||||
$group = null;
|
||||
$this->addDeleteButton($this->translate('Restore'));
|
||||
$this->setSubmitLabel(false);
|
||||
} else {
|
||||
$this->addOverrideHint();
|
||||
|
||||
$group = $this->getDisplayGroup('custom_fields');
|
||||
|
||||
if ($group) {
|
||||
$elements = $group->getElements();
|
||||
$group->setElements([$this->getElement('inheritance_hint')]);
|
||||
$group->addElements($elements);
|
||||
$this->setSubmitLabel(
|
||||
$this->translate('Override vars')
|
||||
);
|
||||
$this->setSubmitLabel($this->translate('Override vars'));
|
||||
} else {
|
||||
$this->addElementsToGroup(
|
||||
array('inheritance_hint'),
|
||||
['inheritance_hint'],
|
||||
'custom_fields',
|
||||
20,
|
||||
$this->translate('Hints regarding this service')
|
||||
|
@ -141,9 +156,6 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||
$this->setSubmitLabel(false);
|
||||
}
|
||||
|
||||
if ($this->hasBeenBlacklisted()) {
|
||||
$this->addDeleteButton($this->translate('Restore'));
|
||||
} else {
|
||||
$this->addDeleteButton($this->translate('Blacklist'));
|
||||
}
|
||||
|
||||
|
@ -185,20 +197,24 @@ class IcingaServiceForm extends DirectorObjectForm
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($this->blacklisted === null) {
|
||||
$host = $this->host;
|
||||
$service = $this->getFirstParent($this->object);
|
||||
$db = $this->db->getDbAdapter();
|
||||
if ($this->providesOverrides()) {
|
||||
return 1 === (int) $db->fetchOne(
|
||||
$this->blacklisted = 1 === (int)$db->fetchOne(
|
||||
$db->select()->from('icinga_host_service_blacklist', 'COUNT(*)')
|
||||
->where('host_id = ?', $host->get('id'))
|
||||
->where('service_id = ?', $service->get('id'))
|
||||
);
|
||||
} else {
|
||||
return false;
|
||||
$this->blacklisted = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->blacklisted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $object
|
||||
* @throws IcingaException
|
||||
|
|
Loading…
Reference in New Issue