Browse Source

AMBARI-6220. Step 7. Create config group popup freeze UI. (onechiporenko)

Oleg Nechiporenko 11 years ago
parent
commit
965696b386

+ 37 - 10
ambari-web/app/controllers/installer.js

@@ -391,11 +391,8 @@ App.InstallerController = App.WizardController.extend({
    * @param stepController App.WizardStep4Controller
    * @param stepController App.WizardStep4Controller
    */
    */
   saveServices: function (stepController) {
   saveServices: function (stepController) {
-    var serviceNames = [];
     this.setDBProperty('service', stepController.get('content'));
     this.setDBProperty('service', stepController.get('content'));
-    stepController.filterProperty('isSelected', true).forEach(function (item) {
-      serviceNames.push(item.serviceName);
-    });
+    var serviceNames = stepController.filterProperty('isSelected', true).mapProperty('serviceName');
     this.set('content.selectedServiceNames', serviceNames);
     this.set('content.selectedServiceNames', serviceNames);
     this.setDBProperty('selectedServiceNames', serviceNames);
     this.setDBProperty('selectedServiceNames', serviceNames);
     console.log('installerController.saveServices: saved data ', serviceNames);
     console.log('installerController.saveServices: saved data ', serviceNames);
@@ -406,16 +403,18 @@ App.InstallerController = App.WizardController.extend({
    * @param stepController App.WizardStep5Controller
    * @param stepController App.WizardStep5Controller
    */
    */
   saveMasterComponentHosts: function (stepController) {
   saveMasterComponentHosts: function (stepController) {
-    var obj = stepController.get('selectedServicesMasters');
+
+    var obj = stepController.get('selectedServicesMasters'),
+      hosts = this.getDBProperty('hosts');
 
 
     var masterComponentHosts = [];
     var masterComponentHosts = [];
     obj.forEach(function (_component) {
     obj.forEach(function (_component) {
       masterComponentHosts.push({
       masterComponentHosts.push({
         display_name: _component.get('display_name'),
         display_name: _component.get('display_name'),
         component: _component.get('component_name'),
         component: _component.get('component_name'),
-        hostName: _component.get('selectedHost'),
         serviceId: _component.get('serviceId'),
         serviceId: _component.get('serviceId'),
-        isInstalled: false
+        isInstalled: false,
+        host_id: hosts[_component.get('selectedHost')].id
       });
       });
     });
     });
 
 
@@ -428,16 +427,44 @@ App.InstallerController = App.WizardController.extend({
    * Load master component hosts data for using in required step controllers
    * Load master component hosts data for using in required step controllers
    */
    */
   loadMasterComponentHosts: function () {
   loadMasterComponentHosts: function () {
-    var masterComponentHosts = this.getDBProperty('masterComponentHosts') || [];
+    var masterComponentHosts = this.getDBProperty('masterComponentHosts'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (Em.isNone(masterComponentHosts)) {
+      masterComponentHosts = [];
+    }
+    else {
+      masterComponentHosts.forEach(function(component) {
+        for (var i = 0; i < host_names.length; i++) {
+          if (hosts[host_names[i]].id === component.host_id) {
+            component.hostName = host_names[i];
+            break;
+          }
+        }
+      });
+    }
     this.set("content.masterComponentHosts", masterComponentHosts);
     this.set("content.masterComponentHosts", masterComponentHosts);
-    console.log("InstallerController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
   },
   },
 
 
   /**
   /**
    * Load master component hosts data for using in required step controllers
    * Load master component hosts data for using in required step controllers
    */
    */
   loadSlaveComponentHosts: function () {
   loadSlaveComponentHosts: function () {
-    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts') || null;
+    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (!Em.isNone(slaveComponentHosts)) {
+      slaveComponentHosts.forEach(function(component) {
+        component.hosts.forEach(function(host) {
+          for (var i = 0; i < host_names.length; i++) {
+            if (hosts[host_names[i]].id === host.host_id) {
+              host.hostName = host_names[i];
+              break;
+            }
+          }
+        });
+      });
+    }
     this.set("content.slaveComponentHosts", slaveComponentHosts);
     this.set("content.slaveComponentHosts", slaveComponentHosts);
     console.log("InstallerController.loadSlaveComponentHosts: loaded hosts ", slaveComponentHosts);
     console.log("InstallerController.loadSlaveComponentHosts: loaded hosts ", slaveComponentHosts);
   },
   },

+ 16 - 1
ambari-web/app/controllers/main/host/add_controller.js

@@ -143,7 +143,22 @@ App.AddHostController = App.WizardController.extend({
    * TODO move to mixin
    * TODO move to mixin
    */
    */
   loadSlaveComponentHosts: function () {
   loadSlaveComponentHosts: function () {
-    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts');
+    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (!Em.isNone(slaveComponentHosts)) {
+      slaveComponentHosts.forEach(function(component) {
+        component.hosts.forEach(function(host) {
+          //Em.set(host, 'hostName', hosts[host.host_id].name);
+          for (var i = 0; i < host_names.length; i++) {
+            if (hosts[host_names[i]].id === host.host_id) {
+              host.hostName = host_names[i];
+              break;
+            }
+          }
+        });
+      });
+    }
     if (!slaveComponentHosts) {
     if (!slaveComponentHosts) {
       slaveComponentHosts = this.getSlaveComponentHosts();
       slaveComponentHosts = this.getSlaveComponentHosts();
     }
     }

+ 18 - 2
ambari-web/app/controllers/main/service/add_controller.js

@@ -114,7 +114,8 @@ App.AddServiceController = App.WizardController.extend({
    * Save data to model
    * Save data to model
    * @param stepController App.WizardStep4Controller
    * @param stepController App.WizardStep4Controller
    */
    */
-  saveServices: function (stepController) {var serviceNames = [];
+  saveServices: function (stepController) {
+    var serviceNames = [];
     this.setDBProperty('service', stepController.get('content'));
     this.setDBProperty('service', stepController.get('content'));
     console.log('AddServiceController.saveServices: saved data', stepController.get('content'));
     console.log('AddServiceController.saveServices: saved data', stepController.get('content'));
     stepController.filterProperty('isSelected', true).filterProperty('isInstalled', false).forEach(function (item) {
     stepController.filterProperty('isSelected', true).filterProperty('isInstalled', false).forEach(function (item) {
@@ -211,7 +212,22 @@ App.AddServiceController = App.WizardController.extend({
    * Load master component hosts data for using in required step controllers
    * Load master component hosts data for using in required step controllers
    */
    */
   loadSlaveComponentHosts: function () {
   loadSlaveComponentHosts: function () {
-    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts');
+    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (!Em.isNone(slaveComponentHosts)) {
+      slaveComponentHosts.forEach(function(component) {
+        component.hosts.forEach(function(host) {
+          //Em.set(host, 'hostName', hosts[host.host_id].name);
+          for (var i = 0; i < host_names.length; i++) {
+            if (hosts[host_names[i]].id === host.host_id) {
+              host.hostName = host_names[i];
+              break;
+            }
+          }
+        });
+      });
+    }
     if(!slaveComponentHosts){
     if(!slaveComponentHosts){
       slaveComponentHosts = this.getSlaveComponentHosts();
       slaveComponentHosts = this.getSlaveComponentHosts();
     }
     }

+ 32 - 11
ambari-web/app/controllers/wizard.js

@@ -590,7 +590,25 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * Load config groups from local DB
    * Load config groups from local DB
    */
    */
   loadServiceConfigGroups: function () {
   loadServiceConfigGroups: function () {
-    var serviceConfigGroups = this.getDBProperty('serviceConfigGroups') || [];
+    var serviceConfigGroups = this.getDBProperty('serviceConfigGroups'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (Em.isNone(serviceConfigGroups)) {
+      serviceConfigGroups = [];
+    }
+    else {
+      serviceConfigGroups.forEach(function(group) {
+        group.hosts.map(function(host_id) {
+          for (var i = 0; i < host_names.length; i++) {
+            if (hosts[host_names[i]].id === host_id) {
+              return host_names[i];
+            }
+          }
+          Em.assert('host is missing!!!!', false);
+        });
+        Em.set(group, 'hosts', host_names);
+      });
+    }
     this.set('content.configGroups', serviceConfigGroups);
     this.set('content.configGroups', serviceConfigGroups);
     console.log("InstallerController.configGroups: loaded config ", serviceConfigGroups);
     console.log("InstallerController.configGroups: loaded config ", serviceConfigGroups);
   },
   },
@@ -611,7 +629,8 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * @param stepController App.WizardStep3Controller
    * @param stepController App.WizardStep3Controller
    */
    */
   saveConfirmedHosts: function (stepController) {
   saveConfirmedHosts: function (stepController) {
-    var hosts = this.get('content.hosts');
+    var hosts = this.get('content.hosts'),
+      indx = 1;
 
 
     //add previously installed hosts
     //add previously installed hosts
     for (var hostName in hosts) {
     for (var hostName in hosts) {
@@ -631,7 +650,8 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
           os_arch: _host.os_arch,
           os_arch: _host.os_arch,
           ip: _host.ip,
           ip: _host.ip,
           bootStatus: _host.bootStatus,
           bootStatus: _host.bootStatus,
-          isInstalled: false
+          isInstalled: false,
+          id: indx++
         };
         };
       }
       }
     });
     });
@@ -667,9 +687,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * @param stepController
    * @param stepController
    */
    */
   saveSlaveComponentHosts: function (stepController) {
   saveSlaveComponentHosts: function (stepController) {
-
-    var hosts = stepController.get('hosts');
-    var headers = stepController.get('headers');
+    var hosts = stepController.get('hosts'),
+      dbHosts = this.getDBProperty('hosts'),
+      headers = stepController.get('headers');
 
 
     var formattedHosts = Ember.Object.create();
     var formattedHosts = Ember.Object.create();
     headers.forEach(function (header) {
     headers.forEach(function (header) {
@@ -683,9 +703,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
         var cb = checkboxes.findProperty('title', header.get('label'));
         var cb = checkboxes.findProperty('title', header.get('label'));
         if (cb.get('checked')) {
         if (cb.get('checked')) {
           formattedHosts.get(header.get('name')).push({
           formattedHosts.get(header.get('name')).push({
-            hostName: host.hostName,
             group: 'Default',
             group: 'Default',
-            isInstalled: cb.get('isInstalled')
+            isInstalled: cb.get('isInstalled'),
+            host_id: dbHosts[host.hostName].id
           });
           });
         }
         }
       });
       });
@@ -848,8 +868,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * @param stepController
    * @param stepController
    */
    */
   saveServiceConfigGroups: function (stepController) {
   saveServiceConfigGroups: function (stepController) {
-    var serviceConfigGroups = [];
-    var isForUpdate = false;
+    var serviceConfigGroups = [],
+      isForUpdate = false,
+      hosts = this.getDBProperty('hosts');
     stepController.get('stepConfigs').forEach(function (service) {
     stepController.get('stepConfigs').forEach(function (service) {
       // mark group of installed service
       // mark group of installed service
       if (service.get('selected') === false) isForUpdate = true;
       if (service.get('selected') === false) isForUpdate = true;
@@ -868,7 +889,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
           id: configGroup.get('id'),
           id: configGroup.get('id'),
           name: configGroup.get('name'),
           name: configGroup.get('name'),
           description: configGroup.get('description'),
           description: configGroup.get('description'),
-          hosts: configGroup.get('hosts'),
+          hosts: configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;}),
           properties: properties,
           properties: properties,
           isDefault: configGroup.get('isDefault'),
           isDefault: configGroup.get('isDefault'),
           isForUpdate: isForUpdate,
           isForUpdate: isForUpdate,

+ 3 - 3
ambari-web/app/controllers/wizard/step7_controller.js

@@ -690,9 +690,9 @@ App.WizardStep7Controller = Em.Controller.extend({
    */
    */
   setStepConfigs: function (configs, storedConfigs) {
   setStepConfigs: function (configs, storedConfigs) {
     var localDB = {
     var localDB = {
-      hosts: this.get('wizardController').getDBProperty('hosts'),
-      masterComponentHosts: this.get('wizardController').getDBProperty('masterComponentHosts'),
-      slaveComponentHosts: this.get('wizardController').getDBProperty('slaveComponentHosts')
+      hosts: this.get('wizardController.content.hosts'),
+      masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
+      slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
     };
     };
     var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB);
     var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB);
     if (this.get('wizardController.name') === 'addServiceController') {
     if (this.get('wizardController.name') === 'addServiceController') {

+ 3 - 2
ambari-web/app/utils/component.js

@@ -46,7 +46,7 @@ module.exports = {
     this.clearStackModel();
     this.clearStackModel();
     var serviceComponents = {items: []};
     var serviceComponents = {items: []};
     data.items.forEach(function(item){
     data.items.forEach(function(item){
-      item.serviceComponents.forEach(function(_serviceComponent){
+      item.serviceComponents.forEach(function(_serviceComponent, indx){
         var stackServiceComponents =  _serviceComponent.StackServiceComponents;
         var stackServiceComponents =  _serviceComponent.StackServiceComponents;
         var serviceComponent = {
         var serviceComponent = {
           component_name: stackServiceComponents.component_name,
           component_name: stackServiceComponents.component_name,
@@ -55,7 +55,8 @@ module.exports = {
           is_master: stackServiceComponents.is_master,
           is_master: stackServiceComponents.is_master,
           is_client: stackServiceComponents.is_client,
           is_client: stackServiceComponents.is_client,
           stack_name: stackServiceComponents.stack_name,
           stack_name: stackServiceComponents.stack_name,
-          stack_version: stackServiceComponents.stack_version
+          stack_version: stackServiceComponents.stack_version,
+          id: indx
         };
         };
         serviceComponents.items.pushObject(serviceComponent);
         serviceComponents.items.pushObject(serviceComponent);
       }, this);
       }, this);

+ 2 - 2
ambari-web/app/utils/config.js

@@ -1295,13 +1295,13 @@ App.config = Em.Object.create({
         selectedGroup.get('hosts').removeObject(hostName);
         selectedGroup.get('hosts').removeObject(hostName);
         if (!selectedGroup.get('isDefault')) {
         if (!selectedGroup.get('isDefault')) {
           self.updateConfigurationGroup(selectedGroup, function () {
           self.updateConfigurationGroup(selectedGroup, function () {
-          }, function () {});
+          }, Em.K);
         }
         }
         newGroup.get('hosts').pushObject(hostName);
         newGroup.get('hosts').pushObject(hostName);
         callback(newGroup);
         callback(newGroup);
         if (!newGroup.get('isDefault')) {
         if (!newGroup.get('isDefault')) {
           self.updateConfigurationGroup(newGroup, function () {
           self.updateConfigurationGroup(newGroup, function () {
-          }, function () {});
+          }, Em.K);
         }
         }
         this.hide();
         this.hide();
       },
       },

+ 3 - 2
ambari-web/app/views/main/service/add_view.js

@@ -77,7 +77,7 @@ App.AddServiceView = Em.View.extend({
   loadHostsSuccessCallback: function (response) {
   loadHostsSuccessCallback: function (response) {
     var installedHosts = {};
     var installedHosts = {};
 
 
-    response.items.forEach(function (item) {
+    response.items.forEach(function (item, indx) {
       installedHosts[item.Hosts.host_name] = {
       installedHosts[item.Hosts.host_name] = {
         name: item.Hosts.host_name,
         name: item.Hosts.host_name,
         cpu: item.Hosts.cpu_count,
         cpu: item.Hosts.cpu_count,
@@ -85,7 +85,8 @@ App.AddServiceView = Em.View.extend({
         disk_info: item.Hosts.disk_info,
         disk_info: item.Hosts.disk_info,
         bootStatus: "REGISTERED",
         bootStatus: "REGISTERED",
         isInstalled: true,
         isInstalled: true,
-        hostComponents: item.host_components
+        hostComponents: item.host_components,
+        id: indx++
       };
       };
     });
     });
     this.get('controller').setDBProperty('hosts', installedHosts);
     this.get('controller').setDBProperty('hosts', installedHosts);