Repository: ambari
Updated Branches:
  refs/heads/trunk 9f9e89afb -> 51cbf0df6


AMBARI-18407 BE:api/v1/persist/CLUSTER_CURRENT_STATUS takes more than 2s for 
transferring 307KB response. (atkach)


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

Branch: refs/heads/trunk
Commit: 51cbf0df6b6ba6922b236c3a0a4cfa39e3d919e5
Parents: 9f9e89a
Author: Andrii Tkach <atk...@apache.org>
Authored: Thu Sep 15 21:56:50 2016 +0300
Committer: Andrii Tkach <atk...@apache.org>
Committed: Fri Sep 16 12:38:27 2016 +0300

----------------------------------------------------------------------
 .../global/user_settings_controller.js          |  6 ++--
 ambari-web/app/controllers/login_controller.js  |  1 -
 ambari-web/app/router.js                        |  3 +-
 .../views/common/widget/graph_widget_view.js    |  5 ++--
 .../global/user_settings_controller_test.js     | 31 +++++++++++++++++---
 .../test/controllers/login_controller_test.js   |  4 +++
 .../common/widget/graph_widget_view_test.js     |  4 +--
 .../manage_alert_notifications_view_test.js     |  5 ++++
 8 files changed, 44 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/51cbf0df/ambari-web/app/controllers/global/user_settings_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/user_settings_controller.js 
b/ambari-web/app/controllers/global/user_settings_controller.js
index 8bcba75..9580400 100644
--- a/ambari-web/app/controllers/global/user_settings_controller.js
+++ b/ambari-web/app/controllers/global/user_settings_controller.js
@@ -81,13 +81,13 @@ App.UserSettingsController = 
Em.Controller.extend(App.UserPref, {
   /**
    * Success-callback for user pref
    *
-   * @param {*} response
+   * @param {?object} response
    * @param {object} opt
-   * @returns {*}
+   * @returns {?object}
    * @method getUserPrefSuccessCallback
    */
   getUserPrefSuccessCallback: function (response, opt) {
-    var getAllRequest = opt.url.contains('persist/?_');
+    var getAllRequest = opt.url.endsWith('persist/');
     if (Em.isNone(response)) {
       this.updateUserPrefWithDefaultValues(response, getAllRequest);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/51cbf0df/ambari-web/app/controllers/login_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/login_controller.js 
b/ambari-web/app/controllers/login_controller.js
index 24c04f7..350da87 100644
--- a/ambari-web/app/controllers/login_controller.js
+++ b/ambari-web/app/controllers/login_controller.js
@@ -49,7 +49,6 @@ App.LoginController = Em.Object.extend({
       }
       this.set('errorMessage', errorMessage);
     }
-    App.router.get('userSettingsController').dataLoading();
     this.set('isSubmitDisabled', false);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/51cbf0df/ambari-web/app/router.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js
index c7a70f1..0270771 100644
--- a/ambari-web/app/router.js
+++ b/ambari-web/app/router.js
@@ -420,7 +420,6 @@ App.Router = Em.Router.extend({
 
   loginSuccessCallback: function(data, opt, params) {
     var self = this;
-    App.router.set('loginController.isSubmitDisabled', false);
     App.usersMapper.map({"items": [data]});
     this.setUserLoggedIn(data.Users.user_name);
     var requestData = {
@@ -585,7 +584,7 @@ App.Router = Em.Router.extend({
       }
     }
     App.set('isPermissionDataLoaded', true);
-    App.router.get('userSettingsController').dataLoading();
+    App.router.get('loginController').postLogin(true, true);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/51cbf0df/ambari-web/app/views/common/widget/graph_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/widget/graph_widget_view.js 
b/ambari-web/app/views/common/widget/graph_widget_view.js
index 6348077..2ee76be 100644
--- a/ambari-web/app/views/common/widget/graph_widget_view.js
+++ b/ambari-web/app/views/common/widget/graph_widget_view.js
@@ -336,8 +336,9 @@ App.GraphWidgetView = Em.View.extend(App.WidgetMixin, 
App.ExportMetricsMixin, {
     },
 
     loadData: function () {
-      Em.run.next(this, function () {
-        this._refreshGraph(this.get('parentView.data'), 
this.get('parentView'));
+      var self = this;
+      Em.run.next(function () {
+        self._refreshGraph(self.get('parentView.data'), 
self.get('parentView'));
       });
     },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/51cbf0df/ambari-web/test/controllers/global/user_settings_controller_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/global/user_settings_controller_test.js 
b/ambari-web/test/controllers/global/user_settings_controller_test.js
index 849fb2f..5ae17f8 100644
--- a/ambari-web/test/controllers/global/user_settings_controller_test.js
+++ b/ambari-web/test/controllers/global/user_settings_controller_test.js
@@ -17,21 +17,44 @@
  */
 
 var App = require('app');
-var userSettingsController;
 
 describe('App.UserSettingsController', function () {
+  var controller;
 
   beforeEach(function () {
-    userSettingsController = App.UserSettingsController.create();
+    controller = App.UserSettingsController.create();
   });
 
   afterEach(function () {
-    userSettingsController.destroy();
+    controller.destroy();
   });
 
   describe('#userSettingsKeys', function () {
     it('should not be empty', function () {
-      
expect(Object.keys(userSettingsController.get('userSettingsKeys'))).to.have.length.gt(0);
+      
expect(Object.keys(controller.get('userSettingsKeys'))).to.have.length.gt(0);
+    });
+  });
+
+  describe("#getUserPrefSuccessCallback()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'updateUserPrefWithDefaultValues');
+    });
+
+    afterEach(function() {
+      controller.updateUserPrefWithDefaultValues.restore();
+    });
+
+    it("response is null, updateUserPrefWithDefaultValues should be called", 
function() {
+      expect(controller.getUserPrefSuccessCallback(null, {url: 
''})).to.be.null;
+      expect(controller.updateUserPrefWithDefaultValues.calledWith(null, 
false)).to.be.true;
+      expect(controller.get('currentPrefObject')).to.be.null;
+    });
+
+    it("response is correct, updateUserPrefWithDefaultValues should not be 
called", function() {
+      expect(controller.getUserPrefSuccessCallback({}, {url: 
''})).to.be.object;
+      expect(controller.updateUserPrefWithDefaultValues.called).to.be.false;
+      expect(controller.get('currentPrefObject')).to.be.object;
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/51cbf0df/ambari-web/test/controllers/login_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/login_controller_test.js 
b/ambari-web/test/controllers/login_controller_test.js
index 15a310b..eaaf12d 100644
--- a/ambari-web/test/controllers/login_controller_test.js
+++ b/ambari-web/test/controllers/login_controller_test.js
@@ -51,6 +51,10 @@ describe('App.LoginController', function () {
       loginController.postLogin(true, false, 'Login Failed: Please append your 
domain to your username and try again.  Example: user_dup@domain');
       expect(loginController.get('errorMessage')).to.be.equal('Login Failed: 
Please append your domain to your username and try again.  Example: 
user_dup@domain');
     });
+    it ('isSubmitDisabled should be false', function() {
+      loginController.postLogin(true, true);
+      expect(loginController.get('isSubmitDisabled')).to.be.false;
+    });
   });
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/51cbf0df/ambari-web/test/views/common/widget/graph_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/widget/graph_widget_view_test.js 
b/ambari-web/test/views/common/widget/graph_widget_view_test.js
index e19feaf..cceecbd 100644
--- a/ambari-web/test/views/common/widget/graph_widget_view_test.js
+++ b/ambari-web/test/views/common/widget/graph_widget_view_test.js
@@ -762,9 +762,7 @@ describe('App.GraphWidgetView', function () {
     describe("#loadData()", function () {
 
       beforeEach(function() {
-        sinon.stub(Em.run, 'next', function(context, callback) {
-          callback.apply(context);
-        });
+        sinon.stub(Em.run, 'next', Em.clb);
         sinon.stub(graphView, '_refreshGraph');
       });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/51cbf0df/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js 
b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
index 39570dd..bb04a0d 100644
--- a/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
+++ b/ambari-web/test/views/main/alerts/manage_alert_notifications_view_test.js
@@ -115,10 +115,15 @@ describe('App.ManageAlertNotificationsView', function () {
   describe("#onAlertNotificationSelect()", function () {
 
     beforeEach(function () {
+      sinon.stub(Em.run, 'later');
       view.removeObserver('selectedAlertNotification', view, 
'onAlertNotificationSelect');
       view.set('controller', Em.Object.create({selectedAlertNotification: 
null}));
     });
 
+    afterEach(function() {
+      Em.run.later.restore();
+    });
+
     it("selectedAlertNotification is null", function () {
       view.set('selectedAlertNotification', null);
       view.onAlertNotificationSelect();

Reply via email to