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