You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2016/03/10 00:49:57 UTC

[05/51] [abbrv] ambari git commit: AMBARI-15308 UI: ability to perform bulk add host components (Joe Wang via rzang)

AMBARI-15308 UI: ability to perform bulk add host components (Joe Wang via rzang)


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

Branch: refs/heads/AMBARI-13364
Commit: bf186cfdc36264b7cdf3ab19a7fda32091c09591
Parents: 3dd4c4a
Author: Richard Zang <rz...@apache.org>
Authored: Mon Mar 7 14:29:19 2016 -0800
Committer: Richard Zang <rz...@apache.org>
Committed: Mon Mar 7 14:29:45 2016 -0800

----------------------------------------------------------------------
 .../main/host/bulk_operations_controller.js     | 22 ++++++++++++++------
 .../host/bulk_operations_controller_test.js     |  6 +++---
 2 files changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bf186cfd/ambari-web/app/controllers/main/host/bulk_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/bulk_operations_controller.js b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
index 659d335..6714231 100644
--- a/ambari-web/app/controllers/main/host/bulk_operations_controller.js
+++ b/ambari-web/app/controllers/main/host/bulk_operations_controller.js
@@ -39,7 +39,7 @@ App.BulkOperationsController = Em.Controller.extend({
         this.bulkOperationForHostComponentsRestart(operationData, hosts);
       }
       else if (operationData.action === 'ADD') {
-        this.bulkOperationForHostComponentsAddConfirm(operationData, hosts);
+        this.bulkOperationForHostComponentsAdd(operationData, hosts);
       }
       else {
         if (operationData.action.indexOf('DECOMMISSION') == -1) {
@@ -310,16 +310,26 @@ App.BulkOperationsController = Em.Controller.extend({
   },
 
   /**
-   * Confirm bulk add for selected hostComponent
+   * bulk add for selected hostComponent
    * @param {Object} operationData - data about bulk operation (action, hostComponent etc)
    * @param {Array} hosts - list of affected hosts
    */
-  bulkOperationForHostComponentsAddConfirm: function (operationData, hosts) {
+  bulkOperationForHostComponentsAdd: function (operationData, hosts) {
+    var self = this;
+    return batchUtils.getComponentsFromServer({
+      components: [operationData.componentName],
+      hosts: hosts.mapProperty('hostName')
+    }, function (data) {
+      return self._getComponentsFromServerForHostComponentsAddCallback(operationData, data, hosts);
+    });
+  },
+
+  _getComponentsFromServerForHostComponentsAddCallback: function (operationData, data, hosts) {
     var self = this;
 
     hosts = hosts.mapProperty('hostName');
 
-    var allHostsWithComponent = App.HostComponent.find().filterProperty('componentName', operationData.componentName).mapProperty('hostName');
+    var allHostsWithComponent = data.items.mapProperty('Hosts.host_name');
     var hostsWithComponent = hosts.filter(function (host) {
       return allHostsWithComponent.contains(host);
     });
@@ -346,7 +356,7 @@ App.BulkOperationsController = Em.Controller.extend({
         },
 
         onPrimary: function() {
-          self.bulkOperationForHostComponentsAdd(operationData, hostsWithOutComponent);
+          self.bulkAddHostComponents(operationData, hostsWithOutComponent);
           this._super();
         },
         bodyClass: Em.View.extend({
@@ -387,7 +397,7 @@ App.BulkOperationsController = Em.Controller.extend({
    * @param {Object} operationData - data about bulk operation (action, hostComponent etc)
    * @param {Array} hostNames - list of affected hosts' names
    */
-  bulkOperationForHostComponentsAdd: function (operationData, hostNames) {
+  bulkAddHostComponents: function (operationData, hostNames) {
     var self= this;
     App.get('router.mainAdminKerberosController').getKDCSessionState(function () {
       App.ajax.send({

http://git-wip-us.apache.org/repos/asf/ambari/blob/bf186cfd/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js b/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js
index 178a6fd..7a8b270 100644
--- a/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js
+++ b/ambari-web/test/controllers/main/host/bulk_operations_controller_test.js
@@ -32,7 +32,7 @@ describe('BulkOperationsController', function () {
       sinon.stub(hostController, 'bulkOperationForHostComponentsRestart', Em.K);
       sinon.stub(hostController, 'bulkOperationForHostComponentsDecommission', Em.K);
       sinon.stub(hostController, 'bulkOperationForHostComponents', Em.K);
-      sinon.stub(hostController, 'bulkOperationForHostComponentsAddConfirm', Em.K);
+      sinon.stub(hostController, 'bulkOperationForHostComponentsAdd', Em.K);
       sinon.stub(hostController, 'bulkOperationForHostsPassiveState', Em.K);
     });
 
@@ -43,7 +43,7 @@ describe('BulkOperationsController', function () {
       hostController.bulkOperationForHostComponentsRestart.restore();
       hostController.bulkOperationForHostComponentsDecommission.restore();
       hostController.bulkOperationForHostComponents.restore();
-      hostController.bulkOperationForHostComponentsAddConfirm.restore();
+      hostController.bulkOperationForHostComponentsAdd.restore();
       hostController.bulkOperationForHostsPassiveState.restore();
 
     });
@@ -121,7 +121,7 @@ describe('BulkOperationsController', function () {
         componentNameFormatted: 'DataNodes'
       };
       hostController.bulkOperation(operationData, []);
-      expect(hostController.bulkOperationForHostComponentsAddConfirm.calledOnce).to.equal(true);
+      expect(hostController.bulkOperationForHostComponentsAdd.calledOnce).to.equal(true);
     });
 
     it('DECOMMISSION for hostComponents', function() {