Repository: ambari
Updated Branches:
  refs/heads/trunk a471ce2ac -> 662da8077


AMBARI-14755. Timezone change not getting updated on Firefox (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 662da80776c86502049665f435a7c81c26273d44
Parents: a471ce2
Author: Oleg Nechiporenko <onechipore...@apache.org>
Authored: Thu Jan 21 14:27:45 2016 +0200
Committer: Oleg Nechiporenko <onechipore...@apache.org>
Committed: Fri Jan 22 09:57:47 2016 +0200

----------------------------------------------------------------------
 .../global/user_settings_controller.js          | 23 ++++++++++++--------
 ambari-web/test/controllers/main_test.js        |  2 +-
 2 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/662da807/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 5dfe104..5aa64b0 100644
--- a/ambari-web/app/controllers/global/user_settings_controller.js
+++ b/ambari-web/app/controllers/global/user_settings_controller.js
@@ -104,7 +104,7 @@ App.UserSettingsController = 
Em.Controller.extend(App.UserPref, {
    */
   getUserPrefErrorCallback: function (request) {
     // this user is first time login
-    if (404 == request.status) {
+    if (404 === request.status) {
       this.updateUserPrefWithDefaultValues();
     }
   },
@@ -145,12 +145,12 @@ App.UserSettingsController = 
Em.Controller.extend(App.UserPref, {
    * @method updateUserPrefWithDefaultValues
    */
   updateUserPrefWithDefaultValues: function (response, getAllRequest) {
-    response = response || {};
+    var r = response || {};
     var keys = this.get('userSettingsKeys');
     var self = this;
     if (getAllRequest) {
       Object.keys(keys).forEach(function (key) {
-        if (Em.isNone(response[keys[key].name])) {
+        if (Em.isNone(r[keys[key].name])) {
           self.postUserPref(key, keys[key].defaultValue);
         }
       });
@@ -207,6 +207,7 @@ App.UserSettingsController = 
Em.Controller.extend(App.UserPref, {
   },
 
   loadPrivilegesSuccessCallback: function(data) {
+    var key;
     var privileges = {
       clusters: {},
       views: {}
@@ -227,7 +228,7 @@ App.UserSettingsController = 
Em.Controller.extend(App.UserPref, {
     // restructure data for view
     var clusters = [];
     var views = [];
-    for (key in privileges.clusters){
+    for (key in privileges.clusters) {
       clusters.push({
         name: key,
         privileges: privileges.clusters[key]
@@ -303,12 +304,16 @@ App.UserSettingsController = 
Em.Controller.extend(App.UserPref, {
         if (Em.isNone(curValue)) {
           curValue = initValue;
         }
+        var tz = this.get('selectedTimezone.value');
+        var popup = this;
         if (!App.get('testMode')) {
-          self.postUserPref('show_bg', curValue);
-          self.postUserPref('timezone', this.get('selectedTimezone.value'));
-        }
-        if (this.needsPageRefresh()) {
-          location.reload();
+          self.postUserPref('show_bg', curValue).always(function () {
+            self.postUserPref('timezone', tz).always(function () {
+              if (popup.needsPageRefresh()) {
+                location.reload();
+              }
+            });
+          });
         }
         this._super();
       },

http://git-wip-us.apache.org/repos/asf/ambari/blob/662da807/ambari-web/test/controllers/main_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main_test.js 
b/ambari-web/test/controllers/main_test.js
index e367201..b0429b0 100644
--- a/ambari-web/test/controllers/main_test.js
+++ b/ambari-web/test/controllers/main_test.js
@@ -138,7 +138,7 @@ describe('App.MainController', function () {
       var args = testHelpers.findAjaxRequest('name', 'ambari.service');
       expect(args[0]).to.exists;
       expect(args[0].sender).to.be.eql(mainController);
-      
expect(args[0].data.fields).to.be.eql('?fields=RootServiceComponents/component_version,RootServiceComponents/properties/server.os_family&minimal_response=true');
+      
expect(args[0].data.fields).to.be.equal('?fields=RootServiceComponents/component_version,RootServiceComponents/properties/server.os_family&minimal_response=true');
     });
   });
 

Reply via email to