You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2015/10/08 14:08:12 UTC

ambari git commit: AMBARI-13353 Add Service wizard: Browser refresh on Assign Master page loses all installed service components. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 7d40f5da3 -> 7ae6e4892


AMBARI-13353 Add Service wizard: Browser refresh on Assign Master page loses all installed service components. (atkach)


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

Branch: refs/heads/branch-2.1
Commit: 7ae6e48929af996cd53c8b2532f7caaf6bb8ea28
Parents: 7d40f5d
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Thu Oct 8 13:34:50 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Thu Oct 8 15:07:43 2015 +0300

----------------------------------------------------------------------
 .../mixins/wizard/assign_master_components.js   | 76 +++++++++-----------
 1 file changed, 33 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7ae6e489/ambari-web/app/mixins/wizard/assign_master_components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/assign_master_components.js b/ambari-web/app/mixins/wizard/assign_master_components.js
index d416c35..7dc267e 100644
--- a/ambari-web/app/mixins/wizard/assign_master_components.js
+++ b/ambari-web/app/mixins/wizard/assign_master_components.js
@@ -649,76 +649,66 @@ App.AssignMasterComponents = Em.Mixin.create({
    * @return {Object[]}
    */
   createComponentInstallationObjects: function() {
-    var self = this;
-
-    var masterComponents = [];
-    if (self.get('isInstallerWizard')) {
-      masterComponents = App.StackServiceComponent.find().filterProperty('isShownOnInstallerAssignMasterPage');
-    } else {
-      masterComponents = App.StackServiceComponent.find().filter(function(component){
-        return component.get('isShownOnAddServiceAssignMasterPage') || self.get('mastersToShow').contains(component.get('componentName'));
-      });
-    }
-    var masterComponentsMap = {};
-    masterComponents.forEach(function(masterComponent) {
-      masterComponentsMap[masterComponent.get('componentName')] = masterComponent;
-    });
-
-    var masterHosts = self.get('content.masterComponentHosts'); //saved to local storage info
-    var selectedNotInstalledServices = self.get('content.services').filterProperty('isSelected').filterProperty('isInstalled', false).mapProperty('serviceName');
-    var recommendations = this.get('content.recommendations');
-
-    var resultComponents = [];
-    var multipleComponentHasBeenAdded = {};
-
-    var existingHostComponentsMap = {};
-    App.HostComponent.find().forEach(function(c) {
-      existingHostComponentsMap[c.get('componentName')] = c;
-    });
+    var stackMasterComponentsMap = {},
+        masterHosts = this.get('content.masterComponentHosts'), //saved to local storage info
+        servicesToAdd = this.get('content.services').filterProperty('isSelected').filterProperty('isInstalled', false).mapProperty('serviceName'),
+        recommendations = this.get('content.recommendations'),
+        resultComponents = [],
+        multipleComponentHasBeenAdded = {},
+        hostGroupsMap = {};
+
+    App.StackServiceComponent.find().forEach(function(component) {
+      if (this.get('isInstallerWizard')) {
+        if (component.get('isShownOnInstallerAssignMasterPage')) {
+          stackMasterComponentsMap[component.get('componentName')] = component;
+        }
+      } else {
+        if (component.get('isShownOnAddServiceAssignMasterPage') || this.get('mastersToShow').contains(component.get('componentName'))) {
+          stackMasterComponentsMap[component.get('componentName')] = component;
+        }
+      }
+    }, this);
 
-    var hostGroupsMap = {};
     recommendations.blueprint_cluster_binding.host_groups.forEach(function(group) {
       hostGroupsMap[group.name] = group;
     });
+
     recommendations.blueprint.host_groups.forEach(function(host_group) {
       var hosts = hostGroupsMap[host_group.name] ? hostGroupsMap[host_group.name].hosts : [];
 
       hosts.forEach(function(host) {
         host_group.components.forEach(function(component) {
-          var willBeAdded = true;
-          //var fullComponent = masterComponents.findProperty('componentName', component.name);
-          var fullComponent = masterComponentsMap[component.name];
-          // If it's master component which should be shown
-          if (fullComponent) {
+          var willBeDisplayed = true;
+          var stackMasterComponent = stackMasterComponentsMap[component.name];
+          if (stackMasterComponent) {
             // If service is already installed and not being added as a new service then render on UI only those master components
             // that have already installed hostComponents.
             // NOTE: On upgrade there might be a prior installed service with non-installed newly introduced serviceComponent
-            var isNotSelectedService = !selectedNotInstalledServices.contains(fullComponent.get('serviceName'));
-            if (isNotSelectedService) {
-              willBeAdded = existingHostComponentsMap[component.name];
+            if (!servicesToAdd.contains(stackMasterComponent.get('serviceName'))) {
+              willBeDisplayed = masterHosts.someProperty('component', component.name);
             }
 
-            if (willBeAdded) {
+            if (willBeDisplayed) {
               var savedComponents = masterHosts.filterProperty('component', component.name);
 
-              if (self.get('multipleComponents').contains(component.name) && savedComponents.length > 0) {
+              if (this.get('multipleComponents').contains(component.name) && savedComponents.length > 0) {
                 if (!multipleComponentHasBeenAdded[component.name]) {
                   multipleComponentHasBeenAdded[component.name] = true;
 
                   savedComponents.forEach(function(saved) {
-                    resultComponents.push(self.createComponentInstallationObject(fullComponent, host.fqdn.toLowerCase(), saved));
-                  });
+                    resultComponents.push(this.createComponentInstallationObject(stackMasterComponent, host.fqdn.toLowerCase(), saved));
+                  }, this);
                 }
               }
               else {
                 var savedComponent = masterHosts.findProperty('component', component.name);
-                resultComponents.push(self.createComponentInstallationObject(fullComponent, host.fqdn.toLowerCase(), savedComponent));
+                resultComponents.push(this.createComponentInstallationObject(stackMasterComponent, host.fqdn.toLowerCase(), savedComponent));
               }
             }
           }
-        });
-      });
-    });
+        }, this);
+      }, this);
+    }, this);
     return resultComponents;
   },