Forráskód Böngészése

AMBARI-12764. ASW. Assign Masters Page. Click "+" takes 3 seconds (only JS processing) to display combobox with new component's host (onechiporenko)

Oleg Nechiporenko 10 éve
szülő
commit
5ea12f0647

+ 9 - 5
ambari-web/app/mixins/common/blueprint.js

@@ -18,14 +18,18 @@
 
 var App = require('app');
 var blueprintUtils = require('utils/blueprint');
+var dataManipulation = require('utils/data_manipulation');
 
 App.BlueprintMixin = Em.Mixin.create({
+
   /**
-   * returns blueprint for all currenlty installed master, slave and client components
+   * returns blueprint for all currently installed master, slave and client components
+   * @method getCurrentMasterSlaveBlueprint
    */
   getCurrentMasterSlaveBlueprint: function () {
     var components = App.HostComponent.find();
     var hosts = components.mapProperty("hostName").uniq();
+    var mappedComponents = dataManipulation.groupPropertyValues(components, 'hostName');
 
     var res = {
       blueprint: { host_groups: [] },
@@ -33,13 +37,13 @@ App.BlueprintMixin = Em.Mixin.create({
     };
 
     hosts.forEach(function (host, i) {
-      var group_name = 'host-group-' + (i+1);
+      var group_name = 'host-group-' + (i + 1);
 
       res.blueprint.host_groups.push({
         name: group_name,
-        components: components.filterProperty("hostName", host).mapProperty("componentName").map(function (c) {
-          return { name: c };
-        })
+        components: mappedComponents[host] ? mappedComponents[host].map(function (c) {
+          return { name: Em.get(c, 'componentName') };
+        }) : []
       });
 
       res.blueprint_cluster_binding.host_groups.push({

+ 11 - 8
ambari-web/app/mixins/wizard/assign_master_components.js

@@ -597,9 +597,9 @@ App.AssignMasterComponents = Em.Mixin.create({
 
   /**
    * Get recommendations info from API
-   * @return {undefined}
-   * @param function(componentInstallationobjects, this) callback
-   * @param bool includeMasters
+   * @param {function}callback
+   * @param {boolean} includeMasters
+   * @method loadComponentsRecommendationsFromServer
    */
   loadComponentsRecommendationsFromServer: function(callback, includeMasters) {
     var self = this;
@@ -608,7 +608,8 @@ App.AssignMasterComponents = Em.Mixin.create({
       // Don't do AJAX call if recommendations has been already received
       // But if user returns to previous step (selecting services), stored recommendations will be cleared in routers' next handler and AJAX call will be made again
       callback(self.createComponentInstallationObjects(), self);
-    } else {
+    }
+    else {
       var selectedServices = App.StackService.find().filterProperty('isSelected').mapProperty('serviceName');
       var installedServices = App.StackService.find().filterProperty('isInstalled').mapProperty('serviceName');
       var services = installedServices.concat(selectedServices).uniq();
@@ -625,9 +626,11 @@ App.AssignMasterComponents = Em.Mixin.create({
       if (includeMasters) {
         // Made partial recommendation request for reflect in blueprint host-layout changes which were made by user in UI
         data.recommendations = self.getCurrentBlueprint();
-      } else if (!self.get('isInstallerWizard')) {
-        data.recommendations = self.getCurrentMasterSlaveBlueprint();
       }
+      else
+        if (!self.get('isInstallerWizard')) {
+          data.recommendations = self.getCurrentMasterSlaveBlueprint();
+        }
 
       return App.ajax.send({
         name: 'wizard.loadrecommendations',
@@ -636,8 +639,8 @@ App.AssignMasterComponents = Em.Mixin.create({
         success: 'loadRecommendationsSuccessCallback',
         error: 'loadRecommendationsErrorCallback'
       }).then(function () {
-            callback(self.createComponentInstallationObjects(), self);
-          });
+          callback(self.createComponentInstallationObjects(), self);
+        });
     }
   },