ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-8180 Broken Config banner. (atkach)
Date Thu, 06 Nov 2014 11:37:54 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 7aed514bb -> 03d9b19e3


AMBARI-8180 Broken Config banner. (atkach)


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

Branch: refs/heads/branch-1.7.0
Commit: 03d9b19e31d3a225a9f879a31a2cd04d227e60d6
Parents: 7aed514
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Thu Nov 6 13:37:34 2014 +0200
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Thu Nov 6 13:37:34 2014 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 42 ++++++++++++++++----
 ambari-web/app/utils/ajax/ajax.js               |  4 +-
 ambari-web/app/utils/config.js                  |  6 +--
 .../main/service/info/config_test.js            | 12 +++++-
 4 files changed, 50 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/03d9b19e/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 11002c1..bb0cac7 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -35,6 +35,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
     items: [],
     supportsFinal: []
   },
+  requestInProgress: null,
   selectedServiceConfigTypes: [],
   selectedServiceSupportsFinal: [],
   configGroups: [],
@@ -194,9 +195,21 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
   },
 
   /**
+   * register request to view to track his progress
+   * @param request
+   */
+  trackRequest: function (request) {
+    this.set('requestInProgress', request);
+  },
+
+  /**
    * clear and set properties to default value
    */
   clearStep: function () {
+    if (this.get('requestInProgress') && this.get('requestInProgress').readyState
!== 4) {
+      this.get('requestInProgress').abort();
+      this.set('requestInProgress', null);
+    }
     this.set("isApplyingChanges", false);
     this.set('modifiedFileNames', []);
     this.set('isInit', true);
@@ -277,15 +290,16 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
       self.set('configTypesInfo', App.config.getConfigTypesInfoFromService(stackService));
     }
 
-    App.config.loadAdvancedConfig(serviceName, function (properties) {
+    this.trackRequest(App.config.loadAdvancedConfig(serviceName, function (properties, xhr)
{
+      if (xhr.statusText === 'abort') return;
       advancedConfigs.pushObjects(properties);
       self.set('advancedConfigs', advancedConfigs);
       if (App.get('supports.configHistory')) {
-        self.loadServiceConfigVersions();
+        self.trackRequest(self.loadServiceConfigVersions());
       } else {
         self.loadServiceTagsAndGroups();
       }
-    });
+    }));
   },
 
   /**
@@ -321,6 +335,17 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
   },
 
   /**
+   * error callback of loadServiceConfigVersions()
+   * override defaultCallback
+   * @param request
+   * @param ajaxOptions
+   * @param error
+   * @param opt
+   * @param params
+   */
+  loadServiceConfigVersionsError: Em.K,
+
+  /**
    * get selected service config version
    * In case selected version is undefined then take currentDefaultVersion
    * @param version
@@ -338,7 +363,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
       this.set('selectedConfigGroup', switchToGroup);
     }
 
-    App.ajax.send({
+    this.trackRequest(App.ajax.send({
       name: 'service.serviceConfigVersions.get.multiple',
       sender: this,
       data: {
@@ -346,13 +371,14 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
         serviceConfigVersions: versions
       },
       success: 'loadSelectedVersionSuccess'
-    }).complete(function () {
+    }).complete(function (xhr) {
+        if (xhr.statusText === 'abort') return;
         if (self.get('dataIsLoaded')) {
           self.onConfigGroupChange();
         } else {
           self.loadServiceTagsAndGroups();
         }
-      });
+      }));
   },
 
   /**
@@ -401,7 +427,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
    * load config groups of service
    */
   loadServiceTagsAndGroups: function () {
-    App.ajax.send({
+    this.trackRequest(App.ajax.send({
       name: 'config.tags_and_groups',
       sender: this,
       data: {
@@ -409,7 +435,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
         urlParams: "&config_groups/ConfigGroup/tag=" + this.get('content.serviceName')
       },
       success: 'loadServiceConfigsSuccess'
-    });
+    }));
   },
 
   loadServiceConfigsSuccess: function (data, opt, params) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/03d9b19e/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 457e4c0..460dc95 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2085,10 +2085,10 @@ var ajax = Em.Object.extend({
         config.sender[config.beforeSend](opt, xhr, params);
       }
     };
-    opt.success = function (data) {
+    opt.success = function (data, textStatus, request) {
       console.log("TRACE: The url is: " + opt.url);
       if (config.success) {
-        config.sender[config.success](data, opt, params);
+        config.sender[config.success](data, opt, params, request);
       }
     };
     opt.error = function (request, ajaxOptions, error) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/03d9b19e/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index df9f7ca..3cd5b7b 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -927,7 +927,7 @@ App.config = Em.Object.create({
     });
   },
 
-  loadAdvancedConfigSuccess: function (data, opt, params) {
+  loadAdvancedConfigSuccess: function (data, opt, params, request) {
     console.log("TRACE: In success function for the loadAdvancedConfig; url is ", opt.url);
     var properties = [];
     if (data.items.length) {
@@ -961,12 +961,12 @@ App.config = Em.Object.create({
         }
       }, this);
     }
-    params.callback(properties);
+    params.callback(properties, request);
   },
 
   loadAdvancedConfigError: function (request, ajaxOptions, error, opt, params) {
     console.log('ERROR: failed to load stack configs for', params.serviceName);
-    params.callback([]);
+    params.callback([], request);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/03d9b19e/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index 86692e7..269bf43 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -1217,6 +1217,16 @@ describe("App.MainServiceInfoConfigsController", function () {
       expect(mainServiceInfoConfigsController.setCompareDefaultGroupConfig({isReconfigurable:
true, isMock: true}, {})).to.eql({compareConfigs: ["compConfig"], isReconfigurable: true,
isMock: true, isComparison: true, hasCompareDiffs: true});
     });
   });
+
+  describe("#trackRequest()", function () {
+    after(function(){
+      mainServiceInfoConfigsController.set('requestInProgress', null);
+    });
+    it("should set requestInProgress", function () {
+      mainServiceInfoConfigsController.trackRequest({'request': {}});
+      expect(mainServiceInfoConfigsController.get('requestInProgress')).to.eql({'request':
{}});
+    });
+  });
 });
 
 describe("#setCompareDefaultGroupConfig", function() {
@@ -1266,4 +1276,4 @@ describe("#setCompareDefaultGroupConfig", function() {
     });
   });
 
-});
\ No newline at end of file
+});


Mime
View raw message