You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by zh...@apache.org on 2016/04/07 00:04:03 UTC

ambari git commit: AMBARI-15136 Alert definitions: Percentage params are shown incrrectly (zhewang)

Repository: ambari
Updated Branches:
  refs/heads/trunk 5060b4f8c -> d4f2d9993


AMBARI-15136 Alert definitions: Percentage params are shown incrrectly (zhewang)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d4f2d999
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d4f2d999
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d4f2d999

Branch: refs/heads/trunk
Commit: d4f2d999362507bd91d7b8583702b98b3fb53b99
Parents: 5060b4f
Author: Zhe (Joe) Wang <zh...@apache.org>
Authored: Wed Apr 6 15:03:15 2016 -0700
Committer: Zhe (Joe) Wang <zh...@apache.org>
Committed: Wed Apr 6 15:03:43 2016 -0700

----------------------------------------------------------------------
 .../alerts/definition_configs_controller.js     |  6 ++--
 ambari-web/app/models/alerts/alert_config.js    | 20 +------------
 .../test/models/alerts/alert_config_test.js     | 30 --------------------
 3 files changed, 5 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d4f2d999/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
index 0141c11..d5b27c5 100644
--- a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
+++ b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js
@@ -366,6 +366,8 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
   renderAggregateConfigs: function () {
     var isWizard = this.get('isWizard');
     var alertDefinition = this.get('content');
+    var units = this.get('content.reporting').findProperty('type','units') ?
+        this.get('content.reporting').findProperty('type','units').get('text'): null;
     return [
       App.AlertConfigProperties.Description.create({
         value: isWizard ? '' : alertDefinition.get('description')
@@ -382,12 +384,12 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
       App.AlertConfigProperties.Thresholds.WarningThreshold.create(App.AlertConfigProperties.Thresholds.PercentageMixin, {
         text: isWizard ? '' : this.getThresholdsProperty('warning', 'text'),
         value: isWizard ? '' : this.getThresholdsProperty('warning', 'value'),
-        valueMetric: '%'
+        valueMetric: units
       }),
       App.AlertConfigProperties.Thresholds.CriticalThreshold.create(App.AlertConfigProperties.Thresholds.PercentageMixin, {
         text: isWizard ? '' : this.getThresholdsProperty('critical', 'text'),
         value: isWizard ? '' : this.getThresholdsProperty('critical', 'value'),
-        valueMetric: '%'
+        valueMetric: units
       })
     ];
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/d4f2d999/ambari-web/app/models/alerts/alert_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/alerts/alert_config.js b/ambari-web/app/models/alerts/alert_config.js
index 66ff2fb..efbfebf 100644
--- a/ambari-web/app/models/alerts/alert_config.js
+++ b/ambari-web/app/models/alerts/alert_config.js
@@ -612,25 +612,7 @@ App.AlertConfigProperties.Thresholds = {
       }
 
       return this.get('showInputForValue') ? !isNaN(value) && value > 0 : true;
-    }.property('displayValue', 'showInputForValue'),
-
-    /**
-     * Return <code>value * 100</code>
-     * @returns {string}
-     */
-    getNewValue: function () {
-      var value = this.get('value');
-      return value && !isNaN(value) ? Number(value) * 100 + '' : value;
-    },
-
-    /**
-     * Return <code>displayValue / 100</code>
-     * @returns {string}
-     */
-    getNewDisplayValue: function () {
-      var displayValue = this.get('displayValue');
-      return displayValue && !isNaN(displayValue) ? Number(displayValue) / 100 + '' : displayValue;
-    }
+    }.property('displayValue', 'showInputForValue')
 
   }),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d4f2d999/ambari-web/test/models/alerts/alert_config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/alerts/alert_config_test.js b/ambari-web/test/models/alerts/alert_config_test.js
index 56f1577..74a91f4 100644
--- a/ambari-web/test/models/alerts/alert_config_test.js
+++ b/ambari-web/test/models/alerts/alert_config_test.js
@@ -152,36 +152,6 @@ describe('App.AlertConfigProperties', function () {
 
     });
 
-    describe('#valueWasChanged', function () {
-
-      it('value change should effect displayValue for AGGREGATE type', function () {
-
-        model = App.AlertConfigProperties.Threshold.create(App.AlertConfigProperties.Thresholds.PercentageMixin, {
-          value: '0.4',
-          valueMetric: '%',
-          text: 'text',
-          showInputForValue: false,
-          showInputForText: false
-        });
-
-        expect(model.get('displayValue')).to.be.equal('40');
-      });
-
-      it('value change should not effect displayValue for not AGGREGATE type', function () {
-
-        model = App.AlertConfigProperties.Threshold.create({
-          value: '0.4',
-          valueMetric: '%',
-          text: 'text',
-          showInputForValue: false,
-          showInputForText: false
-        });
-
-        expect(model.get('displayValue')).to.be.equal('0.4');
-      });
-
-    });
-
     describe('#badgeCssClass', function () {
 
       it ('should be based on badge', function () {