From 4fbadaea2c2a7e998d017d318dbb65b1c3a5306a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 18 May 2015 14:20:17 +0200 Subject: [PATCH 1/4] ToggleInstanceFeaturesCommandForm::createElements(): make form labels shorter refs #9023 --- .../ToggleInstanceFeaturesCommandForm.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 79d15f5c1..e26931f7b 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -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 ) From 729fb9a4d16d5667910bbc59350b8c2eb0dcb8af Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 18 May 2015 14:51:22 +0200 Subject: [PATCH 2/4] ToggleInstanceFeaturesCommandForm::onSuccess(): notifications: show which feature has been enabled or disabled refs #9023 --- .../ToggleInstanceFeaturesCommandForm.php | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index e26931f7b..50970df0c 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -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] ); } } From 0d48ddcc062f67cb2fb4d5e6eaf81bb06aaeb481 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 18 May 2015 15:18:26 +0200 Subject: [PATCH 3/4] ToggleObjectFeaturesCommandForm::onSuccess(): show a notification for each feature about whether it has been enabled or disabled refs #9023 --- .../ToggleObjectFeaturesCommandForm.php | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index 34fbb4c2c..85a6ae3fd 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -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; } } From 7caba93a28c972585bafaaa0fa7dc59da59758e3 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 18 May 2015 16:03:15 +0200 Subject: [PATCH 4/4] Replace `...' w/ `..' refs #9023 --- .../ToggleInstanceFeaturesCommandForm.php | 40 +++++++++---------- .../ToggleObjectFeaturesCommandForm.php | 24 +++++------ 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index 50970df0c..9ef90718f 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -212,44 +212,44 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm $notifications = array( ToggleInstanceFeatureCommand::FEATURE_ACTIVE_HOST_CHECKS => array( - $this->translate('Enabling active host checks...'), - $this->translate('Disabling active host checks...') + $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...') + $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...') + $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...') + $this->translate('Enabling flap detection..'), + $this->translate('Disabling flap detection..') ), ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS => array( - $this->translate('Enabling notifications...'), - $this->translate('Disabling notifications...') + $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...') + $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...') + $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...') + $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...') + $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...') + $this->translate('Enabling performance data..'), + $this->translate('Disabling performance data..') ) ); diff --git a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php index 85a6ae3fd..ad6196d44 100644 --- a/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ToggleObjectFeaturesCommandForm.php @@ -120,28 +120,28 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm $notifications = array( ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS => array( - $this->translate('Enabling active checks...'), - $this->translate('Disabling active checks...') + $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...') + $this->translate('Enabling passive checks..'), + $this->translate('Disabling passive checks..') ), ToggleObjectFeatureCommand::FEATURE_OBSESSING => array( - $this->translate('Enabling obsessing...'), - $this->translate('Disabling obsessing...') + $this->translate('Enabling obsessing..'), + $this->translate('Disabling obsessing..') ), ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS => array( - $this->translate('Enabling notifications...'), - $this->translate('Disabling notifications...') + $this->translate('Enabling notifications..'), + $this->translate('Disabling notifications..') ), ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER => array( - $this->translate('Enabling event handler...'), - $this->translate('Disabling event handler...') + $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...') + $this->translate('Enabling flap detection..'), + $this->translate('Disabling flap detection..') ) );