Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 3aa9f328a -> 0ca576658


AMBARI-14830. Clients names different on host details page and filter. (xiwang 
via yusaku)


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

Branch: refs/heads/branch-2.2
Commit: 0ca576658cad57889e82401084915f1af028052a
Parents: 3aa9f32
Author: Yusaku Sako <[email protected]>
Authored: Tue Mar 8 19:07:06 2016 -0800
Committer: Yusaku Sako <[email protected]>
Committed: Tue Mar 8 19:07:06 2016 -0800

----------------------------------------------------------------------
 .../app/controllers/global/update_controller.js      |  4 ++--
 ambari-web/app/mappers/components_state_mapper.js    |  1 +
 ambari-web/app/mappers/hosts_mapper.js               |  1 +
 ambari-web/app/models/client_component.js            |  9 +--------
 ambari-web/app/models/host_component.js              |  9 +--------
 ambari-web/app/models/service.js                     |  2 +-
 ambari-web/app/utils/helper.js                       | 15 ++++++++++++---
 ambari-web/test/models/host_component_test.js        | 10 ----------
 8 files changed, 19 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0ca57665/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js 
b/ambari-web/app/controllers/global/update_controller.js
index f71afbe..e4ff3e7 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -212,7 +212,7 @@ App.UpdateController = Em.Controller.extend({
         hostDetailsFilter = '',
         realUrl = 
'/hosts?fields=Hosts/rack_info,Hosts/host_name,Hosts/maintenance_state,Hosts/public_host_name,Hosts/cpu_count,Hosts/ph_cpu_count,'
 +
             
'alerts_summary,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/ip,host_components/HostRoles/state,host_components/HostRoles/maintenance_state,'
 +
-            
'host_components/HostRoles/stale_configs,host_components/HostRoles/service_name,host_components/HostRoles/desired_admin_state,'
 +
+            
'host_components/HostRoles/stale_configs,host_components/HostRoles/service_name,host_components/HostRoles/display_name,host_components/HostRoles/desired_admin_state,'
 +
             
'<metrics>Hosts/total_mem<hostDetailsParams><stackVersions>&minimal_response=true',
         hostDetailsParams = 
',Hosts/os_arch,Hosts/os_type,metrics/cpu/cpu_system,metrics/cpu/cpu_user,metrics/memory/mem_total,metrics/memory/mem_free',
         stackVersionInfo = ',stack_versions/HostStackVersions,' +
@@ -522,7 +522,7 @@ App.UpdateController = Em.Controller.extend({
   updateComponentsState: function (callback) {
     var testUrl = '/data/services/HDP2/components_state.json';
     var realUrl = '/components/?fields=ServiceComponentInfo/service_name,' +
-      
'ServiceComponentInfo/category,ServiceComponentInfo/installed_count,ServiceComponentInfo/started_count,ServiceComponentInfo/total_count,host_components/HostRoles/host_name&minimal_response=true';
+      
'ServiceComponentInfo/category,ServiceComponentInfo/installed_count,ServiceComponentInfo/started_count,ServiceComponentInfo/total_count,ServiceComponentInfo/display_name,host_components/HostRoles/host_name&minimal_response=true';
     var url = this.getUrl(testUrl, realUrl);
 
     App.HttpClient.get(url, App.componentsStateMapper, {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ca57665/ambari-web/app/mappers/components_state_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/components_state_mapper.js 
b/ambari-web/app/mappers/components_state_mapper.js
index ac3e1b5..755c0f5 100644
--- a/ambari-web/app/mappers/components_state_mapper.js
+++ b/ambari-web/app/mappers/components_state_mapper.js
@@ -28,6 +28,7 @@ App.componentsStateMapper = App.QuickDataMapper.create({
     service_id: 'ServiceComponentInfo.service_name',
     stack_info_id: 'ServiceComponentInfo.component_name',
     component_name: 'ServiceComponentInfo.component_name',
+    display_name: 'ServiceComponentInfo.display_name',
     service_name: 'ServiceComponentInfo.service_name',
     installed_count: 'ServiceComponentInfo.installed_count',
     started_count: 'ServiceComponentInfo.started_count',

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ca57665/ambari-web/app/mappers/hosts_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/hosts_mapper.js 
b/ambari-web/app/mappers/hosts_mapper.js
index 7691f2b..d54c988 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -59,6 +59,7 @@ App.hostsMapper = App.QuickDataMapper.create({
   },
   hostComponentConfig: {
     component_name: 'HostRoles.component_name',
+    display_name: 'HostRoles.display_name',
     service_id: 'HostRoles.service_name',
     passive_state: 'HostRoles.maintenance_state',
     work_status: 'HostRoles.state',

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ca57665/ambari-web/app/models/client_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/client_component.js 
b/ambari-web/app/models/client_component.js
index 816950c..7dde68a 100644
--- a/ambari-web/app/models/client_component.js
+++ b/ambari-web/app/models/client_component.js
@@ -22,6 +22,7 @@ var stringUtils = require('utils/string_utils');
 App.ClientComponent = DS.Model.extend({
   service: DS.belongsTo('App.Service'),
   componentName: DS.attr('string'),
+  displayName: DS.attr('string'),
   installedCount: DS.attr('number'),
   startedCount: DS.attr('number'),
   totalCount: DS.attr('number'),
@@ -36,14 +37,6 @@ App.ClientComponent = DS.Model.extend({
     return 'value_for_'+this.get('componentName').toLowerCase();
   }.property('componentName'),
 
-  displayName: function() {
-    var displayName = App.format.role(this.get('componentName'));
-    if (this.get('service.serviceName') === this.get('componentName')) {
-      displayName += ' ' + Em.I18n.t('common.client');
-    }
-    return displayName;
-  }.property('componentName'),
-
   displayNamePluralized: function() {
     return stringUtils.pluralize(this.get('installedCount'), 
this.get('displayName'));
   }.property('installedCount')

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ca57665/ambari-web/app/models/host_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host_component.js 
b/ambari-web/app/models/host_component.js
index 3474996..f3c61a9 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -22,6 +22,7 @@ App.HostComponent = DS.Model.extend({
   workStatus: DS.attr('string'),
   passiveState: DS.attr('string'),
   componentName: DS.attr('string'),
+  displayName: DS.attr('string'),
   haStatus: DS.attr('string'),
   displayNameAdvanced: DS.attr('string'),
   staleConfigs: DS.attr('boolean'),
@@ -54,14 +55,6 @@ App.HostComponent = DS.Model.extend({
   }.property('workStatus'),
 
   /**
-   * Formatted <code>componentName</code>
-   * @returns {String}
-   */
-  displayName: function () {
-    return App.format.role(this.get('componentName'));
-  }.property('componentName'),
-
-  /**
    * Determine if component is master
    * @returns {bool}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ca57665/ambari-web/app/models/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service.js b/ambari-web/app/models/service.js
index d5b71e4..d415817 100644
--- a/ambari-web/app/models/service.js
+++ b/ambari-web/app/models/service.js
@@ -23,7 +23,7 @@ require('utils/config');
 App.Service = DS.Model.extend({
   serviceName: DS.attr('string'),
   displayName: function() {
-    return App.format.role(this.get('serviceName'));
+    return App.format.role(this.get('serviceName'), 'SERVICE');
   }.property('serviceName'),
   passiveState: DS.attr('string'),
   workStatus: DS.attr('string'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ca57665/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index ea269e8..31e8955 100644
--- a/ambari-web/app/utils/helper.js
+++ b/ambari-web/app/utils/helper.js
@@ -426,11 +426,20 @@ App.format = {
    * @memberof App.format
    * @method role
    * @param {string} role
+   * @param {string} level
    * return {string}
    */
-  role: function (role) {
-    var models = [App.StackService, App.StackServiceComponent];
-
+  role: function (role, level) {
+    switch (level) {
+      case 'SERVICE':
+        var models = [App.StackService];
+        break;
+      case 'COMPONENT':
+        var models = [App.StackServiceComponent];
+        break;
+      default:
+        var models = [App.StackService, App.StackServiceComponent];
+    }
     if (App.isEmptyObject(this.stackRolesMap)) {
       models.forEach(function (model) {
         model.find().forEach(function (item) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ca57665/ambari-web/test/models/host_component_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/host_component_test.js 
b/ambari-web/test/models/host_component_test.js
index 7b4cf74..b31dd19 100644
--- a/ambari-web/test/models/host_component_test.js
+++ b/ambari-web/test/models/host_component_test.js
@@ -54,16 +54,6 @@ describe('App.HostComponent', function() {
     });
   });
 
-  describe('#displayName', function() {
-    it('', function() {
-      sinon.stub(App.format, 'role', Em.K);
-      hc.propertyDidChange('displayName');
-      hc.get('displayName');
-      expect(App.format.role.calledWith('COMP1')).to.be.true;
-      App.format.role.restore();
-    });
-  });
-
   describe('#isMaster', function() {
     it('', function() {
       sinon.stub(App.get('components.masters'), 'contains', Em.K);

Reply via email to