Przeglądaj źródła

AMBARI-8369 (EC2)Hosts have external host names on Hosts page. (atkach)

Andrii Tkach 10 lat temu
rodzic
commit
e799839097

+ 9 - 9
ambari-web/app/controllers/main/host.js

@@ -68,8 +68,8 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
    */
   filterProperties: [
     {
-      key: 'publicHostName',
-      alias: 'Hosts/public_host_name',
+      key: 'hostName',
+      alias: 'Hosts/host_name',
       type: 'MATCH'
     },
     {
@@ -126,8 +126,8 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
 
   sortProps: [
     {
-      name: 'publicHostName',
-      key: 'Hosts/public_host_name'
+      name: 'hostName',
+      key: 'Hosts/host_name'
     },
     {
       name: 'ip',
@@ -167,12 +167,12 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
   },
 
   getSortProps: function () {
-    // sort by public_host_name by default
+    // sort by host_name by default
     if (App.db.getSortingStatuses(this.get('name')) && App.db.getSortingStatuses(this.get('name')).length === 0) {
       App.db.setSortingStatuses(this.get('name'), {
-        name: 'publicHostName',
+        name: 'hostName',
         status: 'sorting_asc'
-      })
+      });
     }
     return this._super();
   },
@@ -205,7 +205,7 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
           type: property.type,
           isFilter: true
         };
-        if (filter.type === 'string' && sortProperties.someProperty('key', colPropAssoc[filter.iColumn])) {
+        if (filter.type === 'string' && sortProperties.someProperty('name', colPropAssoc[filter.iColumn])) {
           result.value = this.getRegExp(filter.value);
         }
         if (filter.type === 'number' || filter.type === 'ambari-bandwidth') {
@@ -916,7 +916,7 @@ App.MainHostController = Em.ArrayController.extend(App.TableServerMixin, {
   colPropAssoc: function () {
     var associations = [];
     associations[0] = 'healthClass';
-    associations[1] = 'publicHostName';
+    associations[1] = 'hostName';
     associations[2] = 'ip';
     associations[3] = 'cpu';
     associations[4] = 'memoryFormatted';

+ 1 - 1
ambari-web/app/templates/main/host.hbs

@@ -103,7 +103,7 @@
 
           <td class="name">
             <span class="trim_hostname">
-              <a title="{{unbound host.publicHostName}}" href="#" {{action "showDetails" host}}>{{unbound host.publicHostName}}</a>
+              <a title="{{unbound host.hostName}}" href="#" {{action "showDetails" host}}>{{unbound host.hostName}}</a>
             </span>
             {{#if host.criticalAlertsCount}}
               <span class="label label-important alerts-count" {{action "showAlertsPopup" host target="controller"}}>{{host.criticalAlertsCount}}</span>

+ 31 - 1
ambari-web/test/controllers/main/host_test.js

@@ -147,7 +147,7 @@ describe('MainHostController', function () {
         { value: 'a1.*', expected: '.*a1.*' },
         { value: 'a1.*.a2.a3', expected: '.*a1.*.a2.a3.*' },
         { value: 'a1.*.a2...a3', expected: '.*a1.*.a2...a3.*' }
-      ]
+      ];
 
     tests.forEach(function(test){
       it(message.format(test.value, test.expected), function() {
@@ -184,4 +184,34 @@ describe('MainHostController', function () {
       expect(mock.checkRegionServerState.calledWith('host1')).to.be.true;
     });
   });
+
+  describe('#getQueryParameters', function() {
+    beforeEach(function() {
+      hostController = App.MainHostController.create({});
+      sinon.spy(hostController, 'getRegExp');
+      sinon.stub(App.db, 'getFilterConditions', function() {
+        return [{
+          iColumn: 1,
+          skipFilter: false,
+          type: "string",
+          value: "someval"
+        }];
+      });
+    });
+    
+    afterEach(function() {
+      App.db.getFilterConditions.restore();
+      hostController.getRegExp.restore();
+    });
+
+    it('should call #getRegExp with value `someval` on host name filter', function() {
+      hostController.getQueryParameters();
+      expect(hostController.getRegExp.calledWith('someval')).to.ok;
+    });
+
+    it('result should include host name filter converted value', function() {
+      expect(hostController.getQueryParameters().findProperty('key', 'Hosts/host_name').value).to.equal('.*someval.*');
+    });
+  });
+  
 });