Merge branch 'bugfix/Toggle-FeaturesCommandForm-make-notifications-more-verbose-9023'
fixes #9023
This commit is contained in:
commit
52d1cb8c8f
|
@ -85,7 +85,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
'checkbox',
|
||||
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS,
|
||||
array(
|
||||
'label' => $this->translate('Active Host Checks Being Executed'),
|
||||
'label' => $this->translate('Active Host Checks'),
|
||||
'autosubmit' => true,
|
||||
'disabled' => $toggleDisabled
|
||||
)
|
||||
|
@ -94,7 +94,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
'checkbox',
|
||||
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS,
|
||||
array(
|
||||
'label' => $this->translate('Active Service Checks Being Executed'),
|
||||
'label' => $this->translate('Active Service Checks'),
|
||||
'autosubmit' => true,
|
||||
'disabled' => $toggleDisabled
|
||||
)
|
||||
|
@ -103,7 +103,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
'checkbox',
|
||||
ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS,
|
||||
array(
|
||||
'label' => $this->translate('Event Handlers Enabled'),
|
||||
'label' => $this->translate('Event Handlers'),
|
||||
'autosubmit' => true,
|
||||
'disabled' => $toggleDisabled
|
||||
)
|
||||
|
@ -112,7 +112,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
'checkbox',
|
||||
ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION,
|
||||
array(
|
||||
'label' => $this->translate('Flap Detection Enabled'),
|
||||
'label' => $this->translate('Flap Detection'),
|
||||
'autosubmit' => true,
|
||||
'disabled' => $toggleDisabled
|
||||
)
|
||||
|
@ -121,7 +121,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
'checkbox',
|
||||
ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS,
|
||||
array(
|
||||
'label' => $this->translate('Notifications Enabled'),
|
||||
'label' => $this->translate('Notifications'),
|
||||
'autosubmit' => true,
|
||||
'description' => $notificationDescription,
|
||||
'decorators' => array(
|
||||
|
@ -159,7 +159,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
'checkbox',
|
||||
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS,
|
||||
array(
|
||||
'label' => $this->translate('Passive Host Checks Being Accepted'),
|
||||
'label' => $this->translate('Passive Host Checks'),
|
||||
'autosubmit' => true,
|
||||
'disabled' => $toggleDisabled
|
||||
)
|
||||
|
@ -168,7 +168,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
'checkbox',
|
||||
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS,
|
||||
array(
|
||||
'label' => $this->translate('Passive Service Checks Being Accepted'),
|
||||
'label' => $this->translate('Passive Service Checks'),
|
||||
'autosubmit' => true,
|
||||
'disabled' => $toggleDisabled
|
||||
)
|
||||
|
@ -177,7 +177,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
'checkbox',
|
||||
ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA,
|
||||
array(
|
||||
'label' => $this->translate('Performance Data Being Processed'),
|
||||
'label' => $this->translate('Performance Data'),
|
||||
'autosubmit' => true,
|
||||
'disabled' => $toggleDisabled
|
||||
)
|
||||
|
@ -209,6 +209,50 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
public function onSuccess()
|
||||
{
|
||||
$this->assertPermission('monitoring/command/feature/instance');
|
||||
|
||||
$notifications = array(
|
||||
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS => array(
|
||||
$this->translate('Enabling active host checks..'),
|
||||
$this->translate('Disabling active host checks..')
|
||||
),
|
||||
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS => array(
|
||||
$this->translate('Enabling active service checks..'),
|
||||
$this->translate('Disabling active service checks..')
|
||||
),
|
||||
ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS => array(
|
||||
$this->translate('Enabling event handlers..'),
|
||||
$this->translate('Disabling event handlers..')
|
||||
),
|
||||
ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION => array(
|
||||
$this->translate('Enabling flap detection..'),
|
||||
$this->translate('Disabling flap detection..')
|
||||
),
|
||||
ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS => array(
|
||||
$this->translate('Enabling notifications..'),
|
||||
$this->translate('Disabling notifications..')
|
||||
),
|
||||
ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING => array(
|
||||
$this->translate('Enabling obsessing over hosts..'),
|
||||
$this->translate('Disabling obsessing over hosts..')
|
||||
),
|
||||
ToggleInstanceFeatureCommand::FEATURE_SERVICE_OBSESSING => array(
|
||||
$this->translate('Enabling obsessing over services..'),
|
||||
$this->translate('Disabling obsessing over services..')
|
||||
),
|
||||
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS => array(
|
||||
$this->translate('Enabling passive host checks..'),
|
||||
$this->translate('Disabling passive host checks..')
|
||||
),
|
||||
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS => array(
|
||||
$this->translate('Enabling passive service checks..'),
|
||||
$this->translate('Disabling passive service checks..')
|
||||
),
|
||||
ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA => array(
|
||||
$this->translate('Enabling performance data..'),
|
||||
$this->translate('Disabling performance data..')
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($this->getValues() as $feature => $enabled) {
|
||||
$toggleFeature = new ToggleInstanceFeatureCommand();
|
||||
$toggleFeature
|
||||
|
@ -216,10 +260,9 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
->setEnabled($enabled);
|
||||
$this->getTransport($this->request)->send($toggleFeature);
|
||||
|
||||
if ($this->status->{$feature} != $enabled) {
|
||||
Notification::success($enabled
|
||||
? $this->translate('Enabling feature..')
|
||||
: $this->translate('Disabling feature..')
|
||||
if ((bool) $this->status->{$feature} !== (bool) $enabled) {
|
||||
Notification::success(
|
||||
$notifications[$feature][$enabled ? 0 : 1]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,6 +117,34 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
|
|||
public function onSuccess()
|
||||
{
|
||||
$this->assertPermission('monitoring/command/feature/object');
|
||||
|
||||
$notifications = array(
|
||||
ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS => array(
|
||||
$this->translate('Enabling active checks..'),
|
||||
$this->translate('Disabling active checks..')
|
||||
),
|
||||
ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS => array(
|
||||
$this->translate('Enabling passive checks..'),
|
||||
$this->translate('Disabling passive checks..')
|
||||
),
|
||||
ToggleObjectFeatureCommand::FEATURE_OBSESSING => array(
|
||||
$this->translate('Enabling obsessing..'),
|
||||
$this->translate('Disabling obsessing..')
|
||||
),
|
||||
ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS => array(
|
||||
$this->translate('Enabling notifications..'),
|
||||
$this->translate('Disabling notifications..')
|
||||
),
|
||||
ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER => array(
|
||||
$this->translate('Enabling event handler..'),
|
||||
$this->translate('Disabling event handler..')
|
||||
),
|
||||
ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION => array(
|
||||
$this->translate('Enabling flap detection..'),
|
||||
$this->translate('Disabling flap detection..')
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($this->objects as $object) {
|
||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||
foreach ($this->getValues() as $feature => $enabled) {
|
||||
|
@ -127,10 +155,13 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
|
|||
->setObject($object)
|
||||
->setEnabled($enabled);
|
||||
$this->getTransport($this->request)->send($toggleFeature);
|
||||
|
||||
Notification::success(
|
||||
$notifications[$feature][$enabled ? 0 : 1]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Notification::success($this->translate('Toggling feature..'));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue