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;
|
private $inheritedFrom;
|
||||||
|
|
||||||
|
/** @var bool|null */
|
||||||
|
private $blacklisted;
|
||||||
|
|
||||||
public function setApplyGenerated(IcingaService $applyGenerated)
|
public function setApplyGenerated(IcingaService $applyGenerated)
|
||||||
{
|
{
|
||||||
$this->applyGenerated = $applyGenerated;
|
$this->applyGenerated = $applyGenerated;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setInheritedFrom($hostname)
|
public function setInheritedFrom($hostname)
|
||||||
{
|
{
|
||||||
$this->inheritedFrom = $hostname;
|
$this->inheritedFrom = $hostname;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +66,7 @@ class IcingaServiceForm extends DirectorObjectForm
|
||||||
|
|
||||||
if ($this->host && $this->set) {
|
if ($this->host && $this->set) {
|
||||||
$this->setupOnHostForSet();
|
$this->setupOnHostForSet();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,20 +125,29 @@ class IcingaServiceForm extends DirectorObjectForm
|
||||||
return;
|
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();
|
$this->addOverrideHint();
|
||||||
|
|
||||||
$group = $this->getDisplayGroup('custom_fields');
|
$group = $this->getDisplayGroup('custom_fields');
|
||||||
|
|
||||||
if ($group) {
|
if ($group) {
|
||||||
$elements = $group->getElements();
|
$elements = $group->getElements();
|
||||||
$group->setElements([$this->getElement('inheritance_hint')]);
|
$group->setElements([$this->getElement('inheritance_hint')]);
|
||||||
$group->addElements($elements);
|
$group->addElements($elements);
|
||||||
$this->setSubmitLabel(
|
$this->setSubmitLabel($this->translate('Override vars'));
|
||||||
$this->translate('Override vars')
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$this->addElementsToGroup(
|
$this->addElementsToGroup(
|
||||||
array('inheritance_hint'),
|
['inheritance_hint'],
|
||||||
'custom_fields',
|
'custom_fields',
|
||||||
20,
|
20,
|
||||||
$this->translate('Hints regarding this service')
|
$this->translate('Hints regarding this service')
|
||||||
|
@ -141,9 +156,6 @@ class IcingaServiceForm extends DirectorObjectForm
|
||||||
$this->setSubmitLabel(false);
|
$this->setSubmitLabel(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->hasBeenBlacklisted()) {
|
|
||||||
$this->addDeleteButton($this->translate('Restore'));
|
|
||||||
} else {
|
|
||||||
$this->addDeleteButton($this->translate('Blacklist'));
|
$this->addDeleteButton($this->translate('Blacklist'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,20 +197,24 @@ class IcingaServiceForm extends DirectorObjectForm
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->blacklisted === null) {
|
||||||
$host = $this->host;
|
$host = $this->host;
|
||||||
$service = $this->getFirstParent($this->object);
|
$service = $this->getFirstParent($this->object);
|
||||||
$db = $this->db->getDbAdapter();
|
$db = $this->db->getDbAdapter();
|
||||||
if ($this->providesOverrides()) {
|
if ($this->providesOverrides()) {
|
||||||
return 1 === (int) $db->fetchOne(
|
$this->blacklisted = 1 === (int)$db->fetchOne(
|
||||||
$db->select()->from('icinga_host_service_blacklist', 'COUNT(*)')
|
$db->select()->from('icinga_host_service_blacklist', 'COUNT(*)')
|
||||||
->where('host_id = ?', $host->get('id'))
|
->where('host_id = ?', $host->get('id'))
|
||||||
->where('service_id = ?', $service->get('id'))
|
->where('service_id = ?', $service->get('id'))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
$this->blacklisted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->blacklisted;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $object
|
* @param $object
|
||||||
* @throws IcingaException
|
* @throws IcingaException
|
||||||
|
|
Loading…
Reference in New Issue