Updated Branches: refs/heads/branch-1.2.5 f9c5a7785 -> 1640728e6
AMBARI-2668. Jobs page: All should not switch to Filtered after clicking next page. (Oleg Nechiporenko via yusaku) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/1640728e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/1640728e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/1640728e Branch: refs/heads/branch-1.2.5 Commit: 1640728e6950deff455bc39fe99d7c146f188a8b Parents: f9c5a77 Author: Yusaku Sako <[email protected]> Authored: Wed Jul 17 11:24:39 2013 -0700 Committer: Yusaku Sako <[email protected]> Committed: Wed Jul 17 11:25:10 2013 -0700 ---------------------------------------------------------------------- .../app/controllers/main/apps_controller.js | 16 ++++++----- ambari-web/app/views/main/apps_view.js | 2 +- .../test/controllers/main/app_contoller_test.js | 28 +++++++++++++++++++- 3 files changed, 37 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/1640728e/ambari-web/app/controllers/main/apps_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/apps_controller.js b/ambari-web/app/controllers/main/apps_controller.js index f7ab229..4a548ce 100644 --- a/ambari-web/app/controllers/main/apps_controller.js +++ b/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; http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/1640728e/ambari-web/app/views/main/apps_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/apps_view.js b/ambari-web/app/views/main/apps_view.js index e77dff4..a644667 100644 --- a/ambari-web/app/views/main/apps_view.js +++ b/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(); }, /** http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/1640728e/ambari-web/test/controllers/main/app_contoller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/app_contoller_test.js b/ambari-web/test/controllers/main/app_contoller_test.js index 9801b63..77308f0 100644 --- a/ambari-web/test/controllers/main/app_contoller_test.js +++ b/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'); + }); }); + + });
