OLD | NEW |
1 /* | 1 /* |
2 * Loader: | 2 * Loader: |
3 * Reads GM result reports written out by results.py, and imports | 3 * Reads GM result reports written out by results.py, and imports |
4 * them into $scope.categories and $scope.testData . | 4 * them into $scope.categories and $scope.testData . |
5 */ | 5 */ |
6 var Loader = angular.module( | 6 var Loader = angular.module( |
7 'Loader', | 7 'Loader', |
8 [] | 8 [] |
9 ); | 9 ); |
| 10 |
| 11 // TODO(epoger): Combine ALL of our filtering operations (including |
| 12 // truncation) into this one filter, so that runs most efficiently? |
| 13 // (We would have to make sure truncation still took place after |
| 14 // sorting, though.) |
| 15 Loader.filter( |
| 16 'removeHiddenItems', |
| 17 function() { |
| 18 return function(unfilteredItems, hiddenResultTypes, hiddenConfigs) { |
| 19 var filteredItems = []; |
| 20 for (var i = 0; i < unfilteredItems.length; i++) { |
| 21 var item = unfilteredItems[i]; |
| 22 if ((hiddenResultTypes.indexOf(item.resultType) < 0) && |
| 23 (hiddenConfigs.indexOf(item.config) < 0)) { |
| 24 filteredItems.push(item); |
| 25 } |
| 26 } |
| 27 return filteredItems; |
| 28 }; |
| 29 } |
| 30 ); |
| 31 |
10 Loader.controller( | 32 Loader.controller( |
11 'Loader.Controller', | 33 'Loader.Controller', |
12 function($scope, $http) { | 34 function($scope, $http, $filter) { |
13 $http.get("/results/all").then( | 35 $http.get("/results/all").then( |
14 function(response) { | 36 function(response) { |
15 $scope.categories = response.data.categories; | 37 $scope.categories = response.data.categories; |
16 $scope.testData = response.data.testData; | 38 $scope.testData = response.data.testData; |
17 $scope.sortColumn = 'test'; | 39 $scope.sortColumn = 'test'; |
18 » $scope.showResultsOfType = 'failed'; | 40 |
| 41 $scope.hiddenResultTypes = [ |
| 42 'failure-ignored', 'no-comparison', 'succeeded']; |
| 43 $scope.hiddenConfigs = []; |
| 44 |
| 45 $scope.updateResults(); |
19 } | 46 } |
20 ); | 47 ); |
| 48 |
| 49 $scope.isHiddenResultType = function(thisResultType) { |
| 50 return ($scope.hiddenResultTypes.indexOf(thisResultType) >= 0); |
| 51 } |
| 52 $scope.toggleHiddenResultType = function(thisResultType) { |
| 53 var i = $scope.hiddenResultTypes.indexOf(thisResultType); |
| 54 if (i >= 0) { |
| 55 $scope.hiddenResultTypes.splice(i, 1); |
| 56 } else { |
| 57 $scope.hiddenResultTypes.push(thisResultType); |
| 58 } |
| 59 $scope.areUpdatesPending = true; |
| 60 } |
| 61 |
| 62 // TODO(epoger): Rather than maintaining these as hard-coded |
| 63 // variants of isHiddenResultType and toggleHiddenResultType, we |
| 64 // should create general-purpose functions that can work with ANY |
| 65 // category. |
| 66 // But for now, I wanted to see this working. :-) |
| 67 $scope.isHiddenConfig = function(thisConfig) { |
| 68 return ($scope.hiddenConfigs.indexOf(thisConfig) >= 0); |
| 69 } |
| 70 $scope.toggleHiddenConfig = function(thisConfig) { |
| 71 var i = $scope.hiddenConfigs.indexOf(thisConfig); |
| 72 if (i >= 0) { |
| 73 $scope.hiddenConfigs.splice(i, 1); |
| 74 } else { |
| 75 $scope.hiddenConfigs.push(thisConfig); |
| 76 } |
| 77 $scope.areUpdatesPending = true; |
| 78 } |
| 79 |
| 80 $scope.updateResults = function() { |
| 81 $scope.displayLimit = $scope.displayLimitPending; |
| 82 // TODO(epoger): Every time we apply a filter, AngularJS creates |
| 83 // another copy of the array. Is there a way we can filter out |
| 84 // the items as they are displayed, rather than storing multiple |
| 85 // array copies? (For better performance.) |
| 86 $scope.filteredTestData = |
| 87 $filter("orderBy")( |
| 88 $filter("removeHiddenItems")( |
| 89 $scope.testData, |
| 90 $scope.hiddenResultTypes, |
| 91 $scope.hiddenConfigs |
| 92 ), |
| 93 $scope.sortColumn); |
| 94 $scope.limitedTestData = $filter("limitTo")( |
| 95 $scope.filteredTestData, $scope.displayLimit); |
| 96 $scope.imageSize = $scope.imageSizePending; |
| 97 $scope.areUpdatesPending = false; |
| 98 } |
| 99 |
| 100 $scope.sortResultsBy = function(sortColumn) { |
| 101 $scope.sortColumn = sortColumn; |
| 102 $scope.updateResults(); |
| 103 } |
21 } | 104 } |
22 ); | 105 ); |
OLD | NEW |