Sfoglia il codice sorgente

AMBARI-6308 API: filtering by hostname does not work properly. (Buzhor Denys via atkach)

atkach 11 anni fa
parent
commit
3045cc4090

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

@@ -28,6 +28,7 @@ App.MainHostController = Em.ArrayController.extend({
   clearFilters: null,
 
   filteredCount: 0,
+  resetStartIndex: false,
   /**
    * flag responsible for updating status counters of hosts
    */
@@ -226,7 +227,9 @@ App.MainHostController = Em.ArrayController.extend({
     var colPropAssoc = this.get('colPropAssoc');
     var filterProperties = this.get('filterProperties');
     var sortProperties = this.get('sortProps');
+    var oldProperties = App.router.get('updateController.queryParams.Hosts');
 
+    this.set('resetStartIndex', false);
     this.get('viewProperties').forEach(function (property) {
       queryParams.push({
         key: property.get('alias'),
@@ -240,7 +243,8 @@ App.MainHostController = Em.ArrayController.extend({
         var result = {
           key: property.alias,
           value: filter.value,
-          type: property.type
+          type: property.type,
+          isFilter: true
         };
         if (filter.type === 'string' && sortProperties.someProperty('key', colPropAssoc[filter.iColumn])) {
           result.value = this.getRegExp(filter.value);
@@ -257,6 +261,19 @@ App.MainHostController = Em.ArrayController.extend({
         }
       }
     }, this);
+
+    if (queryParams.filterProperty('isFilter').length !== oldProperties.filterProperty('isFilter').length) {
+      queryParams.findProperty('key', 'from').value = 0;
+      this.set('resetStartIndex', true);
+    } else {
+      queryParams.filterProperty('isFilter').forEach(function (queryParam) {
+        var oldProperty = oldProperties.filterProperty('isFilter').findProperty('key', queryParam.key);
+        if (!oldProperty || JSON.stringify(oldProperty.value) !== JSON.stringify(queryParam.value)) {
+          queryParams.findProperty('key', 'from').value = 0;
+          this.set('resetStartIndex', true);
+        }
+      }, this);
+    }
     savedSortConditions.forEach(function (sort) {
       var property = sortProperties.findProperty('key', sort.name);
 

+ 7 - 1
ambari-web/app/views/main/host.js

@@ -849,5 +849,11 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
    */
   colPropAssoc: function () {
     return this.get('controller.colPropAssoc');
-  }.property('controller.colPropAssoc')
+  }.property('controller.colPropAssoc'),
+
+  resetStartIndex: function () {
+    if (this.get('controller.resetStartIndex')) {
+      this.set('startIndex', 1);
+    }
+  }.observes('controller.resetStartIndex')
 });