Merge branch 'bugfix/Toggle-FeaturesCommandForm-make-notifications-more-verbose-9023'

fixes #9023
This commit is contained in:
Alexander A. Klimov 2015-05-18 16:09:07 +02:00
commit 52d1cb8c8f
2 changed files with 87 additions and 13 deletions

View File

@ -85,7 +85,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS, ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS,
array( array(
'label' => $this->translate('Active Host Checks Being Executed'), 'label' => $this->translate('Active Host Checks'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -94,7 +94,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS, ToggleInstanceFeatureCommand::FEATURE_ACTIVE_SERVICE_CHECKS,
array( array(
'label' => $this->translate('Active Service Checks Being Executed'), 'label' => $this->translate('Active Service Checks'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -103,7 +103,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS, ToggleInstanceFeatureCommand::FEATURE_EVENT_HANDLERS,
array( array(
'label' => $this->translate('Event Handlers Enabled'), 'label' => $this->translate('Event Handlers'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -112,7 +112,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION, ToggleInstanceFeatureCommand::FEATURE_FLAP_DETECTION,
array( array(
'label' => $this->translate('Flap Detection Enabled'), 'label' => $this->translate('Flap Detection'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -121,7 +121,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS, ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS,
array( array(
'label' => $this->translate('Notifications Enabled'), 'label' => $this->translate('Notifications'),
'autosubmit' => true, 'autosubmit' => true,
'description' => $notificationDescription, 'description' => $notificationDescription,
'decorators' => array( 'decorators' => array(
@ -159,7 +159,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS, ToggleInstanceFeatureCommand::FEATURE_PASSIVE_HOST_CHECKS,
array( array(
'label' => $this->translate('Passive Host Checks Being Accepted'), 'label' => $this->translate('Passive Host Checks'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -168,7 +168,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS, ToggleInstanceFeatureCommand::FEATURE_PASSIVE_SERVICE_CHECKS,
array( array(
'label' => $this->translate('Passive Service Checks Being Accepted'), 'label' => $this->translate('Passive Service Checks'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -177,7 +177,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
'checkbox', 'checkbox',
ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA, ToggleInstanceFeatureCommand::FEATURE_PERFORMANCE_DATA,
array( array(
'label' => $this->translate('Performance Data Being Processed'), 'label' => $this->translate('Performance Data'),
'autosubmit' => true, 'autosubmit' => true,
'disabled' => $toggleDisabled 'disabled' => $toggleDisabled
) )
@ -209,6 +209,50 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
public function onSuccess() public function onSuccess()
{ {
$this->assertPermission('monitoring/command/feature/instance'); $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) { foreach ($this->getValues() as $feature => $enabled) {
$toggleFeature = new ToggleInstanceFeatureCommand(); $toggleFeature = new ToggleInstanceFeatureCommand();
$toggleFeature $toggleFeature
@ -216,10 +260,9 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
->setEnabled($enabled); ->setEnabled($enabled);
$this->getTransport($this->request)->send($toggleFeature); $this->getTransport($this->request)->send($toggleFeature);
if ($this->status->{$feature} != $enabled) { if ((bool) $this->status->{$feature} !== (bool) $enabled) {
Notification::success($enabled Notification::success(
? $this->translate('Enabling feature..') $notifications[$feature][$enabled ? 0 : 1]
: $this->translate('Disabling feature..')
); );
} }
} }

View File

@ -117,6 +117,34 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
public function onSuccess() public function onSuccess()
{ {
$this->assertPermission('monitoring/command/feature/object'); $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) { foreach ($this->objects as $object) {
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */ /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
foreach ($this->getValues() as $feature => $enabled) { foreach ($this->getValues() as $feature => $enabled) {
@ -127,10 +155,13 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
->setObject($object) ->setObject($object)
->setEnabled($enabled); ->setEnabled($enabled);
$this->getTransport($this->request)->send($toggleFeature); $this->getTransport($this->request)->send($toggleFeature);
Notification::success(
$notifications[$feature][$enabled ? 0 : 1]
);
} }
} }
} }
Notification::success($this->translate('Toggling feature..'));
return true; return true;
} }
} }