Jelajahi Sumber

AMBARI-2668. Jobs page: All should not switch to Filtered after clicking next page. (Oleg Nechiporenko via yusaku)

Yusaku Sako 12 tahun lalu
induk
melakukan
6a7855c830

+ 9 - 7
ambari-web/app/controllers/main/apps_controller.js

@@ -326,21 +326,23 @@ App.MainAppsController = Em.ArrayController.extend({
         "iSortCol_0", "sSortDir_0"
       ];
 
+      var notFilterFields = ["iDisplayLength", "iDisplayStart", "iSortCol_0", "sSortDir_0"];
+
+      var filtersUsed = false;
+
       for (var n=0; n<arr.length;n++) {
         if(this.get(arr[n])){
           link += arr[n] + "=" + this.get(arr[n]) + "&";
+          if (!notFilterFields.contains(arr[n])) {
+            filtersUsed = true;
+          }
         }
       };
 
       link = link.slice(0,link.length-1);
 
-      var valueInString=link.match(/&/g);
-
-      if(!this.get("viewTypeClickEvent"))
-      if(valueInString != null){
-        this.set("viewType","filtered");
-      }else{
-        this.set("viewType","all");
+      if(!this.get("viewTypeClickEvent")) {
+        this.set('viewType', filtersUsed?'filtered':'all');
       }
 
       return link;

+ 1 - 1
ambari-web/app/views/main/apps_view.js

@@ -275,7 +275,7 @@ App.MainAppsView = Em.View.extend({
         }
       });
     });
-    App.router.get('mainAppsItemController').set('lastJobId', null);
+    this.get('controller').set('lastJobId', null);
     this.onChangeViewType();
   },
   /**

+ 27 - 1
ambari-web/test/controllers/main/app_contoller_test.js

@@ -177,9 +177,35 @@ describe('MainAppsController', function () {
            "&iDisplayStart=10" +
            "&iSortCol_0=1" +
            "&sSortDir_0=ASC");
-     })
+       expect(mainAppsController.get('filterObject.viewType')).to.equal('filtered');
+     });
+
+     it('should set viewType to "all" when set iDisplayLength, iDisplayStart, iSortCol_0, sSortDir_0', function () {
+       mainAppsController.set("filterObject.sSearch_0", "");
+       mainAppsController.set("filterObject.sSearch_1", "");
+       mainAppsController.set("filterObject.sSearch_2", "");
+       mainAppsController.set("filterObject.sSearch_3", "");
+       mainAppsController.set("filterObject.minJobs", "");
+       mainAppsController.set("filterObject.maxJobs", "");
+       mainAppsController.set("filterObject.minInputBytes", "");
+       mainAppsController.set("filterObject.maxInputBytes", "");
+       mainAppsController.set("filterObject.minOutputBytes", "");
+       mainAppsController.set("filterObject.maxOutputBytes", "");
+       mainAppsController.set("filterObject.minDuration", "");
+       mainAppsController.set("filterObject.maxDuration", "");
+       mainAppsController.set("filterObject.minStartTime", "");
+       mainAppsController.set("filterObject.maxStartTime", "");
+       mainAppsController.set("filterObject.sSearch", "");
+       mainAppsController.set("filterObject.iDisplayLength", "10");
+       mainAppsController.set("filterObject.iDisplayStart", "10");
+       mainAppsController.set("filterObject.iSortCol_0", "1");
+       mainAppsController.set("filterObject.sSortDir_0", "ASC");
+       expect(mainAppsController.get('filterObject.viewType')).to.equal('all');
+     });
    });
 
 
+
+
  });