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', 'diff_viewer'] | 8 ['ConstantsModule', 'diff_viewer'] |
9 ); | 9 ); |
10 | 10 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 | 68 |
69 /** | 69 /** |
70 * On initial page load, load a full dictionary of results. | 70 * On initial page load, load a full dictionary of results. |
71 * Once the dictionary is loaded, unhide the page elements so they can | 71 * Once the dictionary is loaded, unhide the page elements so they can |
72 * render the data. | 72 * render the data. |
73 */ | 73 */ |
74 $http.get("/results/" + $scope.resultsToLoad).success( | 74 $http.get("/results/" + $scope.resultsToLoad).success( |
75 function(data, status, header, config) { | 75 function(data, status, header, config) { |
76 var dataHeader = data[constants.KEY__HEADER]; | 76 var dataHeader = data[constants.KEY__HEADER]; |
77 if (dataHeader[constants.KEY__HEADER__IS_STILL_LOADING]) { | 77 if (dataHeader[constants.KEY__HEADER__IS_STILL_LOADING]) { |
78 // Apply the server's requested reload delay to local time, | |
79 // so we will wait the right number of seconds regardless of clock | |
80 // skew between client and server. | |
81 var reloadDelayInSeconds = | |
82 dataHeader[constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE] - | |
83 dataHeader[constants.KEY__HEADER__TIME_UPDATED]; | |
84 var timeNow = new Date().getTime(); | |
85 var timeToReload = timeNow + reloadDelayInSeconds * 1000; | |
78 $scope.loadingMessage = | 86 $scope.loadingMessage = |
79 "Server is still loading results; will retry at " + | 87 "Server is still loading results; will retry at " + |
80 $scope.localTimeString(dataHeader[ | 88 $scope.localTimeString(timeToReload / 1000); |
borenet
2014/03/10 17:51:14
Why not store this in a timeToReloadInSeconds vari
epoger
2014/03/10 18:04:47
The problem with that, is that I would need to div
| |
81 constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE]); | |
82 $timeout( | 89 $timeout( |
83 function(){location.reload();}, | 90 function(){location.reload();}, |
84 (dataHeader[constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE] | 91 timeToReload - timeNow); |
85 * 1000) - new Date().getTime()); | |
86 } else { | 92 } else { |
87 $scope.loadingMessage = "Processing data, please wait..."; | 93 $scope.loadingMessage = "Processing data, please wait..."; |
88 | 94 |
89 $scope.header = dataHeader; | 95 $scope.header = dataHeader; |
90 $scope.extraColumnHeaders = data[constants.KEY__EXTRACOLUMNHEADERS]; | 96 $scope.extraColumnHeaders = data[constants.KEY__EXTRACOLUMNHEADERS]; |
91 $scope.imagePairs = data[constants.KEY__IMAGEPAIRS]; | 97 $scope.imagePairs = data[constants.KEY__IMAGEPAIRS]; |
92 $scope.imageSets = data[constants.KEY__IMAGESETS]; | 98 $scope.imageSets = data[constants.KEY__IMAGESETS]; |
93 $scope.sortColumnSubdict = constants.KEY__DIFFERENCE_DATA; | 99 $scope.sortColumnSubdict = constants.KEY__DIFFERENCE_DATA; |
94 $scope.sortColumnKey = constants.KEY__DIFFERENCE_DATA__WEIGHTED_DIFF; | 100 $scope.sortColumnKey = constants.KEY__DIFFERENCE_DATA__WEIGHTED_DIFF; |
95 | 101 |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
779 */ | 785 */ |
780 $scope.getImageDiffRelativeUrl = function(imagePair) { | 786 $scope.getImageDiffRelativeUrl = function(imagePair) { |
781 var before = | 787 var before = |
782 imagePair[constants.KEY__IMAGE_A_URL] + "-vs-" + | 788 imagePair[constants.KEY__IMAGE_A_URL] + "-vs-" + |
783 imagePair[constants.KEY__IMAGE_B_URL]; | 789 imagePair[constants.KEY__IMAGE_B_URL]; |
784 return before.replace(/[^\w\-]/g, "_") + ".png"; | 790 return before.replace(/[^\w\-]/g, "_") + ".png"; |
785 } | 791 } |
786 | 792 |
787 } | 793 } |
788 ); | 794 ); |
OLD | NEW |