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 | 11 |
12 // TODO(epoger): Combine ALL of our filtering operations (including | 12 // TODO(epoger): Combine ALL of our filtering operations (including |
13 // truncation) into this one filter, so that runs most efficiently? | 13 // truncation) into this one filter, so that runs most efficiently? |
14 // (We would have to make sure truncation still took place after | 14 // (We would have to make sure truncation still took place after |
15 // sorting, though.) | 15 // sorting, though.) |
16 Loader.filter( | 16 Loader.filter( |
17 'removeHiddenItems', | 17 'removeHiddenItems', |
18 function() { | 18 function() { |
19 return function(unfilteredItems, hiddenResultTypes, hiddenConfigs, | 19 return function(unfilteredItems, hiddenResultTypes, hiddenConfigs, |
20 viewingTab) { | 20 builderSubstring, testSubstring, viewingTab) { |
21 var filteredItems = []; | 21 var filteredItems = []; |
22 for (var i = 0; i < unfilteredItems.length; i++) { | 22 for (var i = 0; i < unfilteredItems.length; i++) { |
23 var item = unfilteredItems[i]; | 23 var item = unfilteredItems[i]; |
24 // For performance, we examine the "set" objects directly rather | 24 // For performance, we examine the "set" objects directly rather |
25 // than calling $scope.isValueInSet(). | 25 // than calling $scope.isValueInSet(). |
26 // Besides, I don't think we have access to $scope in here... | 26 // Besides, I don't think we have access to $scope in here... |
27 if (!(true == hiddenResultTypes[item.resultType]) && | 27 if (!(true == hiddenResultTypes[item.resultType]) && |
28 !(true == hiddenConfigs[item.config]) && | 28 !(true == hiddenConfigs[item.config]) && |
29 !(-1 == item.builder.indexOf(builderSubstring)) && | |
30 !(-1 == item.test.indexOf(testSubstring)) && | |
29 (viewingTab == item.tab)) { | 31 (viewingTab == item.tab)) { |
30 filteredItems.push(item); | 32 filteredItems.push(item); |
31 } | 33 } |
32 } | 34 } |
33 return filteredItems; | 35 return filteredItems; |
34 }; | 36 }; |
35 } | 37 } |
36 ); | 38 ); |
37 | 39 |
38 | 40 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 | 94 |
93 // Arrays within which the user can toggle individual elements. | 95 // Arrays within which the user can toggle individual elements. |
94 $scope.selectedItems = []; | 96 $scope.selectedItems = []; |
95 | 97 |
96 // Sets within which the user can toggle individual elements. | 98 // Sets within which the user can toggle individual elements. |
97 $scope.hiddenResultTypes = { | 99 $scope.hiddenResultTypes = { |
98 'failure-ignored': true, | 100 'failure-ignored': true, |
99 'no-comparison': true, | 101 'no-comparison': true, |
100 'succeeded': true, | 102 'succeeded': true, |
101 }; | 103 }; |
104 $scope.allResultTypes = Object.keys(data.categories['resultType']); | |
102 $scope.hiddenConfigs = {}; | 105 $scope.hiddenConfigs = {}; |
106 $scope.allConfigs = Object.keys(data.categories['config']); | |
107 | |
108 // Associative array of partial string matches per category. | |
109 $scope.categoryValueMatch = {}; | |
110 $scope.categoryValueMatch.builder = ""; | |
111 $scope.categoryValueMatch.test = ""; | |
103 | 112 |
104 $scope.updateResults(); | 113 $scope.updateResults(); |
105 $scope.loadingMessage = ""; | 114 $scope.loadingMessage = ""; |
106 $scope.windowTitle = "Current GM Results"; | 115 $scope.windowTitle = "Current GM Results"; |
107 } | 116 } |
108 ).error( | 117 ).error( |
109 function(data, status, header, config) { | 118 function(data, status, header, config) { |
110 $scope.loadingMessage = "Failed to load results of type '" | 119 $scope.loadingMessage = "Failed to load results of type '" |
111 + resultsToLoad + "'"; | 120 + resultsToLoad + "'"; |
112 $scope.windowTitle = "Failed to Load GM Results"; | 121 $scope.windowTitle = "Failed to Load GM Results"; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 // the items as they are displayed, rather than storing multiple | 241 // the items as they are displayed, rather than storing multiple |
233 // array copies? (For better performance.) | 242 // array copies? (For better performance.) |
234 | 243 |
235 if ($scope.viewingTab == $scope.defaultTab) { | 244 if ($scope.viewingTab == $scope.defaultTab) { |
236 $scope.filteredTestData = | 245 $scope.filteredTestData = |
237 $filter("orderBy")( | 246 $filter("orderBy")( |
238 $filter("removeHiddenItems")( | 247 $filter("removeHiddenItems")( |
239 $scope.testData, | 248 $scope.testData, |
240 $scope.hiddenResultTypes, | 249 $scope.hiddenResultTypes, |
241 $scope.hiddenConfigs, | 250 $scope.hiddenConfigs, |
251 $scope.categoryValueMatch.builder, | |
252 $scope.categoryValueMatch.test, | |
242 $scope.viewingTab | 253 $scope.viewingTab |
243 ), | 254 ), |
244 $scope.sortColumn); | 255 $scope.sortColumn); |
245 $scope.limitedTestData = $filter("limitTo")( | 256 $scope.limitedTestData = $filter("limitTo")( |
246 $scope.filteredTestData, $scope.displayLimit); | 257 $scope.filteredTestData, $scope.displayLimit); |
247 } else { | 258 } else { |
248 $scope.filteredTestData = | 259 $scope.filteredTestData = |
249 $filter("orderBy")( | 260 $filter("orderBy")( |
250 $filter("filter")( | 261 $filter("filter")( |
251 $scope.testData, | 262 $scope.testData, |
(...skipping 10 matching lines...) Expand all Loading... | |
262 /** | 273 /** |
263 * Re-sort the displayed results. | 274 * Re-sort the displayed results. |
264 * | 275 * |
265 * @param sortColumn (string): name of the column to sort on | 276 * @param sortColumn (string): name of the column to sort on |
266 */ | 277 */ |
267 $scope.sortResultsBy = function(sortColumn) { | 278 $scope.sortResultsBy = function(sortColumn) { |
268 $scope.sortColumn = sortColumn; | 279 $scope.sortColumn = sortColumn; |
269 $scope.updateResults(); | 280 $scope.updateResults(); |
270 } | 281 } |
271 | 282 |
283 /** | |
284 * Set $scope.categoryValueMatch[name] = value, and update results. | |
285 * | |
286 * @param name | |
287 * @param value | |
288 */ | |
289 $scope.setCategoryValueMatch = function(name, value) { | |
290 $scope.categoryValueMatch[name] = value; | |
291 $scope.updateResults(); | |
292 } | |
293 | |
294 /** | |
295 * Update $scope.hiddenResultTypes so that ONLY this resultType is showing, | |
296 * and update the visible results. | |
297 * | |
298 * @param resultType | |
299 */ | |
300 $scope.showOnlyResultType = function(resultType) { | |
301 $scope.hiddenResultTypes = {}; | |
302 $scope.toggleValuesInSet($scope.allResultTypes, $scope.hiddenResultTypes); | |
303 $scope.toggleValueInSet(resultType, $scope.hiddenResultTypes); | |
borenet
2013/10/29 13:56:54
I'm confused about why you're using these toggle f
epoger
2013/10/29 15:44:58
Because they're different data types. Added a TOD
| |
304 $scope.updateResults(); | |
305 } | |
306 | |
307 /** | |
308 * Update $scope.hiddenConfigs so that ONLY this config is showing, | |
309 * and update the visible results. | |
310 * | |
311 * @param config | |
312 */ | |
313 $scope.showOnlyConfig = function(config) { | |
314 $scope.hiddenConfigs = {}; | |
315 $scope.toggleValuesInSet($scope.allConfigs, $scope.hiddenConfigs); | |
316 $scope.toggleValueInSet(config, $scope.hiddenConfigs); | |
317 $scope.updateResults(); | |
318 } | |
319 | |
272 | 320 |
273 // | 321 // |
274 // Operations for sending info back to the server. | 322 // Operations for sending info back to the server. |
275 // | 323 // |
276 | 324 |
277 /** | 325 /** |
278 * Tell the server that the actual results of these particular tests | 326 * Tell the server that the actual results of these particular tests |
279 * are acceptable. | 327 * are acceptable. |
280 * | 328 * |
281 * @param testDataSubset an array of test results, most likely a subset of | 329 * @param testDataSubset an array of test results, most likely a subset of |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 * @param set an Object which we use to mimic set semantics | 433 * @param set an Object which we use to mimic set semantics |
386 */ | 434 */ |
387 $scope.toggleValueInSet = function(value, set) { | 435 $scope.toggleValueInSet = function(value, set) { |
388 if (true == set[value]) { | 436 if (true == set[value]) { |
389 delete set[value]; | 437 delete set[value]; |
390 } else { | 438 } else { |
391 set[value] = true; | 439 set[value] = true; |
392 } | 440 } |
393 } | 441 } |
394 | 442 |
443 /** | |
444 * For each value in valueArray, call toggleValueInSet(value, set). | |
445 * | |
446 * @param valueArray | |
447 * @param set | |
448 */ | |
449 $scope.toggleValuesInSet = function(valueArray, set) { | |
450 var arrayLength = valueArray.length; | |
451 for (var i = 0; i < arrayLength; i++) { | |
452 $scope.toggleValueInSet(valueArray[i], set); | |
453 } | |
454 } | |
455 | |
395 | 456 |
396 // | 457 // |
397 // Array operations; similar to our Set operations, but operate on a | 458 // Array operations; similar to our Set operations, but operate on a |
398 // Javascript Array so we *can* easily get a list of all values in the Set. | 459 // Javascript Array so we *can* easily get a list of all values in the Set. |
399 // TODO(epoger): move into a separate .js file? | 460 // TODO(epoger): move into a separate .js file? |
400 // | 461 // |
401 | 462 |
402 /** | 463 /** |
403 * Returns true if value "value" is present within array "array". | 464 * Returns true if value "value" is present within array "array". |
404 * | 465 * |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 * | 498 * |
438 * @param secondsPastEpoch (numeric): seconds past epoch in UTC | 499 * @param secondsPastEpoch (numeric): seconds past epoch in UTC |
439 */ | 500 */ |
440 $scope.localTimeString = function(secondsPastEpoch) { | 501 $scope.localTimeString = function(secondsPastEpoch) { |
441 var d = new Date(secondsPastEpoch * 1000); | 502 var d = new Date(secondsPastEpoch * 1000); |
442 return d.toString(); | 503 return d.toString(); |
443 } | 504 } |
444 | 505 |
445 } | 506 } |
446 ); | 507 ); |
OLD | NEW |