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']; | |
epoger
2013/10/02 18:04:57
Brian requested that we only show "failed" results
| |
43 » $scope.hiddenConfigs = []; | |
44 | |
45 » $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
| |
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 $scope.filteredTestData = | |
83 $filter("orderBy")( | |
84 $filter("removeHiddenItems")( | |
85 $scope.testData, | |
86 $scope.hiddenResultTypes, | |
87 $scope.hiddenConfigs | |
88 ), | |
89 $scope.sortColumn); | |
90 $scope.limitedTestData = $filter("limitTo")( | |
91 $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
| |
92 $scope.imageSize = $scope.imageSizePending; | |
93 $scope.areUpdatesPending = false; | |
94 } | |
95 | |
96 $scope.sortResultsBy = function(sortColumn) { | |
97 $scope.sortColumn = sortColumn; | |
98 $scope.updateResults(); | |
99 } | |
21 } | 100 } |
22 ); | 101 ); |
OLD | NEW |