ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [46/50] [abbrv] ambari git commit: AMBARI-19351. ambari-web action to download all client configs of host. (jaimin)
Date Thu, 05 Jan 2017 00:05:27 GMT
AMBARI-19351. ambari-web action to download all client configs of host. (jaimin)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 4253a6173281ee896aa237b87904c64667878c2f
Parents: e96dee0
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Wed Jan 4 11:35:13 2017 -0800
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Wed Jan 4 11:48:17 2017 -0800

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 13 +++++-
 ambari-web/app/controllers/main/service.js      |  2 +-
 ambari-web/app/controllers/main/service/item.js |  2 +-
 ambari-web/app/messages.js                      |  1 +
 .../details/support_client_configs_download.js  | 49 +++++++++++++++-----
 ambari-web/app/templates/main/host/details.hbs  |  5 ++
 .../main/service/all_services_actions.hbs       |  2 +-
 ambari-web/app/views/main/host/details.js       |  2 +
 .../test/controllers/main/host/details_test.js  | 25 ++++++++--
 .../test/controllers/main/service/item_test.js  |  4 +-
 10 files changed, 84 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index a8f6c75..4a7cce4 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -2592,7 +2592,18 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
     this.downloadClientConfigsCall({
       hostName: event.context.get('hostName'),
       componentName: event.context.get('componentName'),
-      displayName: event.context.get('displayName')
+      resourceType: this.resourceTypeEnum.HOST_COMPONENT
+    });
+  },
+
+  /**
+   *  This controller action is called from the template when user clicks to download configs
for "All Clients On Host"
+   */
+  downloadAllClientConfigs: function () {
+    var self = this;
+    this.downloadClientConfigsCall({
+      hostName: self.get('content.hostName'),
+      resourceType: this.resourceTypeEnum.HOST
     });
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/app/controllers/main/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service.js b/ambari-web/app/controllers/main/service.js
index e4d751d..6e68ec5 100644
--- a/ambari-web/app/controllers/main/service.js
+++ b/ambari-web/app/controllers/main/service.js
@@ -147,7 +147,7 @@ App.MainServiceController = Em.ArrayController.extend(App.SupportClientConfigsDo
    * Download client configs for all services
    */
   downloadAllClientConfigs: function() {
-    this.downloadClientConfigsCall({downloadAll: true});
+    this.downloadClientConfigsCall({resourceType: this.resourceTypeEnum.CLUSTER});
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index 19b021b..8921e22 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -1093,7 +1093,7 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
     this.downloadClientConfigsCall({
       serviceName: this.get('content.serviceName'),
       componentName: (event && event.name) || component.get('componentName'),
-      displayName: (event && event.label) || component.get('displayName')
+      resourceType: this.resourceTypeEnum.SERVICE_COMPONENT
     });
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 0b0b78e..1e25b3a 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2655,6 +2655,7 @@ Em.I18n.translations = {
   'host.host.details.installClients': 'Install clients',
   'host.host.details.reinstallClients': 'Reinstall clients',
   'host.host.details.checkHost': 'Check host',
+  'host.host.details.downloadAllClients': 'All Clients On Host',
 
   'host.host.componentFilter.master':'Master Components',
   'host.host.componentFilter.slave':'Slave Components',

http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/app/mixins/main/host/details/support_client_configs_download.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/host/details/support_client_configs_download.js b/ambari-web/app/mixins/main/host/details/support_client_configs_download.js
index 58460f0..0b880b4 100644
--- a/ambari-web/app/mixins/main/host/details/support_client_configs_download.js
+++ b/ambari-web/app/mixins/main/host/details/support_client_configs_download.js
@@ -20,34 +20,59 @@ var App = require('app');
 App.SupportClientConfigsDownload = Em.Mixin.create({
 
   /**
+   * This object is supposed to be used as an enum  for resource types supported by ambari
+   */
+  resourceTypeEnum: Object.freeze({
+    CLUSTER: "ClusterResource",
+    HOST: "HostResource",
+    SERVICE: "ServiceResource",
+    SERVICE_COMPONENT: "ServiceComponentResource",
+    HOST_COMPONENT: "HostComponentResource"
+  }),
+
+  /**
    *
-   * @param {{hostName: string, componentName: string, displayName: string, serviceName:
string}} data
+   * @param {{hostName: string, componentName: string, displayName: string, serviceName:
string, resourceType: resourceTypeEnum}} data
    */
   downloadClientConfigsCall: function (data) {
-    var url = this._getUrl(data.hostName, data.serviceName, data.componentName, data.downloadAll);
+    var url = this._getUrl(data.hostName, data.serviceName, data.componentName, data.resourceType);
     var newWindow = window.open(url);
     newWindow.focus();
   },
 
-  _getDownloadAllUrl: function () {
-    return App.get('apiPrefix') + '/clusters/' + App.router.getClusterName() + '/components?format=client_config_tar';
-  },
   /**
    *
    * @param {string|null} hostName
    * @param {string} serviceName
    * @param {string} componentName
+   * @param {string} resourceType
    * @returns {string}
    * @private
    */
-  _getUrl: function (hostName, serviceName, componentName, downloadAll) {
-    if (downloadAll) {
-      return this._getDownloadAllUrl();
+  _getUrl: function (hostName, serviceName, componentName, resourceType) {
+    var result;
+    var prefix = App.get('apiPrefix') + '/clusters/' + App.router.getClusterName() + '/';
+
+    switch (resourceType) {
+      case this.resourceTypeEnum.SERVICE_COMPONENT:
+        result = prefix + 'services/' + serviceName + '/components/' + componentName;
+        break;
+      case this.resourceTypeEnum.HOST_COMPONENT:
+        result = prefix + 'hosts/' + hostName + '/host_components/' + componentName;
+        break;
+      case this.resourceTypeEnum.HOST:
+        result = prefix + 'hosts/' + hostName + '/host_components';
+        break;
+      case this.resourceTypeEnum.SERVICE:
+        result = prefix + 'services/' + serviceName + '/components';
+        break;
+      case this.resourceTypeEnum.CLUSTER:
+      default:
+        result = prefix + 'components';
     }
-    var isForHost = !Em.isNone(hostName);
-    return App.get('apiPrefix') + '/clusters/' + App.router.getClusterName() + '/' +
-      (isForHost ? 'hosts/' + hostName + '/host_components/' : 'services/' + serviceName
+ '/components/') +
-      componentName + '?format=client_config_tar';
+
+    result += '?format=client_config_tar';
+    return result;
   }
 
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/app/templates/main/host/details.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/details.hbs b/ambari-web/app/templates/main/host/details.hbs
index 630f0da..bd75f5c 100644
--- a/ambari-web/app/templates/main/host/details.hbs
+++ b/ambari-web/app/templates/main/host/details.hbs
@@ -51,6 +51,11 @@
 
                   <div class="dropdown-menu-wrap">
                     <ul class="dropdown-menu">
+                    {{#if view.hasManyClientsWithConfigs}}
+                      <li>
+                         <a id="all-clients-on-host-link" {{action "downloadAllClientConfigs"
target="controller" href=true}}>{{t host.host.details.downloadAllClients}}</a>
+                      </li>
+                    {{/if}}
                       {{#each client in view.clientsWithConfigs}}
                         <li>
                           <a {{action "downloadClientConfigs" client target="controller"
href=true}}>{{client.displayName}}</a>

http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/app/templates/main/service/all_services_actions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/all_services_actions.hbs b/ambari-web/app/templates/main/service/all_services_actions.hbs
index a185e4f..9756f01 100644
--- a/ambari-web/app/templates/main/service/all_services_actions.hbs
+++ b/ambari-web/app/templates/main/service/all_services_actions.hbs
@@ -59,7 +59,7 @@
             </li>
           {{/isAuthorized}}
             <li>
-                <a href="#"
+                <a href="#" id="all-clients-of-cluster-link"
                     {{action "downloadAllClientConfigs" target="view.serviceController"}}>
                     <i {{bindAttr class=":glyphicon :glyphicon-download-alt"}}></i>
                     {{t services.service.downloadAllClientConfigs}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/app/views/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details.js b/ambari-web/app/views/main/host/details.js
index ba507a3..54e3a76 100644
--- a/ambari-web/app/views/main/host/details.js
+++ b/ambari-web/app/views/main/host/details.js
@@ -36,6 +36,8 @@ App.MainHostDetailsView = Em.View.extend({
     });
   }.property('content.hostComponents.@each'),
 
+  hasManyClientsWithConfigs: Em.computed.gt('clientsWithConfigs.length', 1),
+
   isActive: Em.computed.equal('controller.content.passiveState', 'OFF'),
 
   maintenance: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/test/controllers/main/host/details_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js
index 2f4376f..a4cb177 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -2439,14 +2439,33 @@ describe('App.MainHostDetailsController', function () {
       controller.downloadClientConfigs({
         context: Em.Object.create({
           componentName: 'name',
-          hostName: 'host1',
-          displayName: 'dName'
+          hostName: 'host1'
         })
       });
       expect(controller.downloadClientConfigsCall.calledWith({
         componentName: 'name',
         hostName: 'host1',
-        displayName: 'dName'
+        resourceType: controller.resourceTypeEnum.HOST_COMPONENT
+      })).to.be.true;
+    });
+  });
+
+  describe('#downloadAllClientConfigs', function () {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'downloadClientConfigsCall', Em.K);
+      sinon.stub(controller, 'get').withArgs('content.hostName').returns('host1');
+    });
+    afterEach(function () {
+      controller.downloadClientConfigsCall.restore();
+      controller.get.restore();
+    });
+
+    it('should launch controller.downloadClientConfigsCall method', function () {
+      controller.downloadAllClientConfigs();
+      expect(controller.downloadClientConfigsCall.calledWith({
+        hostName: 'host1',
+        resourceType: controller.resourceTypeEnum.HOST
       })).to.be.true;
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/4253a617/ambari-web/test/controllers/main/service/item_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/item_test.js b/ambari-web/test/controllers/main/service/item_test.js
index a22733f..4b3a419 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -1214,7 +1214,7 @@ describe('App.MainServiceItemController', function () {
       expect(mainServiceItemController.downloadClientConfigsCall.calledWith({
         serviceName: 'S1',
         componentName: 'C1',
-        displayName: 'd1'
+        resourceType: mainServiceItemController.resourceTypeEnum.SERVICE_COMPONENT
       })).to.be.true;
     });
     it('should launch $.fileDownload method, event passed', function () {
@@ -1226,7 +1226,7 @@ describe('App.MainServiceItemController', function () {
       expect(mainServiceItemController.downloadClientConfigsCall.calledWith({
         serviceName: 'S1',
         componentName: 'name1',
-        displayName: 'label1'
+        resourceType: mainServiceItemController.resourceTypeEnum.SERVICE_COMPONENT
       })).to.be.true;
     });
   });


Mime
View raw message