Browse Source

AMBARI-11533. Add Host Wizard Configuration Page confusing with duplicate HDFS lines (alexantonenko)

Alex Antonenko 10 years ago
parent
commit
f4db014284

+ 14 - 9
ambari-web/app/controllers/main/host/add_controller.js

@@ -122,7 +122,7 @@ App.AddHostController = App.WizardController.extend({
     this.set('content.services', App.StackService.find());
   },
 
-  /**
+ /**
    * Load slave component hosts data for using in required step controllers
    * TODO move to mixin
    */
@@ -264,15 +264,20 @@ App.AddHostController = App.WizardController.extend({
             var configGroups = this.get('content.configGroups').filterProperty('ConfigGroup.tag', serviceName);
             var configGroupsNames = configGroups.mapProperty('ConfigGroup.group_name');
             var defaultGroupName = service.get('displayName') + ' Default';
+            var selectedService = selectedServices.findProperty('serviceId', serviceName);
             configGroupsNames.unshift(defaultGroupName);
-            selectedServices.push({
-              serviceId: serviceName,
-              displayName: service.get('displayName'),
-              hosts: slave.hosts.mapProperty('hostName'),
-              configGroupsNames: configGroupsNames,
-              configGroups: configGroups,
-              selectedConfigGroup: defaultGroupName
-            });
+            if (selectedService) {
+              Em.set(selectedService, 'hosts', Em.getWithDefault(selectedService, 'hosts', []).concat(slave.hosts.mapProperty('hostName')).uniq());
+            } else {
+              selectedServices.push({
+                serviceId: serviceName,
+                displayName: service.get('displayName'),
+                hosts: slave.hosts.mapProperty('hostName'),
+                configGroupsNames: configGroupsNames,
+                configGroups: configGroups,
+                selectedConfigGroup: defaultGroupName
+              });
+            }
           }
         }
       }, this);

+ 9 - 2
ambari-web/test/controllers/main/host/add_controller_test.js

@@ -912,15 +912,22 @@ describe('App.AddHostController', function () {
             {hostName: 'host1'}
           ],
           componentName: 'C1'
+        },
+        {
+          hosts: [
+            {hostName: 'host2'}
+          ],
+          componentName: 'C2'
         }
       ]);
       expect(controller.loadServiceConfigGroupsBySlaves(selectedServices)).to.be.true;
-      expect(selectedServices).to.eql([
+      expect(selectedServices.toArray()).to.eql([
         {
           "serviceId": "S1",
           "displayName": "s1",
           "hosts": [
-            "host1"
+            "host1",
+            "host2"
           ],
           "configGroupsNames": [
             "s1 Default",