Browse Source

AMBARI-5026 Assigning hosts to Config group takes a minute and Ok button is not greyed out. (atkach)

atkach 11 years ago
parent
commit
4edcf069a1

+ 4 - 2
ambari-web/app/controllers/main/service/manage_config_groups_controller.js

@@ -203,12 +203,13 @@ App.ManageConfigGroupsController = Em.Controller.extend({
   addHostsCallback: function (selectedHosts) {
     var group = this.get('selectedConfigGroup');
     if (selectedHosts) {
-      var defaultHosts = group.get('parentConfigGroup.hosts');
+      var defaultHosts = group.get('parentConfigGroup.hosts').slice();
       var configGroupHosts = group.get('hosts');
       selectedHosts.forEach(function (hostName) {
         configGroupHosts.pushObject(hostName);
         defaultHosts.removeObject(hostName);
       });
+      group.set('parentConfigGroup.hosts', defaultHosts);
     }
   },
 
@@ -220,11 +221,12 @@ App.ManageConfigGroupsController = Em.Controller.extend({
       return;
     }
     var groupHosts = this.get('selectedConfigGroup.hosts');
-    var defaultGroupHosts = this.get('selectedConfigGroup.parentConfigGroup.hosts');
+    var defaultGroupHosts = this.get('selectedConfigGroup.parentConfigGroup.hosts').slice();
     this.get('selectedHosts').slice().forEach(function (hostName) {
       defaultGroupHosts.pushObject(hostName);
       groupHosts.removeObject(hostName);
     });
+    this.set('selectedConfigGroup.parentConfigGroup.hosts', defaultGroupHosts);
     this.set('selectedHosts', []);
   },
 

+ 3 - 2
ambari-web/app/models/config_group.js

@@ -117,11 +117,12 @@ App.ConfigGroup = Ember.Object.extend({
     this.get('parentConfigGroup.hosts').forEach(function (hostName) {
       unusedHostsMap[hostName] = true;
     });
-    App.Host.find().filter(function (host) {
+    App.Host.find().forEach(function (host) {
       if(unusedHostsMap[host.get('id')]) {
         availableHosts.pushObject(Ember.Object.create({
           selected: false,
-          host: host
+          host: host,
+          hostComponentNames: host.get('hostComponents').mapProperty('componentName')
         }));
       }
     });

+ 3 - 7
ambari-web/app/utils/hosts.js

@@ -50,12 +50,8 @@ module.exports = {
       warningMessage: null,
       onPrimary: function () {
         this.set('warningMessage', null);
-        var arrayOfSelectedHosts = [];
-        var selectedHosts = availableHosts.filterProperty('selected', true);
-        selectedHosts.forEach(function (host) {
-          arrayOfSelectedHosts.push(host.get('host.id'));
-        });
-        if (selectAtleastOneHost && arrayOfSelectedHosts.length<1) {
+        var arrayOfSelectedHosts = availableHosts.filterProperty('selected', true).mapProperty('host.id');
+        if (selectAtleastOneHost && arrayOfSelectedHosts.length < 1) {
           this.set('warningMessage', Em.I18n.t('hosts.selectHostsDialog.message.warning'));
           return;
         }
@@ -99,7 +95,7 @@ module.exports = {
           this.get('availableHosts').forEach(function (host) {
             var skip = showOnlySelectedHosts && !host.get('selected');
             var value = host.get('host').get(filterColumn.id);
-            var hostComponentNames = host.get('host.hostComponents').mapProperty('componentName');
+            var hostComponentNames = host.get('hostComponentNames');
 
             host.set('filterColumnValue', value);