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.extraColumnHeaders and $scope.imagePairs . | 4 * them into $scope.extraColumnHeaders and $scope.imagePairs . |
5 */ | 5 */ |
6 var Loader = angular.module( | 6 var Loader = angular.module( |
7 'Loader', | 7 'Loader', |
8 ['ConstantsModule'] | 8 ['ConstantsModule'] |
9 ); | 9 ); |
10 | 10 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 | 123 |
124 Loader.controller( | 124 Loader.controller( |
125 'Loader.Controller', | 125 'Loader.Controller', |
126 function($scope, $http, $filter, $location, $log, $timeout, constants) { | 126 function($scope, $http, $filter, $location, $log, $timeout, constants) { |
127 $scope.readyToDisplay = false; | 127 $scope.readyToDisplay = false; |
128 $scope.constants = constants; | 128 $scope.constants = constants; |
129 $scope.windowTitle = "Loading GM Results..."; | 129 $scope.windowTitle = "Loading GM Results..."; |
130 $scope.resultsToLoad = $location.search().resultsToLoad; | 130 $scope.resultsToLoad = $location.search().resultsToLoad; |
131 $scope.loadingMessage = "please wait..."; | 131 $scope.loadingMessage = "please wait..."; |
132 | 132 |
133 var currSortAsc = true; | |
134 | |
135 | |
133 /** | 136 /** |
134 * On initial page load, load a full dictionary of results. | 137 * On initial page load, load a full dictionary of results. |
135 * Once the dictionary is loaded, unhide the page elements so they can | 138 * Once the dictionary is loaded, unhide the page elements so they can |
136 * render the data. | 139 * render the data. |
137 */ | 140 */ |
138 $http.get($scope.resultsToLoad).success( | 141 $http.get($scope.resultsToLoad).success( |
139 function(data, status, header, config) { | 142 function(data, status, header, config) { |
140 var dataHeader = data[constants.KEY__ROOT__HEADER]; | 143 var dataHeader = data[constants.KEY__ROOT__HEADER]; |
141 if (dataHeader[constants.KEY__HEADER__SCHEMA_VERSION] != | 144 if (dataHeader[constants.KEY__HEADER__SCHEMA_VERSION] != |
142 constants.VALUE__HEADER__SCHEMA_VERSION) { | 145 constants.VALUE__HEADER__SCHEMA_VERSION) { |
(...skipping 17 matching lines...) Expand all Loading... | |
160 function(){location.reload();}, | 163 function(){location.reload();}, |
161 timeToReload - timeNow); | 164 timeToReload - timeNow); |
162 } else { | 165 } else { |
163 $scope.loadingMessage = "processing data, please wait..."; | 166 $scope.loadingMessage = "processing data, please wait..."; |
164 | 167 |
165 $scope.header = dataHeader; | 168 $scope.header = dataHeader; |
166 $scope.extraColumnHeaders = data[constants.KEY__ROOT__EXTRACOLUMNHEADE RS]; | 169 $scope.extraColumnHeaders = data[constants.KEY__ROOT__EXTRACOLUMNHEADE RS]; |
167 $scope.orderedColumnNames = data[constants.KEY__ROOT__EXTRACOLUMNORDER ]; | 170 $scope.orderedColumnNames = data[constants.KEY__ROOT__EXTRACOLUMNORDER ]; |
168 $scope.imagePairs = data[constants.KEY__ROOT__IMAGEPAIRS]; | 171 $scope.imagePairs = data[constants.KEY__ROOT__IMAGEPAIRS]; |
169 $scope.imageSets = data[constants.KEY__ROOT__IMAGESETS]; | 172 $scope.imageSets = data[constants.KEY__ROOT__IMAGESETS]; |
173 | |
174 // set the default sort column and make it ascending. | |
170 $scope.sortColumnSubdict = constants.KEY__IMAGEPAIRS__DIFFERENCES; | 175 $scope.sortColumnSubdict = constants.KEY__IMAGEPAIRS__DIFFERENCES; |
171 $scope.sortColumnKey = constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF; | 176 $scope.sortColumnKey = constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF; |
177 currSortAsc = true; | |
172 | 178 |
173 $scope.showSubmitAdvancedSettings = false; | 179 $scope.showSubmitAdvancedSettings = false; |
174 $scope.submitAdvancedSettings = {}; | 180 $scope.submitAdvancedSettings = {}; |
175 $scope.submitAdvancedSettings[ | 181 $scope.submitAdvancedSettings[ |
176 constants.KEY__EXPECTATIONS__REVIEWED] = true; | 182 constants.KEY__EXPECTATIONS__REVIEWED] = true; |
177 $scope.submitAdvancedSettings[ | 183 $scope.submitAdvancedSettings[ |
178 constants.KEY__EXPECTATIONS__IGNOREFAILURE] = false; | 184 constants.KEY__EXPECTATIONS__IGNOREFAILURE] = false; |
179 $scope.submitAdvancedSettings['bug'] = ''; | 185 $scope.submitAdvancedSettings['bug'] = ''; |
180 | 186 |
181 // Create the list of tabs (lists into which the user can file each | 187 // Create the list of tabs (lists into which the user can file each |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 $scope.imageSets, | 286 $scope.imageSets, |
281 function(imageSet) { | 287 function(imageSet) { |
282 var baseUrl = imageSet[baseUrlKey]; | 288 var baseUrl = imageSet[baseUrlKey]; |
283 if ((baseUrl.substring(0, 1) != '/') && | 289 if ((baseUrl.substring(0, 1) != '/') && |
284 (baseUrl.indexOf('://') == -1)) { | 290 (baseUrl.indexOf('://') == -1)) { |
285 imageSet[baseUrlKey] = $scope.resultsToLoad + '/../' + baseUrl; | 291 imageSet[baseUrlKey] = $scope.resultsToLoad + '/../' + baseUrl; |
286 } | 292 } |
287 } | 293 } |
288 ); | 294 ); |
289 | 295 |
296 | |
297 // show the table and sort it ascending by | |
290 $scope.readyToDisplay = true; | 298 $scope.readyToDisplay = true; |
291 $scope.updateResults(); | 299 $scope.updateResults(); |
292 $scope.loadingMessage = ""; | 300 $scope.loadingMessage = ""; |
293 $scope.windowTitle = "Current GM Results"; | 301 $scope.windowTitle = "Current GM Results"; |
294 | 302 |
295 $timeout( function() { | 303 $timeout( function() { |
296 make_results_header_sticky(); | 304 make_results_header_sticky(); |
297 }); | 305 }); |
298 } | 306 } |
299 } | 307 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 ); | 598 ); |
591 $scope.showingColumnValues[columnName] = showingColumnValues; | 599 $scope.showingColumnValues[columnName] = showingColumnValues; |
592 } | 600 } |
593 } | 601 } |
594 ); | 602 ); |
595 | 603 |
596 // TODO(epoger): Every time we apply a filter, AngularJS creates | 604 // TODO(epoger): Every time we apply a filter, AngularJS creates |
597 // another copy of the array. Is there a way we can filter out | 605 // another copy of the array. Is there a way we can filter out |
598 // the imagePairs as they are displayed, rather than storing multiple | 606 // the imagePairs as they are displayed, rather than storing multiple |
599 // array copies? (For better performance.) | 607 // array copies? (For better performance.) |
600 | |
601 if ($scope.viewingTab == $scope.defaultTab) { | 608 if ($scope.viewingTab == $scope.defaultTab) { |
602 | 609 |
603 // TODO(epoger): Until we allow the user to reverse sort order, | 610 // TODO(epoger): Until we allow the user to reverse sort order, |
604 // there are certain columns we want to sort in a different order. | 611 // there are certain columns we want to sort in a different order. |
605 var doReverse = ( | 612 var doReverse = ( |
606 ($scope.sortColumnKey == | 613 ($scope.sortColumnKey == |
607 constants.KEY__DIFFERENCES__PERCENT_DIFF_PIXELS) || | 614 constants.KEY__DIFFERENCES__PERCENT_DIFF_PIXELS) || |
608 ($scope.sortColumnKey == | 615 ($scope.sortColumnKey == |
609 constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF)); | 616 constants.KEY__DIFFERENCES__PERCEPTUAL_DIFF)); |
610 | 617 |
618 doReverse = !currSortAsc; | |
619 | |
611 $scope.filteredImagePairs = | 620 $scope.filteredImagePairs = |
612 $filter("orderBy")( | 621 $filter("orderBy")( |
613 $filter("removeHiddenImagePairs")( | 622 $filter("removeHiddenImagePairs")( |
614 $scope.imagePairs, | 623 $scope.imagePairs, |
615 $scope.filterableColumnNames, | 624 $scope.filterableColumnNames, |
616 $scope.showingColumnValues, | 625 $scope.showingColumnValues, |
617 $scope.viewingTab | 626 $scope.viewingTab |
618 ), | 627 ), |
619 [$scope.getSortColumnValue, $scope.getSecondOrderSortValue], | 628 // [$scope.getSortColumnValue, $scope.getSecondOrderSortValue], |
629 $scope.getSortColumnValue, | |
620 doReverse); | 630 doReverse); |
621 $scope.limitedImagePairs = $filter("mergeAndLimit")( | 631 $scope.limitedImagePairs = $filter("mergeAndLimit")( |
622 $scope.filteredImagePairs, $scope.displayLimit, $scope.mergeIdentica lRows); | 632 $scope.filteredImagePairs, $scope.displayLimit, $scope.mergeIdentica lRows); |
623 } else { | 633 } else { |
624 $scope.filteredImagePairs = | 634 $scope.filteredImagePairs = |
625 $filter("orderBy")( | 635 $filter("orderBy")( |
626 $filter("filter")( | 636 $filter("filter")( |
627 $scope.imagePairs, | 637 $scope.imagePairs, |
628 {tab: $scope.viewingTab}, | 638 {tab: $scope.viewingTab}, |
629 true | 639 true |
630 ), | 640 ), |
631 [$scope.getSortColumnValue, $scope.getSecondOrderSortValue]); | 641 // [$scope.getSortColumnValue, $scope.getSecondOrderSortValue]); |
642 $scope.getSortColumnValue); | |
632 $scope.limitedImagePairs = $filter("mergeAndLimit")( | 643 $scope.limitedImagePairs = $filter("mergeAndLimit")( |
633 $scope.filteredImagePairs, -1, $scope.mergeIdenticalRows); | 644 $scope.filteredImagePairs, -1, $scope.mergeIdenticalRows); |
634 } | 645 } |
635 $scope.showThumbnails = $scope.showThumbnailsPending; | 646 $scope.showThumbnails = $scope.showThumbnailsPending; |
636 $scope.imageSize = $scope.imageSizePending; | 647 $scope.imageSize = $scope.imageSizePending; |
637 $scope.setUpdatesPending(false); | 648 $scope.setUpdatesPending(false); |
638 $scope.queryParameters.save(); | 649 $scope.queryParameters.save(); |
639 } | 650 } |
640 | 651 |
641 /** | 652 /** |
642 * This function is called when the results have been completely rendered | 653 * This function is called when the results have been completely rendered |
643 * after updateResults(). | 654 * after updateResults(). |
644 */ | 655 */ |
645 $scope.resultsUpdatedCallback = function() { | 656 $scope.resultsUpdatedCallback = function() { |
646 $scope.renderEndTime = window.performance.now(); | 657 $scope.renderEndTime = window.performance.now(); |
647 $log.debug("renderEndTime: " + $scope.renderEndTime); | 658 $log.debug("renderEndTime: " + $scope.renderEndTime); |
648 } | 659 }; |
649 | 660 |
650 /** | 661 /** |
651 * Re-sort the displayed results. | 662 * Re-sort the displayed results. |
652 * | 663 * |
653 * @param subdict (string): which KEY__IMAGEPAIRS__* subdictionary | 664 * @param subdict (string): which KEY__IMAGEPAIRS__* subdictionary |
654 * the sort column key is within, or 'none' if the sort column | 665 * the sort column key is within, or 'none' if the sort column |
655 * key is one of KEY__IMAGEPAIRS__* | 666 * key is one of KEY__IMAGEPAIRS__* |
656 * @param key (string): sort by value associated with this key in subdict | 667 * @param key (string): sort by value associated with this key in subdict |
657 */ | 668 */ |
658 $scope.sortResultsBy = function(subdict, key) { | 669 $scope.sortResultsBy = function(subdict, key) { |
659 $scope.sortColumnSubdict = subdict; | 670 if ((subdict === $scope.sortColumnSubdict) && ($scope.sortColumnKey === ke y)) { |
epoger
2014/08/07 13:58:29
Maybe add comment, like...
// If we are already s
stephana
2014/08/07 15:52:22
Done.
| |
660 $scope.sortColumnKey = key; | 671 currSortAsc = !currSortAsc; |
672 } else { | |
673 $scope.sortColumnSubdict = subdict; | |
674 $scope.sortColumnKey = key; | |
675 currSortAsc = true; | |
676 } | |
661 $scope.updateResults(); | 677 $scope.updateResults(); |
662 } | 678 }; |
679 | |
680 /** | |
681 * Returns ASC or DESC (from constants) if currently the data | |
682 * is sorted by the provided column. | |
683 * | |
684 * @param colName: name of the column for which we need to get the class. | |
685 */ | |
686 | |
687 $scope.sortedByColumnsCls = function (colName) { | |
688 if ($scope.sortColumnKey !== colName) { | |
689 return ''; | |
690 } | |
691 | |
692 var result = (currSortAsc) ? constants.ASC : constants.DESC; | |
693 console.log("sort class:", result); | |
694 return result; | |
695 }; | |
663 | 696 |
664 /** | 697 /** |
665 * For a particular ImagePair, return the value of the column we are | 698 * For a particular ImagePair, return the value of the column we are |
666 * sorting on (according to $scope.sortColumnSubdict and | 699 * sorting on (according to $scope.sortColumnSubdict and |
667 * $scope.sortColumnKey). | 700 * $scope.sortColumnKey). |
668 * | 701 * |
669 * @param imagePair: imagePair to get a column value out of. | 702 * @param imagePair: imagePair to get a column value out of. |
670 */ | 703 */ |
671 $scope.getSortColumnValue = function(imagePair) { | 704 $scope.getSortColumnValue = function(imagePair) { |
672 if ($scope.sortColumnSubdict in imagePair) { | 705 if ($scope.sortColumnSubdict in imagePair) { |
673 return imagePair[$scope.sortColumnSubdict][$scope.sortColumnKey]; | 706 return imagePair[$scope.sortColumnSubdict][$scope.sortColumnKey]; |
674 } else if ($scope.sortColumnKey in imagePair) { | 707 } else if ($scope.sortColumnKey in imagePair) { |
675 return imagePair[$scope.sortColumnKey]; | 708 return imagePair[$scope.sortColumnKey]; |
676 } else { | 709 } else { |
677 return undefined; | 710 return undefined; |
678 } | 711 } |
679 } | 712 }; |
epoger
2014/08/07 13:58:29
Nit: I see that we don't have semicolons at the en
stephana
2014/08/07 15:52:22
Well they should be at the other functions as well
| |
680 | 713 |
681 /** | 714 /** |
682 * For a particular ImagePair, return the value we use for the | 715 * For a particular ImagePair, return the value we use for the |
683 * second-order sort (tiebreaker when multiple rows have | 716 * second-order sort (tiebreaker when multiple rows have |
684 * the same getSortColumnValue()). | 717 * the same getSortColumnValue()). |
685 * | 718 * |
686 * We join the imageA and imageB urls for this value, so that we merge | 719 * We join the imageA and imageB urls for this value, so that we merge |
687 * adjacent rows as much as possible. | 720 * adjacent rows as much as possible. |
688 * | 721 * |
689 * @param imagePair: imagePair to get a column value out of. | 722 * @param imagePair: imagePair to get a column value out of. |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1021 */ | 1054 */ |
1022 $scope.getImageDiffRelativeUrl = function(imagePair) { | 1055 $scope.getImageDiffRelativeUrl = function(imagePair) { |
1023 var before = | 1056 var before = |
1024 imagePair[constants.KEY__IMAGEPAIRS__IMAGE_A_URL] + "-vs-" + | 1057 imagePair[constants.KEY__IMAGEPAIRS__IMAGE_A_URL] + "-vs-" + |
1025 imagePair[constants.KEY__IMAGEPAIRS__IMAGE_B_URL]; | 1058 imagePair[constants.KEY__IMAGEPAIRS__IMAGE_B_URL]; |
1026 return before.replace(/[^\w\-]/g, "_") + ".png"; | 1059 return before.replace(/[^\w\-]/g, "_") + ".png"; |
1027 } | 1060 } |
1028 | 1061 |
1029 } | 1062 } |
1030 ); | 1063 ); |
OLD | NEW |