ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-12168. Configs: Historical configs show "default" values that don't make sense (onechiporenko)
Date Fri, 26 Jun 2015 13:52:53 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d94a5da8f -> a9e122e85


AMBARI-12168. Configs: Historical configs show "default" values that don't make sense (onechiporenko)


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

Branch: refs/heads/trunk
Commit: a9e122e85c7ab614626acb2f47b49429e484425b
Parents: d94a5da
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Fri Jun 26 16:50:45 2015 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Fri Jun 26 16:50:57 2015 +0300

----------------------------------------------------------------------
 .../mixins/common/configs/configs_comparator.js |  4 +-
 .../widgets/slider_config_widget_view.js        | 59 ++++++++++----------
 .../widgets/slider_config_widget_view_test.js   | 22 ++++++++
 3 files changed, 56 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a9e122e8/ambari-web/app/mixins/common/configs/configs_comparator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_comparator.js b/ambari-web/app/mixins/common/configs/configs_comparator.js
index f056347..2f15ea0 100644
--- a/ambari-web/app/mixins/common/configs/configs_comparator.js
+++ b/ambari-web/app/mixins/common/configs/configs_comparator.js
@@ -226,7 +226,8 @@ App.ConfigsComparator = Em.Mixin.create({
       compareObject.setProperties({
         isFinal: !!compareConfig.isFinal,
         value: App.config.formatOverrideValue(serviceConfig, compareConfig.value),
-        compareConfigs: null
+        compareConfigs: null,
+        isOriginalSCP: false
       });
     }
     return compareObject;
@@ -292,6 +293,7 @@ App.ConfigsComparator = Em.Mixin.create({
       isSecureConfig: false,
       isUserProperty: true,
       isVisible: true,
+      isOriginalSCP: false,
       name: name,
       filename: filename,
       serviceName: serviceName,

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9e122e8/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
index 32f273c..e37a565 100644
--- a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
@@ -319,6 +319,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
       mirrorStep = this.get('mirrorStep'),
       recommendedValue = this.valueForTick(+this.get('widgetRecommendedValue')),
       range = Math.floor((maxMirrorValue - minMirrorValue) / mirrorStep) * mirrorStep,
+      isOriginalSCP = config.get('isOriginalSCP'),
       // for little odd numbers in range 4..23 and widget type 'int' use always 4 ticks
       isSmallInt = this.get('unitType') == 'int' && range > 4 && range
< 23 && range % 2 == 1,
       recommendedValueMirroredId,
@@ -339,35 +340,37 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
 
     ticks = ticks.uniq();
 
-    // default marker should be added only if recommendedValue is in range [min, max]
-    if (recommendedValue <= maxMirrorValue && recommendedValue >= minMirrorValue
&& recommendedValue != '') {
-      // process additional tick for default value if it not defined in previous computation
-      if (!ticks.contains(recommendedValue)) {
-        // push default value
-        ticks.push(recommendedValue);
-        // and resort array
-        ticks = ticks.sort(function (a, b) {
-          return a - b;
-        });
-        recommendedValueId = ticks.indexOf(recommendedValue);
-        // to save nice tick labels layout we should add new tick value which is mirrored
by index to default value
-        recommendedValueMirroredId = ticks.length - recommendedValueId;
-        // push mirrored default value behind default
-        if (recommendedValueId == recommendedValueMirroredId) {
-          recommendedValueMirroredId--;
+    if (!(this.get('controller.isCompareMode') && !isOriginalSCP)) {
+      // default marker should be added only if recommendedValue is in range [min, max]
+      if (recommendedValue <= maxMirrorValue && recommendedValue >= minMirrorValue
&& recommendedValue != '') {
+        // process additional tick for default value if it not defined in previous computation
+        if (!ticks.contains(recommendedValue)) {
+          // push default value
+          ticks.push(recommendedValue);
+          // and resort array
+          ticks = ticks.sort(function (a, b) {
+            return a - b;
+          });
+          recommendedValueId = ticks.indexOf(recommendedValue);
+          // to save nice tick labels layout we should add new tick value which is mirrored
by index to default value
+          recommendedValueMirroredId = ticks.length - recommendedValueId;
+          // push mirrored default value behind default
+          if (recommendedValueId == recommendedValueMirroredId) {
+            recommendedValueMirroredId--;
+          }
+          // push empty label for default value tick
+          ticksLabels.insertAt(recommendedValueId, '');
+          // push empty to mirrored position
+          ticksLabels.insertAt(recommendedValueMirroredId, '');
+          // for saving correct sliding need to add value to mirrored position which is average
between previous
+          // and next value
+          ticks.insertAt(recommendedValueMirroredId, this.valueForTick((ticks[recommendedValueMirroredId]
+ ticks[recommendedValueMirroredId - 1]) / 2));
+          // get new index for default value
+          recommendedValueId = ticks.indexOf(recommendedValue);
+        }
+        else {
+          recommendedValueId = ticks.indexOf(recommendedValue);
         }
-        // push empty label for default value tick
-        ticksLabels.insertAt(recommendedValueId, '');
-        // push empty to mirrored position
-        ticksLabels.insertAt(recommendedValueMirroredId, '');
-        // for saving correct sliding need to add value to mirrored position which is average
between previous
-        // and next value
-        ticks.insertAt(recommendedValueMirroredId, this.valueForTick((ticks[recommendedValueMirroredId]
+ ticks[recommendedValueMirroredId - 1]) / 2));
-        // get new index for default value
-        recommendedValueId = ticks.indexOf(recommendedValue);
-      }
-      else {
-        recommendedValueId = ticks.indexOf(recommendedValue);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a9e122e8/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
index b008909..38c382c 100644
--- a/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
+++ b/ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
@@ -379,6 +379,25 @@ describe('App.SliderConfigWidgetView', function () {
           ticks: [1, 10, 26, 51, 75, 87.5, 100],
           ticksLabels: ["1 GB", "", "", "51 GB", "", "", "100 GB"]
         }
+      },
+      {
+        viewSetup: {
+          minMirrorValue: 1,
+          maxMirrorValue: 100,
+          isCompareMode: true,
+          widgetRecommendedValue: 10,
+          config: Em.Object.create({
+            isOriginalSCP: false,
+            stackConfigProperty: Em.Object.create({
+              valueAttributes: {unit: "B", type: "int", minimum: "1073741824", maximum: "107374182400",
increment_step: "1073741824"},
+              widget: { units: [ { 'unit-name': "GB"}]}
+            })
+          })
+        },
+        e: {
+          ticks: [1, 26, 51, 75, 100],
+          ticksLabels: ["1 GB", "", "51 GB", "", "100 GB"]
+        }
       }
     ];
 
@@ -386,6 +405,9 @@ describe('App.SliderConfigWidgetView', function () {
       it('should generate ticks: {0} - tick labels: {1}'.format(test.e.ticks, test.e.ticksLabels),
function() {
         var ticks, ticksLabels;
         this.view = this.view.create(test.viewSetup);
+        this.view.set('controller', {
+          isCompareMode: test.viewSetup.isCompareMode
+        });
         var sliderCopy= window.Slider.prototype;
         window.Slider = function(a, b) {
           ticks = b.ticks;


Mime
View raw message