Browse Source

Revert "AMBARI-5161 Customize Services step load: change calls to asynchronous. (atkach)"

This reverts commit b6b56cfeb600cd1be788245843f57ed2c6306072.
Yusaku Sako 11 years ago
parent
commit
6cb293b27f

+ 9 - 16
ambari-web/app/controllers/wizard.js

@@ -691,23 +691,16 @@ App.WizardController = Em.Controller.extend({
   /**
   /**
    * load advanced configs from server
    * load advanced configs from server
    */
    */
-  loadAdvancedConfigs: function (dependentController) {
-    var self = this;
-    var counter = this.get('content.services').filterProperty('isSelected').length;
-    var loadAdvancedConfigResult = [];
-    dependentController.set('isAdvancedConfigLoaded', false);
-    this.get('content.services').filterProperty('isSelected').mapProperty('serviceName').forEach(function (_serviceName) {
-      App.config.loadAdvancedConfig(_serviceName, function(properties){
-        loadAdvancedConfigResult.pushObjects(properties);
-        counter--;
-        //pass configs to controller after last call is completed
-        if (counter === 0) {
-          self.set('content.advancedServiceConfig', loadAdvancedConfigResult);
-          self.setDBProperty('advancedServiceConfig', loadAdvancedConfigResult);
-          dependentController.set('isAdvancedConfigLoaded', true);
-        }
-      });
+  loadAdvancedConfigs: function () {
+    var configs = (this.getDBProperty('advancedServiceConfig')) ? this.getDBProperty('advancedServiceConfig') : [];
+    this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName').forEach(function (_serviceName) {
+      var serviceComponents = App.config.loadAdvancedConfig(_serviceName);
+      if (serviceComponents) {
+        configs = configs.concat(serviceComponents);
+      }
     }, this);
     }, this);
+    this.set('content.advancedServiceConfig', configs);
+    this.setDBProperty('advancedServiceConfig', configs);
   },
   },
   /**
   /**
    * Load serviceConfigProperties to model
    * Load serviceConfigProperties to model

+ 1 - 7
ambari-web/app/controllers/wizard/step7_controller.js

@@ -62,8 +62,6 @@ App.WizardStep7Controller = Em.Controller.extend({
 
 
   serviceConfigsData: require('data/service_configs'),
   serviceConfigsData: require('data/service_configs'),
 
 
-  isAdvancedConfigLoaded: true,
-
   isSubmitDisabled: function () {
   isSubmitDisabled: function () {
     return (!this.stepConfigs.filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible"));
     return (!this.stepConfigs.filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible"));
   }.property('stepConfigs.@each.errorCount', 'miscModalVisible'),
   }.property('stepConfigs.@each.errorCount', 'miscModalVisible'),
@@ -344,9 +342,6 @@ App.WizardStep7Controller = Em.Controller.extend({
    */
    */
   loadStep: function () {
   loadStep: function () {
     console.log("TRACE: Loading step7: Configure Services");
     console.log("TRACE: Loading step7: Configure Services");
-    if (!this.get('isAdvancedConfigLoaded')) {
-      return;
-    }
     this.clearStep();
     this.clearStep();
     //STEP 1: Load advanced configs
     //STEP 1: Load advanced configs
     var advancedConfigs = this.get('content.advancedServiceConfig');
     var advancedConfigs = this.get('content.advancedServiceConfig');
@@ -408,8 +403,7 @@ App.WizardStep7Controller = Em.Controller.extend({
     if (this.get('content.skipConfigStep')) {
     if (this.get('content.skipConfigStep')) {
       App.router.send('next');
       App.router.send('next');
     }
     }
-  }.observes('isAdvancedConfigLoaded'),
-
+  },
   getConfigTags: function() {
   getConfigTags: function() {
     App.ajax.send({
     App.ajax.send({
       name: 'config.tags.sync',
       name: 'config.tags.sync',

+ 2 - 2
ambari-web/app/routes/add_service_routes.js

@@ -185,9 +185,9 @@ module.exports = App.WizardRoute.extend({
       var controller = router.get('addServiceController');
       var controller = router.get('addServiceController');
       controller.setCurrentStep('4');
       controller.setCurrentStep('4');
       controller.dataLoading().done(function () {
       controller.dataLoading().done(function () {
-        var wizardStep7Controller = router.get('wizardStep7Controller');
         controller.loadAllPriorSteps();
         controller.loadAllPriorSteps();
-        controller.loadAdvancedConfigs(wizardStep7Controller);
+        controller.loadAdvancedConfigs();
+        var wizardStep7Controller = router.get('wizardStep7Controller');
         wizardStep7Controller.set('wizardController', controller);
         wizardStep7Controller.set('wizardController', controller);
         controller.connectOutlet('wizardStep7', controller.get('content'));
         controller.connectOutlet('wizardStep7', controller.get('content'));
       })
       })

+ 1 - 2
ambari-web/app/routes/installer.js

@@ -280,7 +280,6 @@ module.exports = Em.Route.extend({
     next: function (router) {
     next: function (router) {
       var controller = router.get('installerController');
       var controller = router.get('installerController');
       var wizardStep6Controller = router.get('wizardStep6Controller');
       var wizardStep6Controller = router.get('wizardStep6Controller');
-      var wizardStep7Controller = router.get('wizardStep7Controller');
 
 
       if (wizardStep6Controller.validate()) {
       if (wizardStep6Controller.validate()) {
         controller.saveSlaveComponentHosts(wizardStep6Controller);
         controller.saveSlaveComponentHosts(wizardStep6Controller);
@@ -288,7 +287,7 @@ module.exports = Em.Route.extend({
         controller.setDBProperty('serviceConfigProperties', null);
         controller.setDBProperty('serviceConfigProperties', null);
         controller.setDBProperty('advancedServiceConfig', null);
         controller.setDBProperty('advancedServiceConfig', null);
         controller.setDBProperty('serviceConfigGroups', null);
         controller.setDBProperty('serviceConfigGroups', null);
-        controller.loadAdvancedConfigs(wizardStep7Controller);
+        controller.loadAdvancedConfigs();
         router.transitionTo('step7');
         router.transitionTo('step7');
       }
       }
     }
     }

+ 1 - 6
ambari-web/app/templates/wizard/step7.hbs

@@ -23,12 +23,7 @@
       {{t installer.step7.body}}
       {{t installer.step7.body}}
     </div>
     </div>
 
 
-    {{#if isAdvancedConfigLoaded}}
-      {{view App.ServicesConfigView}}
-    {{else}}
-      <div class="spinner"></div>
-    {{/if}}
-
+    {{view App.ServicesConfigView}}
 
 
     <div class="btn-area">
     <div class="btn-area">
         <a class="btn" {{action back}}>&larr; {{t common.back}}</a>
         <a class="btn" {{action back}}>&larr; {{t common.back}}</a>

+ 6 - 1
ambari-web/app/utils/ajax.js

@@ -299,7 +299,12 @@ var urls = {
 
 
   'config.advanced': {
   'config.advanced': {
     'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*',
     'real': '{stack2VersionUrl}/stackServices/{serviceName}/configurations?fields=*',
-    'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json'
+    'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json',
+    'format': function() {
+      return {
+        async: false
+      };
+    }
   },
   },
   'config.advanced.global': {
   'config.advanced.global': {
     'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/type',
     'real': '{stack2VersionUrl}/stackServices?fields=configurations/StackConfigurations/type',

+ 7 - 11
ambari-web/app/utils/config.js

@@ -20,6 +20,7 @@ var App = require('app');
 var stringUtils = require('utils/string_utils');
 var stringUtils = require('utils/string_utils');
 
 
 var categotyConfigs = require('data/service_configs');
 var categotyConfigs = require('data/service_configs');
+var serviceComponents = {};
 var configGroupsByTag = [];
 var configGroupsByTag = [];
 
 
 App.config = Em.Object.create({
 App.config = Em.Object.create({
@@ -750,19 +751,19 @@ App.config = Em.Object.create({
    * @param serviceName
    * @param serviceName
    * @return {*}
    * @return {*}
    */
    */
-  loadAdvancedConfig: function (serviceName, callback) {
+  loadAdvancedConfig: function (serviceName) {
     App.ajax.send({
     App.ajax.send({
       name: 'config.advanced',
       name: 'config.advanced',
       sender: this,
       sender: this,
       data: {
       data: {
         serviceName: serviceName,
         serviceName: serviceName,
         stack2VersionUrl: App.get('stack2VersionURL'),
         stack2VersionUrl: App.get('stack2VersionURL'),
-        stackVersion: App.get('currentStackVersionNumber'),
-        callback: callback
+        stackVersion: App.get('currentStackVersionNumber')
       },
       },
-      success: 'loadAdvancedConfigSuccess',
-      error: 'loadAdvancedConfigError'
+      success: 'loadAdvancedConfigSuccess'
     });
     });
+    return serviceComponents[serviceName];
+    //TODO clean serviceComponents
   },
   },
 
 
   loadAdvancedConfigSuccess: function (data, opt, params) {
   loadAdvancedConfigSuccess: function (data, opt, params) {
@@ -792,13 +793,8 @@ App.config = Em.Object.create({
           });
           });
         }
         }
       }, this);
       }, this);
+      serviceComponents[data.items[0].StackConfigurations.service_name] = properties;
     }
     }
-    params.callback(properties);
-  },
-
-  loadAdvancedConfigError: function (request, ajaxOptions, error, opt, params) {
-    console.log('ERROR: failed to load stack configs for', params.serviceName);
-    params.callback([]);
   },
   },
 
 
   /**
   /**