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

ambari git commit: AMBARI-9899. Resource Manager Dashboard widget thresholds null after upgrade (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.0 abacc556e -> ebd752b15


AMBARI-9899. Resource Manager Dashboard widget thresholds null after upgrade (alexantonenko)


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

Branch: refs/heads/branch-2.0.0
Commit: ebd752b1587f53894347f0ad8de78f56506cf61d
Parents: abacc55
Author: Alex Antonenko <hi...@gmail.com>
Authored: Wed Mar 4 06:26:22 2015 +0200
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Wed Mar 4 06:26:22 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/views/common/table_view.js          |  8 +++++---
 ambari-web/app/views/main/dashboard/widgets.js     |  9 +++++++++
 .../test/views/main/dashboard/widget_test.js       |  4 ++--
 .../test/views/main/dashboard/widgets_test.js      | 17 ++++++++++++++++-
 4 files changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ebd752b1/ambari-web/app/views/common/table_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/table_view.js b/ambari-web/app/views/common/table_view.js
index b17c011..3f0013c 100644
--- a/ambari-web/app/views/common/table_view.js
+++ b/ambari-web/app/views/common/table_view.js
@@ -86,9 +86,11 @@ App.TableView = Em.View.extend(App.UserPref, {
           self.initFilters();
         });
       } else {
-        this.getUserPref(this.displayLengthKey()).complete(function () {
-          self.initFilters();
-        });
+        if (!$.mocho) {
+          this.getUserPref(this.displayLengthKey()).complete(function () {
+            self.initFilters();
+          });
+        }
       }
     }
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/ebd752b1/ambari-web/app/views/main/dashboard/widgets.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js
index d39c12f..79cf392 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -477,6 +477,15 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage, {
   getUserPrefSuccessCallback: function (response, request, data) {
     if (response) {
       console.log('Got persist value from server with key ' + data.key + '. Value is: ' + response);
+      var initPrefObject = this.get('initPrefObject');
+      initPrefObject.get('threshold');
+      for(var k in response.threshold) {
+        if (response.threshold.hasOwnProperty(k)) {
+          if (response.threshold[k].length === 0 && initPrefObject.get('threshold')[k] && initPrefObject.get('threshold')[k].length) {
+            response.threshold[k] = initPrefObject.get('threshold')[k];
+          }
+        }
+      }
       this.set('currentPrefObject', response);
     }
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/ebd752b1/ambari-web/test/views/main/dashboard/widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widget_test.js b/ambari-web/test/views/main/dashboard/widget_test.js
index b0c249c..0625474 100644
--- a/ambari-web/test/views/main/dashboard/widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widget_test.js
@@ -23,7 +23,7 @@ describe('App.DashboardWidgetView', function () {
   var dashboardWidgetView = App.DashboardWidgetView.create({
     parentView: Em.Object.create({
       widgetsMapper: Em.K,
-      getUserPref: Em.K,
+      getUserPref: function () {return {complete: Em.K}},
       postUserPref: Em.K,
       translateToReal: Em.K,
       visibleWidgets: [],
@@ -404,4 +404,4 @@ describe('App.DashboardWidgetView', function () {
       });
     });
   });
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/ebd752b1/ambari-web/test/views/main/dashboard/widgets_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets_test.js b/ambari-web/test/views/main/dashboard/widgets_test.js
index e02fb7f..0768c77 100644
--- a/ambari-web/test/views/main/dashboard/widgets_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets_test.js
@@ -414,16 +414,31 @@ describe('App.MainDashboardWidgetsView', function () {
   });
 
   describe("#getUserPrefSuccessCallback()", function () {
+
     it("response is null", function () {
       view.set('currentPrefObject', null);
       view.getUserPrefSuccessCallback(null, {}, {});
       expect(view.get('currentPrefObject')).to.be.null;
     });
+
     it("response is correct", function () {
       view.set('currentPrefObject', null);
       view.getUserPrefSuccessCallback({}, {}, {});
       expect(view.get('currentPrefObject')).to.eql({});
     });
+
+    it('should update missing thresholds', function () {
+
+      view.set('currentPrefObject', null);
+      view.getUserPrefSuccessCallback({
+        threshold: {
+          17: []
+        }
+      }, {}, {});
+      expect(view.get('currentPrefObject.threshold')['17']).to.eql([70, 90]);
+
+    });
+
   });
 
   describe("#resetAllWidgets()", function () {
@@ -499,4 +514,4 @@ describe('App.MainDashboardWidgetsView', function () {
     });
 
   });
-});
\ No newline at end of file
+});