Chromium Code Reviews| Index: gm/rebaseline_server/static/loader.js |
| =================================================================== |
| --- gm/rebaseline_server/static/loader.js (revision 11573) |
| +++ gm/rebaseline_server/static/loader.js (working copy) |
| @@ -7,16 +7,95 @@ |
| 'Loader', |
| [] |
| ); |
| + |
| +// TODO(epoger): Combine ALL of our filtering operations (including |
| +// truncation) into this one filter, so that runs most efficiently? |
| +// (We would have to make sure truncation still took place after |
| +// sorting, though.) |
| +Loader.filter( |
| + 'removeHiddenItems', |
| + function() { |
| + return function(unfilteredItems, hiddenResultTypes, hiddenConfigs) { |
| + var filteredItems = []; |
| + for (var i = 0; i < unfilteredItems.length; i++) { |
| + var item = unfilteredItems[i]; |
| + if ((hiddenResultTypes.indexOf(item.resultType) < 0) && |
| + (hiddenConfigs.indexOf(item.config) < 0)) { |
| + filteredItems.push(item); |
| + } |
| + } |
| + return filteredItems; |
| + }; |
| + } |
| +); |
| + |
| Loader.controller( |
| 'Loader.Controller', |
| - function($scope, $http) { |
| + function($scope, $http, $filter) { |
| $http.get("/results/all").then( |
| function(response) { |
| $scope.categories = response.data.categories; |
| $scope.testData = response.data.testData; |
| $scope.sortColumn = 'test'; |
| - $scope.showResultsOfType = 'failed'; |
| + |
| + $scope.hiddenResultTypes = [ |
| + 'failure-ignored', 'no-comparison', 'succeeded']; |
|
epoger
2013/10/02 18:04:57
Brian requested that we only show "failed" results
|
| + $scope.hiddenConfigs = []; |
| + |
| + $scope.updateResults(); |
|
borenet
2013/10/02 18:30:30
Nit: tabs
epoger
2013/10/02 18:57:14
Fixed. I don't know how those started cropping up
borenet
2013/10/02 19:07:35
Please remove the personality who thinks tabs are
|
| } |
| ); |
| + |
| + $scope.isHiddenResultType = function(thisResultType) { |
| + return ($scope.hiddenResultTypes.indexOf(thisResultType) >= 0); |
| + } |
| + $scope.toggleHiddenResultType = function(thisResultType) { |
| + var i = $scope.hiddenResultTypes.indexOf(thisResultType); |
| + if (i >= 0) { |
| + $scope.hiddenResultTypes.splice(i, 1); |
| + } else { |
| + $scope.hiddenResultTypes.push(thisResultType); |
| + } |
| + $scope.areUpdatesPending = true; |
| + } |
| + |
| + // TODO(epoger): Rather than maintaining these as hard-coded |
| + // variants of isHiddenResultType and toggleHiddenResultType, we |
| + // should create general-purpose functions that can work with ANY |
| + // category. |
| + // But for now, I wanted to see this working. :-) |
| + $scope.isHiddenConfig = function(thisConfig) { |
| + return ($scope.hiddenConfigs.indexOf(thisConfig) >= 0); |
| + } |
| + $scope.toggleHiddenConfig = function(thisConfig) { |
| + var i = $scope.hiddenConfigs.indexOf(thisConfig); |
| + if (i >= 0) { |
| + $scope.hiddenConfigs.splice(i, 1); |
| + } else { |
| + $scope.hiddenConfigs.push(thisConfig); |
| + } |
| + $scope.areUpdatesPending = true; |
| + } |
| + |
| + $scope.updateResults = function() { |
| + $scope.displayLimit = $scope.displayLimitPending; |
| + $scope.filteredTestData = |
| + $filter("orderBy")( |
| + $filter("removeHiddenItems")( |
| + $scope.testData, |
| + $scope.hiddenResultTypes, |
| + $scope.hiddenConfigs |
| + ), |
| + $scope.sortColumn); |
| + $scope.limitedTestData = $filter("limitTo")( |
| + $scope.filteredTestData, $scope.displayLimit); |
|
borenet
2013/10/02 18:30:30
This creates a second array, right? Is it possibl
epoger
2013/10/02 18:57:14
Agreed, but I think AngularJS forces us to do it t
|
| + $scope.imageSize = $scope.imageSizePending; |
| + $scope.areUpdatesPending = false; |
| + } |
| + |
| + $scope.sortResultsBy = function(sortColumn) { |
| + $scope.sortColumn = sortColumn; |
| + $scope.updateResults(); |
| + } |
| } |
| ); |