This is an automated email from the ASF dual-hosted git repository.

akovalenko pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by 
this push:
     new 3a7fb23  Fixed additional instance of the same API call being used. 
(#675)
3a7fb23 is described below

commit 3a7fb237794b7450b4d9ab79d2834126888612e5
Author: Jason Golieb <[email protected]>
AuthorDate: Tue Apr 3 09:19:17 2018 -0400

    Fixed additional instance of the same API call being used. (#675)
---
 .../app/controllers/global/update_controller.js    | 47 +++++++++++----------
 .../controllers/main/admin/service_auto_start.js   | 48 ++++++++++++----------
 .../app/controllers/wizard/step8_controller.js     |  2 +-
 ambari-web/app/utils/ajax/ajax.js                  |  8 ++--
 .../controllers/global/update_controller_test.js   |  6 +--
 .../main/admin/service_auto_start_test.js          | 13 +++---
 6 files changed, 64 insertions(+), 60 deletions(-)

diff --git a/ambari-web/app/controllers/global/update_controller.js 
b/ambari-web/app/controllers/global/update_controller.js
index 94c5466..6c3b0eb 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -626,33 +626,36 @@ App.UpdateController = Em.Controller.extend({
   },
 
   //TODO - update service auto-start to use this
-  updateClusterEnv: function (callback) {
-    this.loadClusterConfig(callback).done(function (data) {
-      var tag = [
-        {
-          siteName: 'cluster-env',
-          tagName: data.Clusters.desired_configs['cluster-env'].tag,
-          newTagName: null
-        }
-      ];
-      
App.router.get('configurationController').getConfigsByTags(tag).done(function 
(config) {
-        App.router.get('clusterController').set('clusterEnv', config[0]);
-      });
+  updateClusterEnv: function () {
+    this.loadClusterSettings().then(function (settings) {
+      App.router.get('clusterController').set('clusterEnv', { properties: 
settings });
     });
   },
 
-  loadClusterConfig: function (callback) {
-    return App.ajax.send({
-      name: 'config.tags.site',
-      sender: this,
-      data: {
-        site: 'cluster-env'
-      },
-      callback: callback
-    });
+  loadClusterSettings: function () {
+    const dfd = $.Deferred();
+
+    App.ajax.send({
+      name: 'common.cluster.settings',
+      sender: this
+    }).then(data => {
+      const settings = {};
+      
+      if (data && data.items) {
+        data.items.forEach(item => {
+          const key = item.ClusterSettingInfo.cluster_setting_name;
+          const value = item.ClusterSettingInfo.cluster_setting_value;
+          settings[key] = value;
+        });
+      }
+      
+      dfd.resolve(settings);
+    }, dfd.reject);
+    
+    return dfd.promise();
   },
 
-  updateWizardWatcher: function(callback) {
+  updateWizardWatcher: function (callback) {
     App.router.get('wizardWatcherController').getUser().complete(callback);
   },
 
diff --git a/ambari-web/app/controllers/main/admin/service_auto_start.js 
b/ambari-web/app/controllers/main/admin/service_auto_start.js
index 80b6e50..79dec3b 100644
--- a/ambari-web/app/controllers/main/admin/service_auto_start.js
+++ b/ambari-web/app/controllers/main/admin/service_auto_start.js
@@ -112,33 +112,37 @@ App.MainAdminServiceAutoStartController = 
Em.Controller.extend({
   },
 
   load: function() {
-    this.loadClusterConfig().done((data) => {
-      const tag = [
-        {
-          siteName: 'cluster-env',
-          tagName: data.Clusters.desired_configs['cluster-env'].tag,
-          newTagName: null
-        }
-      ];
-      
App.router.get('configurationController').getConfigsByTags(tag).done((data) => {
-        this.set('clusterConfigs', data[0].properties);
-        this.set('isGeneralRecoveryEnabled', 
data[0].properties.recovery_enabled === 'true');
-        this.set('isGeneralRecoveryEnabledCached', 
this.get('isGeneralRecoveryEnabled'));
-        this.loadComponentsConfigs().then(() => {
-          this.set('isLoaded', true);
-        });
+    this.loadClusterSettings().done(function (settings) {
+      this.set('clusterConfigs', settings);
+      this.set('isGeneralRecoveryEnabled', settings.recovery_enabled === 
'true');
+      this.set('isGeneralRecoveryEnabledCached', 
this.get('isGeneralRecoveryEnabled'));
+      this.loadComponentsConfigs().then(() => {
+        this.set('isLoaded', true);
       });
     });
   },
 
-  loadClusterConfig: function () {
-    return App.ajax.send({
-      name: 'config.tags.site',
-      sender: this,
-      data: {
-        site: 'cluster-env'
+  loadClusterSettings: function () {
+    const dfd = $.Deferred();
+
+    App.ajax.send({
+      name: 'common.cluster.settings',
+      sender: this
+    }).then(data => {
+      const settings = {};
+      
+      if (data && data.items) {
+        data.items.forEach(item => {
+          const key = item.ClusterSettingInfo.cluster_setting_name;
+          const value = item.ClusterSettingInfo.cluster_setting_value;
+          settings[key] = value;
+        });
       }
-    });
+      
+      dfd.resolve(settings);
+    }, dfd.reject);
+    
+    return dfd.promise();
   },
 
   loadComponentsConfigs: function () {
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js 
b/ambari-web/app/controllers/wizard/step8_controller.js
index d1bc85a..86b0c3f 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1520,7 +1520,7 @@ App.WizardStep8Controller = 
App.WizardStepController.extend(App.AddSecurityConfi
     });
 
     this.addRequestToAjaxQueue({
-      name: 'common.cluster.settings',
+      name: 'common.cluster.settings.create',
       data: {
         clusterName: this.get('clusterName'),
         data: data
diff --git a/ambari-web/app/utils/ajax/ajax.js 
b/ambari-web/app/utils/ajax/ajax.js
index bea8617..4d70854 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -43,6 +43,10 @@ var urls = {
   },
 
   'common.cluster.settings' : {
+    'real': 
'/clusters/{clusterName}/settings/?fields=ClusterSettingInfo/cluster_setting_name,ClusterSettingInfo/cluster_setting_value',
+  },
+
+  'common.cluster.settings.create' : {
     'type': 'POST',
     'real': '/clusters/{clusterName}/settings',
     'format': function (data) {
@@ -849,10 +853,6 @@ var urls = {
     'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
     'mock': '/data/clusters/cluster.json'
   },
-  'config.tags.site': {
-    'real': '/clusters/{clusterName}?fields=Clusters/desired_configs/{site}',
-    'mock': ''
-  },
   'config.tags_and_groups': {
     'real': 
'/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*{urlParams}',
     'mock': '/data/clusters/tags_and_groups.json'
diff --git a/ambari-web/test/controllers/global/update_controller_test.js 
b/ambari-web/test/controllers/global/update_controller_test.js
index 6165af9..62a6bb1 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -519,11 +519,11 @@ describe('App.UpdateController', function () {
     });
   });
 
-  describe('#loadClusterConfig()', function() {
+  describe('#loadClusterSettings()', function() {
 
     it('App.ajax.send should be called', function() {
-      c.loadClusterConfig();
-      var args = testHelpers.findAjaxRequest('name', 'config.tags.site');
+      c.loadClusterSettings();
+      var args = testHelpers.findAjaxRequest('name', 
'common.cluster.settings');
       expect(args).to.exists;
     });
   });
diff --git a/ambari-web/test/controllers/main/admin/service_auto_start_test.js 
b/ambari-web/test/controllers/main/admin/service_auto_start_test.js
index 2fb1894..55f1809 100644
--- a/ambari-web/test/controllers/main/admin/service_auto_start_test.js
+++ b/ambari-web/test/controllers/main/admin/service_auto_start_test.js
@@ -125,17 +125,14 @@ describe('App.MainAdminServiceAutoStartController', 
function() {
     });
   });
 
-  describe('#loadClusterConfig()', function() {
+  describe('#loadClusterSettings()', function() {
 
     it('App.ajax.send should be called', function() {
-      controller.loadClusterConfig();
-      var args = testHelpers.findAjaxRequest('name', 'config.tags.site');
+      controller.loadClusterSettings();
+      var args = testHelpers.findAjaxRequest('name', 
'common.cluster.settings');
       expect(args[0]).to.be.eql({
-        name: 'config.tags.site',
-        sender: controller,
-        data: {
-          site: 'cluster-env'
-        }
+        name: 'common.cluster.settings',
+        sender: controller
       });
     });
   });

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to