2013-09-27 15:02:44 +00:00
|
|
|
/*
|
|
|
|
* Loader:
|
2013-09-30 15:06:25 +00:00
|
|
|
* Reads GM result reports written out by results.py, and imports
|
2014-02-26 19:05:20 +00:00
|
|
|
* them into $scope.extraColumnHeaders and $scope.imagePairs .
|
2013-09-27 15:02:44 +00:00
|
|
|
*/
|
|
|
|
var Loader = angular.module(
|
|
|
|
'Loader',
|
2014-02-26 19:05:20 +00:00
|
|
|
['ConstantsModule', 'diff_viewer']
|
2013-09-27 15:02:44 +00:00
|
|
|
);
|
2013-10-02 18:57:48 +00:00
|
|
|
|
2014-03-10 15:36:06 +00:00
|
|
|
Loader.directive(
|
|
|
|
'resultsUpdatedCallbackDirective',
|
|
|
|
['$timeout',
|
|
|
|
function($timeout) {
|
|
|
|
return function(scope, element, attrs) {
|
|
|
|
if (scope.$last) {
|
|
|
|
$timeout(function() {
|
|
|
|
scope.resultsUpdatedCallback();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
2013-10-02 18:57:48 +00:00
|
|
|
// TODO(epoger): Combine ALL of our filtering operations (including
|
|
|
|
// truncation) into this one filter, so that runs most efficiently?
|
|
|
|
// (We would have to make sure truncation still took place after
|
|
|
|
// sorting, though.)
|
|
|
|
Loader.filter(
|
2014-02-26 19:05:20 +00:00
|
|
|
'removeHiddenImagePairs',
|
|
|
|
function(constants) {
|
|
|
|
return function(unfilteredImagePairs, hiddenResultTypes, hiddenConfigs,
|
2013-10-29 15:49:40 +00:00
|
|
|
builderSubstring, testSubstring, viewingTab) {
|
2014-02-26 19:05:20 +00:00
|
|
|
var filteredImagePairs = [];
|
|
|
|
for (var i = 0; i < unfilteredImagePairs.length; i++) {
|
|
|
|
var imagePair = unfilteredImagePairs[i];
|
|
|
|
var extraColumnValues = imagePair[constants.KEY__EXTRA_COLUMN_VALUES];
|
2013-10-26 14:31:11 +00:00
|
|
|
// For performance, we examine the "set" objects directly rather
|
|
|
|
// than calling $scope.isValueInSet().
|
|
|
|
// Besides, I don't think we have access to $scope in here...
|
2014-02-26 19:05:20 +00:00
|
|
|
if (!(true == hiddenResultTypes[extraColumnValues[
|
|
|
|
constants.KEY__EXTRACOLUMN__RESULT_TYPE]]) &&
|
|
|
|
!(true == hiddenConfigs[extraColumnValues[
|
|
|
|
constants.KEY__EXTRACOLUMN__CONFIG]]) &&
|
|
|
|
!(-1 == extraColumnValues[constants.KEY__EXTRACOLUMN__BUILDER]
|
|
|
|
.indexOf(builderSubstring)) &&
|
|
|
|
!(-1 == extraColumnValues[constants.KEY__EXTRACOLUMN__TEST]
|
|
|
|
.indexOf(testSubstring)) &&
|
|
|
|
(viewingTab == imagePair.tab)) {
|
|
|
|
filteredImagePairs.push(imagePair);
|
2013-10-09 18:05:58 +00:00
|
|
|
}
|
2013-10-02 18:57:48 +00:00
|
|
|
}
|
2014-02-26 19:05:20 +00:00
|
|
|
return filteredImagePairs;
|
2013-10-02 18:57:48 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
|
2013-09-27 15:02:44 +00:00
|
|
|
Loader.controller(
|
|
|
|
'Loader.Controller',
|
2014-03-10 15:36:06 +00:00
|
|
|
function($scope, $http, $filter, $location, $log, $timeout, constants) {
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.constants = constants;
|
2013-10-15 20:10:33 +00:00
|
|
|
$scope.windowTitle = "Loading GM Results...";
|
2013-12-05 18:03:24 +00:00
|
|
|
$scope.resultsToLoad = $location.search().resultsToLoad;
|
|
|
|
$scope.loadingMessage = "Loading results of type '" + $scope.resultsToLoad +
|
2013-10-11 18:45:33 +00:00
|
|
|
"', please wait...";
|
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
/**
|
|
|
|
* On initial page load, load a full dictionary of results.
|
|
|
|
* Once the dictionary is loaded, unhide the page elements so they can
|
|
|
|
* render the data.
|
|
|
|
*/
|
2013-12-05 18:03:24 +00:00
|
|
|
$http.get("/results/" + $scope.resultsToLoad).success(
|
2013-10-11 18:45:33 +00:00
|
|
|
function(data, status, header, config) {
|
2014-02-26 19:05:20 +00:00
|
|
|
var dataHeader = data[constants.KEY__HEADER];
|
|
|
|
if (dataHeader[constants.KEY__HEADER__IS_STILL_LOADING]) {
|
2014-03-10 18:05:15 +00:00
|
|
|
// Apply the server's requested reload delay to local time,
|
|
|
|
// so we will wait the right number of seconds regardless of clock
|
|
|
|
// skew between client and server.
|
|
|
|
var reloadDelayInSeconds =
|
|
|
|
dataHeader[constants.KEY__HEADER__TIME_NEXT_UPDATE_AVAILABLE] -
|
|
|
|
dataHeader[constants.KEY__HEADER__TIME_UPDATED];
|
|
|
|
var timeNow = new Date().getTime();
|
|
|
|
var timeToReload = timeNow + reloadDelayInSeconds * 1000;
|
2013-12-05 16:05:16 +00:00
|
|
|
$scope.loadingMessage =
|
2013-12-17 18:06:13 +00:00
|
|
|
"Server is still loading results; will retry at " +
|
2014-03-10 18:05:15 +00:00
|
|
|
$scope.localTimeString(timeToReload / 1000);
|
2013-12-05 16:05:16 +00:00
|
|
|
$timeout(
|
|
|
|
function(){location.reload();},
|
2014-03-10 18:05:15 +00:00
|
|
|
timeToReload - timeNow);
|
2013-12-05 16:05:16 +00:00
|
|
|
} else {
|
|
|
|
$scope.loadingMessage = "Processing data, please wait...";
|
|
|
|
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.header = dataHeader;
|
|
|
|
$scope.extraColumnHeaders = data[constants.KEY__EXTRACOLUMNHEADERS];
|
|
|
|
$scope.imagePairs = data[constants.KEY__IMAGEPAIRS];
|
|
|
|
$scope.imageSets = data[constants.KEY__IMAGESETS];
|
|
|
|
$scope.sortColumnSubdict = constants.KEY__DIFFERENCE_DATA;
|
|
|
|
$scope.sortColumnKey = constants.KEY__DIFFERENCE_DATA__WEIGHTED_DIFF;
|
2013-12-05 16:05:16 +00:00
|
|
|
|
|
|
|
$scope.showSubmitAdvancedSettings = false;
|
|
|
|
$scope.submitAdvancedSettings = {};
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.submitAdvancedSettings[
|
|
|
|
constants.KEY__EXPECTATIONS__REVIEWED] = true;
|
|
|
|
$scope.submitAdvancedSettings[
|
|
|
|
constants.KEY__EXPECTATIONS__IGNOREFAILURE] = false;
|
2013-12-05 16:05:16 +00:00
|
|
|
$scope.submitAdvancedSettings['bug'] = '';
|
|
|
|
|
|
|
|
// Create the list of tabs (lists into which the user can file each
|
|
|
|
// test). This may vary, depending on isEditable.
|
|
|
|
$scope.tabs = [
|
|
|
|
'Unfiled', 'Hidden'
|
|
|
|
];
|
2014-02-26 19:05:20 +00:00
|
|
|
if (dataHeader[constants.KEY__HEADER__IS_EDITABLE]) {
|
2013-12-05 16:05:16 +00:00
|
|
|
$scope.tabs = $scope.tabs.concat(
|
|
|
|
['Pending Approval']);
|
|
|
|
}
|
|
|
|
$scope.defaultTab = $scope.tabs[0];
|
|
|
|
$scope.viewingTab = $scope.defaultTab;
|
|
|
|
|
|
|
|
// Track the number of results on each tab.
|
|
|
|
$scope.numResultsPerTab = {};
|
|
|
|
for (var i = 0; i < $scope.tabs.length; i++) {
|
|
|
|
$scope.numResultsPerTab[$scope.tabs[i]] = 0;
|
|
|
|
}
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.numResultsPerTab[$scope.defaultTab] = $scope.imagePairs.length;
|
2013-12-05 16:05:16 +00:00
|
|
|
|
|
|
|
// Add index and tab fields to all records.
|
2014-02-26 19:05:20 +00:00
|
|
|
for (var i = 0; i < $scope.imagePairs.length; i++) {
|
|
|
|
$scope.imagePairs[i].index = i;
|
|
|
|
$scope.imagePairs[i].tab = $scope.defaultTab;
|
2013-12-05 16:05:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Arrays within which the user can toggle individual elements.
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.selectedImagePairs = [];
|
2013-12-05 16:05:16 +00:00
|
|
|
|
|
|
|
// Sets within which the user can toggle individual elements.
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.hiddenResultTypes = {};
|
|
|
|
$scope.hiddenResultTypes[
|
|
|
|
constants.KEY__RESULT_TYPE__FAILUREIGNORED] = true;
|
|
|
|
$scope.hiddenResultTypes[
|
|
|
|
constants.KEY__RESULT_TYPE__NOCOMPARISON] = true;
|
|
|
|
$scope.hiddenResultTypes[
|
|
|
|
constants.KEY__RESULT_TYPE__SUCCEEDED] = true;
|
|
|
|
$scope.allResultTypes = Object.keys(
|
|
|
|
$scope.extraColumnHeaders[constants.KEY__EXTRACOLUMN__RESULT_TYPE]
|
|
|
|
[constants.KEY__VALUES_AND_COUNTS]);
|
2013-12-05 16:05:16 +00:00
|
|
|
$scope.hiddenConfigs = {};
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.allConfigs = Object.keys(
|
|
|
|
$scope.extraColumnHeaders[constants.KEY__EXTRACOLUMN__CONFIG]
|
|
|
|
[constants.KEY__VALUES_AND_COUNTS]);
|
2013-12-05 16:05:16 +00:00
|
|
|
|
|
|
|
// Associative array of partial string matches per category.
|
|
|
|
$scope.categoryValueMatch = {};
|
|
|
|
$scope.categoryValueMatch.builder = "";
|
|
|
|
$scope.categoryValueMatch.test = "";
|
|
|
|
|
2013-12-05 18:03:24 +00:00
|
|
|
// If any defaults were overridden in the URL, get them now.
|
|
|
|
$scope.queryParameters.load();
|
|
|
|
|
2013-12-05 16:05:16 +00:00
|
|
|
$scope.updateResults();
|
|
|
|
$scope.loadingMessage = "";
|
|
|
|
$scope.windowTitle = "Current GM Results";
|
2013-10-23 15:07:26 +00:00
|
|
|
}
|
2013-10-11 18:45:33 +00:00
|
|
|
}
|
|
|
|
).error(
|
|
|
|
function(data, status, header, config) {
|
|
|
|
$scope.loadingMessage = "Failed to load results of type '"
|
2013-12-05 18:03:24 +00:00
|
|
|
+ $scope.resultsToLoad + "'";
|
2013-10-15 20:10:33 +00:00
|
|
|
$scope.windowTitle = "Failed to Load GM Results";
|
2013-09-27 15:02:44 +00:00
|
|
|
}
|
|
|
|
);
|
2013-10-02 18:57:48 +00:00
|
|
|
|
|
|
|
|
2013-10-26 14:31:11 +00:00
|
|
|
//
|
|
|
|
// Select/Clear/Toggle all tests.
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Select all currently showing tests.
|
|
|
|
*/
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.selectAllImagePairs = function() {
|
|
|
|
var numImagePairsShowing = $scope.limitedImagePairs.length;
|
|
|
|
for (var i = 0; i < numImagePairsShowing; i++) {
|
|
|
|
var index = $scope.limitedImagePairs[i].index;
|
|
|
|
if (!$scope.isValueInArray(index, $scope.selectedImagePairs)) {
|
|
|
|
$scope.toggleValueInArray(index, $scope.selectedImagePairs);
|
2013-10-26 14:31:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deselect all currently showing tests.
|
|
|
|
*/
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.clearAllImagePairs = function() {
|
|
|
|
var numImagePairsShowing = $scope.limitedImagePairs.length;
|
|
|
|
for (var i = 0; i < numImagePairsShowing; i++) {
|
|
|
|
var index = $scope.limitedImagePairs[i].index;
|
|
|
|
if ($scope.isValueInArray(index, $scope.selectedImagePairs)) {
|
|
|
|
$scope.toggleValueInArray(index, $scope.selectedImagePairs);
|
2013-10-26 14:31:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle selection of all currently showing tests.
|
|
|
|
*/
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.toggleAllImagePairs = function() {
|
|
|
|
var numImagePairsShowing = $scope.limitedImagePairs.length;
|
|
|
|
for (var i = 0; i < numImagePairsShowing; i++) {
|
|
|
|
var index = $scope.limitedImagePairs[i].index;
|
|
|
|
$scope.toggleValueInArray(index, $scope.selectedImagePairs);
|
2013-10-26 14:31:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
//
|
|
|
|
// Tab operations.
|
|
|
|
//
|
2013-10-02 18:57:48 +00:00
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
/**
|
|
|
|
* Change the selected tab.
|
|
|
|
*
|
|
|
|
* @param tab (string): name of the tab to select
|
|
|
|
*/
|
2013-10-23 15:07:26 +00:00
|
|
|
$scope.setViewingTab = function(tab) {
|
|
|
|
$scope.viewingTab = tab;
|
|
|
|
$scope.updateResults();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-02-26 19:05:20 +00:00
|
|
|
* Move the imagePairs in $scope.selectedImagePairs to a different tab,
|
|
|
|
* and then clear $scope.selectedImagePairs.
|
2013-10-23 15:07:26 +00:00
|
|
|
*
|
|
|
|
* @param newTab (string): name of the tab to move the tests to
|
|
|
|
*/
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.moveSelectedImagePairsToTab = function(newTab) {
|
|
|
|
$scope.moveImagePairsToTab($scope.selectedImagePairs, newTab);
|
|
|
|
$scope.selectedImagePairs = [];
|
2013-10-23 15:07:26 +00:00
|
|
|
$scope.updateResults();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-02-26 19:05:20 +00:00
|
|
|
* Move a subset of $scope.imagePairs to a different tab.
|
2013-10-23 15:07:26 +00:00
|
|
|
*
|
2014-02-26 19:05:20 +00:00
|
|
|
* @param imagePairIndices (array of ints): indices into $scope.imagePairs
|
2013-10-23 15:07:26 +00:00
|
|
|
* indicating which test results to move
|
|
|
|
* @param newTab (string): name of the tab to move the tests to
|
|
|
|
*/
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.moveImagePairsToTab = function(imagePairIndices, newTab) {
|
|
|
|
var imagePairIndex;
|
|
|
|
var numImagePairs = imagePairIndices.length;
|
|
|
|
for (var i = 0; i < numImagePairs; i++) {
|
|
|
|
imagePairIndex = imagePairIndices[i];
|
|
|
|
$scope.numResultsPerTab[$scope.imagePairs[imagePairIndex].tab]--;
|
|
|
|
$scope.imagePairs[imagePairIndex].tab = newTab;
|
2013-10-23 15:07:26 +00:00
|
|
|
}
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.numResultsPerTab[newTab] += numImagePairs;
|
2013-10-23 15:07:26 +00:00
|
|
|
}
|
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
|
2013-12-05 18:03:24 +00:00
|
|
|
//
|
|
|
|
// $scope.queryParameters:
|
|
|
|
// Transfer parameter values between $scope and the URL query string.
|
|
|
|
//
|
|
|
|
$scope.queryParameters = {};
|
|
|
|
|
|
|
|
// load and save functions for parameters of each type
|
|
|
|
// (load a parameter value into $scope from nameValuePairs,
|
|
|
|
// save a parameter value from $scope into nameValuePairs)
|
|
|
|
$scope.queryParameters.copiers = {
|
|
|
|
'simple': {
|
|
|
|
'load': function(nameValuePairs, name) {
|
|
|
|
var value = nameValuePairs[name];
|
|
|
|
if (value) {
|
|
|
|
$scope[name] = value;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'save': function(nameValuePairs, name) {
|
|
|
|
nameValuePairs[name] = $scope[name];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'categoryValueMatch': {
|
|
|
|
'load': function(nameValuePairs, name) {
|
|
|
|
var value = nameValuePairs[name];
|
|
|
|
if (value) {
|
|
|
|
$scope.categoryValueMatch[name] = value;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'save': function(nameValuePairs, name) {
|
|
|
|
nameValuePairs[name] = $scope.categoryValueMatch[name];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
'set': {
|
|
|
|
'load': function(nameValuePairs, name) {
|
|
|
|
var value = nameValuePairs[name];
|
|
|
|
if (value) {
|
|
|
|
var valueArray = value.split(',');
|
|
|
|
$scope[name] = {};
|
|
|
|
$scope.toggleValuesInSet(valueArray, $scope[name]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'save': function(nameValuePairs, name) {
|
|
|
|
nameValuePairs[name] = Object.keys($scope[name]).join(',');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// parameter name -> copier objects to load/save parameter value
|
|
|
|
$scope.queryParameters.map = {
|
2014-03-05 19:46:17 +00:00
|
|
|
'resultsToLoad': $scope.queryParameters.copiers.simple,
|
|
|
|
'displayLimitPending': $scope.queryParameters.copiers.simple,
|
|
|
|
'showThumbnailsPending': $scope.queryParameters.copiers.simple,
|
|
|
|
'imageSizePending': $scope.queryParameters.copiers.simple,
|
|
|
|
'sortColumnSubdict': $scope.queryParameters.copiers.simple,
|
|
|
|
'sortColumnKey': $scope.queryParameters.copiers.simple,
|
2013-12-05 18:03:24 +00:00
|
|
|
|
|
|
|
'hiddenResultTypes': $scope.queryParameters.copiers.set,
|
|
|
|
'hiddenConfigs': $scope.queryParameters.copiers.set,
|
|
|
|
};
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.queryParameters.map[constants.KEY__EXTRACOLUMN__BUILDER] =
|
|
|
|
$scope.queryParameters.copiers.categoryValueMatch;
|
|
|
|
$scope.queryParameters.map[constants.KEY__EXTRACOLUMN__TEST] =
|
|
|
|
$scope.queryParameters.copiers.categoryValueMatch;
|
2013-12-05 18:03:24 +00:00
|
|
|
|
|
|
|
// Loads all parameters into $scope from the URL query string;
|
|
|
|
// any which are not found within the URL will keep their current value.
|
|
|
|
$scope.queryParameters.load = function() {
|
|
|
|
var nameValuePairs = $location.search();
|
|
|
|
angular.forEach($scope.queryParameters.map,
|
|
|
|
function(copier, paramName) {
|
|
|
|
copier.load(nameValuePairs, paramName);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Saves all parameters from $scope into the URL query string.
|
|
|
|
$scope.queryParameters.save = function() {
|
|
|
|
var nameValuePairs = {};
|
|
|
|
angular.forEach($scope.queryParameters.map,
|
|
|
|
function(copier, paramName) {
|
|
|
|
copier.save(nameValuePairs, paramName);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
$location.search(nameValuePairs);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
//
|
|
|
|
// updateResults() and friends.
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set $scope.areUpdatesPending (to enable/disable the Update Results
|
|
|
|
* button).
|
|
|
|
*
|
|
|
|
* TODO(epoger): We could reduce the amount of code by just setting the
|
|
|
|
* variable directly (from, e.g., a button's ng-click handler). But when
|
|
|
|
* I tried that, the HTML elements depending on the variable did not get
|
|
|
|
* updated.
|
|
|
|
* It turns out that this is due to variable scoping within an ng-repeat
|
|
|
|
* element; see http://stackoverflow.com/questions/15388344/behavior-of-assignment-expression-invoked-by-ng-click-within-ng-repeat
|
|
|
|
*
|
|
|
|
* @param val boolean value to set $scope.areUpdatesPending to
|
|
|
|
*/
|
|
|
|
$scope.setUpdatesPending = function(val) {
|
|
|
|
$scope.areUpdatesPending = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-12-05 18:03:24 +00:00
|
|
|
* Update the displayed results, based on filters/settings,
|
|
|
|
* and call $scope.queryParameters.save() so that the new filter results
|
|
|
|
* can be bookmarked.
|
2013-10-24 15:38:27 +00:00
|
|
|
*/
|
2013-10-02 18:57:48 +00:00
|
|
|
$scope.updateResults = function() {
|
2014-03-10 15:36:06 +00:00
|
|
|
$scope.renderStartTime = window.performance.now();
|
|
|
|
$log.debug("renderStartTime: " + $scope.renderStartTime);
|
2013-10-02 18:57:48 +00:00
|
|
|
$scope.displayLimit = $scope.displayLimitPending;
|
|
|
|
// TODO(epoger): Every time we apply a filter, AngularJS creates
|
|
|
|
// another copy of the array. Is there a way we can filter out
|
2014-02-26 19:05:20 +00:00
|
|
|
// the imagePairs as they are displayed, rather than storing multiple
|
2013-10-02 18:57:48 +00:00
|
|
|
// array copies? (For better performance.)
|
2013-10-23 15:07:26 +00:00
|
|
|
|
|
|
|
if ($scope.viewingTab == $scope.defaultTab) {
|
2013-11-08 16:25:25 +00:00
|
|
|
|
|
|
|
// TODO(epoger): Until we allow the user to reverse sort order,
|
|
|
|
// there are certain columns we want to sort in a different order.
|
|
|
|
var doReverse = (
|
2014-02-26 19:05:20 +00:00
|
|
|
($scope.sortColumnKey ==
|
|
|
|
constants.KEY__DIFFERENCE_DATA__PERCENT_DIFF_PIXELS) ||
|
|
|
|
($scope.sortColumnKey ==
|
|
|
|
constants.KEY__DIFFERENCE_DATA__WEIGHTED_DIFF));
|
2013-11-08 16:25:25 +00:00
|
|
|
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.filteredImagePairs =
|
2013-10-23 15:07:26 +00:00
|
|
|
$filter("orderBy")(
|
2014-02-26 19:05:20 +00:00
|
|
|
$filter("removeHiddenImagePairs")(
|
|
|
|
$scope.imagePairs,
|
2013-10-23 15:07:26 +00:00
|
|
|
$scope.hiddenResultTypes,
|
|
|
|
$scope.hiddenConfigs,
|
2013-10-29 15:49:40 +00:00
|
|
|
$scope.categoryValueMatch.builder,
|
|
|
|
$scope.categoryValueMatch.test,
|
2013-10-23 15:07:26 +00:00
|
|
|
$scope.viewingTab
|
|
|
|
),
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.getSortColumnValue, doReverse);
|
|
|
|
$scope.limitedImagePairs = $filter("limitTo")(
|
|
|
|
$scope.filteredImagePairs, $scope.displayLimit);
|
2013-10-23 15:07:26 +00:00
|
|
|
} else {
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.filteredImagePairs =
|
2013-10-23 15:07:26 +00:00
|
|
|
$filter("orderBy")(
|
|
|
|
$filter("filter")(
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.imagePairs,
|
2013-10-23 15:07:26 +00:00
|
|
|
{tab: $scope.viewingTab},
|
|
|
|
true
|
|
|
|
),
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.getSortColumnValue);
|
|
|
|
$scope.limitedImagePairs = $scope.filteredImagePairs;
|
2013-10-23 15:07:26 +00:00
|
|
|
}
|
2014-03-05 19:46:17 +00:00
|
|
|
$scope.showThumbnails = $scope.showThumbnailsPending;
|
2013-10-02 18:57:48 +00:00
|
|
|
$scope.imageSize = $scope.imageSizePending;
|
2013-10-24 15:38:27 +00:00
|
|
|
$scope.setUpdatesPending(false);
|
2013-12-05 18:03:24 +00:00
|
|
|
$scope.queryParameters.save();
|
2013-10-02 18:57:48 +00:00
|
|
|
}
|
|
|
|
|
2014-03-10 15:36:06 +00:00
|
|
|
/**
|
|
|
|
* This function is called when the results have been completely rendered
|
|
|
|
* after updateResults().
|
|
|
|
*/
|
|
|
|
$scope.resultsUpdatedCallback = function() {
|
|
|
|
$scope.renderEndTime = window.performance.now();
|
|
|
|
$log.debug("renderEndTime: " + $scope.renderEndTime);
|
|
|
|
}
|
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
/**
|
|
|
|
* Re-sort the displayed results.
|
|
|
|
*
|
2014-02-26 19:05:20 +00:00
|
|
|
* @param subdict (string): which subdictionary
|
|
|
|
* (constants.KEY__DIFFERENCE_DATA, constants.KEY__EXPECTATIONS_DATA,
|
|
|
|
* constants.KEY__EXTRA_COLUMN_VALUES) the sort column key is within
|
|
|
|
* @param key (string): sort by value associated with this key in subdict
|
2013-10-24 15:38:27 +00:00
|
|
|
*/
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.sortResultsBy = function(subdict, key) {
|
|
|
|
$scope.sortColumnSubdict = subdict;
|
|
|
|
$scope.sortColumnKey = key;
|
2013-10-02 18:57:48 +00:00
|
|
|
$scope.updateResults();
|
|
|
|
}
|
2013-10-23 15:07:26 +00:00
|
|
|
|
2014-02-26 19:05:20 +00:00
|
|
|
/**
|
|
|
|
* For a particular ImagePair, return the value of the column we are
|
|
|
|
* sorting on (according to $scope.sortColumnSubdict and
|
|
|
|
* $scope.sortColumnKey).
|
|
|
|
*
|
|
|
|
* @param imagePair: imagePair to get a column value out of.
|
|
|
|
*/
|
|
|
|
$scope.getSortColumnValue = function(imagePair) {
|
|
|
|
if ($scope.sortColumnSubdict in imagePair) {
|
|
|
|
return imagePair[$scope.sortColumnSubdict][$scope.sortColumnKey];
|
|
|
|
} else {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-29 15:49:40 +00:00
|
|
|
/**
|
|
|
|
* Set $scope.categoryValueMatch[name] = value, and update results.
|
|
|
|
*
|
|
|
|
* @param name
|
|
|
|
* @param value
|
|
|
|
*/
|
|
|
|
$scope.setCategoryValueMatch = function(name, value) {
|
|
|
|
$scope.categoryValueMatch[name] = value;
|
|
|
|
$scope.updateResults();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update $scope.hiddenResultTypes so that ONLY this resultType is showing,
|
|
|
|
* and update the visible results.
|
|
|
|
*
|
|
|
|
* @param resultType
|
|
|
|
*/
|
|
|
|
$scope.showOnlyResultType = function(resultType) {
|
|
|
|
$scope.hiddenResultTypes = {};
|
|
|
|
// TODO(epoger): Maybe change $scope.allResultTypes to be a Set like
|
|
|
|
// $scope.hiddenResultTypes (rather than an array), so this operation is
|
|
|
|
// simpler (just assign or add allResultTypes to hiddenResultTypes).
|
|
|
|
$scope.toggleValuesInSet($scope.allResultTypes, $scope.hiddenResultTypes);
|
|
|
|
$scope.toggleValueInSet(resultType, $scope.hiddenResultTypes);
|
|
|
|
$scope.updateResults();
|
|
|
|
}
|
|
|
|
|
2014-02-06 20:22:25 +00:00
|
|
|
/**
|
|
|
|
* Update $scope.hiddenResultTypes so that ALL resultTypes are showing,
|
|
|
|
* and update the visible results.
|
|
|
|
*/
|
|
|
|
$scope.showAllResultTypes = function() {
|
|
|
|
$scope.hiddenResultTypes = {};
|
|
|
|
$scope.updateResults();
|
|
|
|
}
|
|
|
|
|
2013-10-29 15:49:40 +00:00
|
|
|
/**
|
|
|
|
* Update $scope.hiddenConfigs so that ONLY this config is showing,
|
|
|
|
* and update the visible results.
|
|
|
|
*
|
|
|
|
* @param config
|
|
|
|
*/
|
|
|
|
$scope.showOnlyConfig = function(config) {
|
|
|
|
$scope.hiddenConfigs = {};
|
|
|
|
$scope.toggleValuesInSet($scope.allConfigs, $scope.hiddenConfigs);
|
|
|
|
$scope.toggleValueInSet(config, $scope.hiddenConfigs);
|
|
|
|
$scope.updateResults();
|
|
|
|
}
|
|
|
|
|
2014-02-06 20:22:25 +00:00
|
|
|
/**
|
|
|
|
* Update $scope.hiddenConfigs so that ALL configs are showing,
|
|
|
|
* and update the visible results.
|
|
|
|
*/
|
|
|
|
$scope.showAllConfigs = function() {
|
|
|
|
$scope.hiddenConfigs = {};
|
|
|
|
$scope.updateResults();
|
|
|
|
}
|
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Operations for sending info back to the server.
|
|
|
|
//
|
|
|
|
|
2013-10-23 15:07:26 +00:00
|
|
|
/**
|
|
|
|
* Tell the server that the actual results of these particular tests
|
|
|
|
* are acceptable.
|
|
|
|
*
|
2014-02-26 19:05:20 +00:00
|
|
|
* TODO(epoger): This assumes that the original expectations are in
|
|
|
|
* imageSetA, and the actuals are in imageSetB.
|
|
|
|
*
|
|
|
|
* @param imagePairsSubset an array of test results, most likely a subset of
|
|
|
|
* $scope.imagePairs (perhaps with some modifications)
|
2013-10-23 15:07:26 +00:00
|
|
|
*/
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.submitApprovals = function(imagePairsSubset) {
|
2013-10-23 15:07:26 +00:00
|
|
|
$scope.submitPending = true;
|
2013-10-26 14:31:11 +00:00
|
|
|
|
|
|
|
// Convert bug text field to null or 1-item array.
|
|
|
|
var bugs = null;
|
|
|
|
var bugNumber = parseInt($scope.submitAdvancedSettings['bug']);
|
|
|
|
if (!isNaN(bugNumber)) {
|
|
|
|
bugs = [bugNumber];
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(epoger): This is a suboptimal way to prevent users from
|
|
|
|
// rebaselining failures in alternative renderModes, but it does work.
|
|
|
|
// For a better solution, see
|
|
|
|
// https://code.google.com/p/skia/issues/detail?id=1748 ('gm: add new
|
|
|
|
// result type, RenderModeMismatch')
|
|
|
|
var encounteredComparisonConfig = false;
|
|
|
|
|
2014-02-26 19:05:20 +00:00
|
|
|
var updatedExpectations = [];
|
|
|
|
for (var i = 0; i < imagePairsSubset.length; i++) {
|
|
|
|
var imagePair = imagePairsSubset[i];
|
|
|
|
var updatedExpectation = {};
|
|
|
|
updatedExpectation[constants.KEY__EXPECTATIONS_DATA] =
|
|
|
|
imagePair[constants.KEY__EXPECTATIONS_DATA];
|
|
|
|
updatedExpectation[constants.KEY__EXTRA_COLUMN_VALUES] =
|
|
|
|
imagePair[constants.KEY__EXTRA_COLUMN_VALUES];
|
|
|
|
updatedExpectation[constants.KEY__NEW_IMAGE_URL] =
|
|
|
|
imagePair[constants.KEY__IMAGE_B_URL];
|
|
|
|
if (0 == updatedExpectation[constants.KEY__EXTRA_COLUMN_VALUES]
|
|
|
|
[constants.KEY__EXTRACOLUMN__CONFIG]
|
|
|
|
.indexOf('comparison-')) {
|
2013-10-26 14:31:11 +00:00
|
|
|
encounteredComparisonConfig = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Advanced settings...
|
2014-02-26 19:05:20 +00:00
|
|
|
if (null == updatedExpectation[constants.KEY__EXPECTATIONS_DATA]) {
|
|
|
|
updatedExpectation[constants.KEY__EXPECTATIONS_DATA] = {};
|
|
|
|
}
|
|
|
|
updatedExpectation[constants.KEY__EXPECTATIONS_DATA]
|
|
|
|
[constants.KEY__EXPECTATIONS__REVIEWED] =
|
|
|
|
$scope.submitAdvancedSettings[
|
|
|
|
constants.KEY__EXPECTATIONS__REVIEWED];
|
|
|
|
if (true == $scope.submitAdvancedSettings[
|
|
|
|
constants.KEY__EXPECTATIONS__IGNOREFAILURE]) {
|
2013-10-26 14:31:11 +00:00
|
|
|
// if it's false, don't send it at all (just keep the default)
|
2014-02-26 19:05:20 +00:00
|
|
|
updatedExpectation[constants.KEY__EXPECTATIONS_DATA]
|
|
|
|
[constants.KEY__EXPECTATIONS__IGNOREFAILURE] = true;
|
2013-10-26 14:31:11 +00:00
|
|
|
}
|
2014-02-26 19:05:20 +00:00
|
|
|
updatedExpectation[constants.KEY__EXPECTATIONS_DATA]
|
|
|
|
[constants.KEY__EXPECTATIONS__BUGS] = bugs;
|
2013-10-26 14:31:11 +00:00
|
|
|
|
2014-02-26 19:05:20 +00:00
|
|
|
updatedExpectations.push(updatedExpectation);
|
2013-10-23 15:07:26 +00:00
|
|
|
}
|
2013-10-26 14:31:11 +00:00
|
|
|
if (encounteredComparisonConfig) {
|
|
|
|
alert("Approval failed -- you cannot approve results with config " +
|
|
|
|
"type comparison-*");
|
|
|
|
$scope.submitPending = false;
|
|
|
|
return;
|
|
|
|
}
|
2014-02-26 19:05:20 +00:00
|
|
|
var modificationData = {};
|
|
|
|
modificationData[constants.KEY__EDITS__MODIFICATIONS] =
|
|
|
|
updatedExpectations;
|
|
|
|
modificationData[constants.KEY__EDITS__OLD_RESULTS_HASH] =
|
|
|
|
$scope.header[constants.KEY__HEADER__DATAHASH];
|
|
|
|
modificationData[constants.KEY__EDITS__OLD_RESULTS_TYPE] =
|
|
|
|
$scope.header[constants.KEY__HEADER__TYPE];
|
2013-10-23 15:07:26 +00:00
|
|
|
$http({
|
|
|
|
method: "POST",
|
|
|
|
url: "/edits",
|
2014-02-26 19:05:20 +00:00
|
|
|
data: modificationData
|
2013-10-23 15:07:26 +00:00
|
|
|
}).success(function(data, status, headers, config) {
|
2014-02-26 19:05:20 +00:00
|
|
|
var imagePairIndicesToMove = [];
|
|
|
|
for (var i = 0; i < imagePairsSubset.length; i++) {
|
|
|
|
imagePairIndicesToMove.push(imagePairsSubset[i].index);
|
2013-10-23 15:07:26 +00:00
|
|
|
}
|
2014-02-26 19:05:20 +00:00
|
|
|
$scope.moveImagePairsToTab(imagePairIndicesToMove,
|
|
|
|
"HackToMakeSureThisImagePairDisappears");
|
2013-10-23 15:07:26 +00:00
|
|
|
$scope.updateResults();
|
|
|
|
alert("New baselines submitted successfully!\n\n" +
|
|
|
|
"You still need to commit the updated expectations files on " +
|
|
|
|
"the server side to the Skia repo.\n\n" +
|
2013-12-17 18:06:13 +00:00
|
|
|
"When you click OK, your web UI will reload; after that " +
|
|
|
|
"completes, you will see the updated data (once the server has " +
|
|
|
|
"finished loading the update results into memory!) and you can " +
|
|
|
|
"submit more baselines if you want.");
|
|
|
|
// I don't know why, but if I just call reload() here it doesn't work.
|
|
|
|
// Making a timer call it fixes the problem.
|
|
|
|
$timeout(function(){location.reload();}, 1);
|
2013-10-23 15:07:26 +00:00
|
|
|
}).error(function(data, status, headers, config) {
|
|
|
|
alert("There was an error submitting your baselines.\n\n" +
|
|
|
|
"Please see server-side log for details.");
|
|
|
|
$scope.submitPending = false;
|
|
|
|
});
|
|
|
|
}
|
2013-10-24 15:38:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Operations we use to mimic Set semantics, in such a way that
|
|
|
|
// checking for presence within the Set is as fast as possible.
|
|
|
|
// But getting a list of all values within the Set is not necessarily
|
|
|
|
// possible.
|
|
|
|
// TODO(epoger): move into a separate .js file?
|
|
|
|
//
|
|
|
|
|
2014-02-06 20:22:25 +00:00
|
|
|
/**
|
|
|
|
* Returns the number of values present within set "set".
|
|
|
|
*
|
|
|
|
* @param set an Object which we use to mimic set semantics
|
|
|
|
*/
|
|
|
|
$scope.setSize = function(set) {
|
|
|
|
return Object.keys(set).length;
|
|
|
|
}
|
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
/**
|
|
|
|
* Returns true if value "value" is present within set "set".
|
|
|
|
*
|
|
|
|
* @param value a value of any type
|
|
|
|
* @param set an Object which we use to mimic set semantics
|
|
|
|
* (this should make isValueInSet faster than if we used an Array)
|
|
|
|
*/
|
|
|
|
$scope.isValueInSet = function(value, set) {
|
|
|
|
return (true == set[value]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If value "value" is already in set "set", remove it; otherwise, add it.
|
|
|
|
*
|
|
|
|
* @param value a value of any type
|
|
|
|
* @param set an Object which we use to mimic set semantics
|
|
|
|
*/
|
|
|
|
$scope.toggleValueInSet = function(value, set) {
|
|
|
|
if (true == set[value]) {
|
|
|
|
delete set[value];
|
|
|
|
} else {
|
|
|
|
set[value] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-29 15:49:40 +00:00
|
|
|
/**
|
|
|
|
* For each value in valueArray, call toggleValueInSet(value, set).
|
|
|
|
*
|
|
|
|
* @param valueArray
|
|
|
|
* @param set
|
|
|
|
*/
|
|
|
|
$scope.toggleValuesInSet = function(valueArray, set) {
|
|
|
|
var arrayLength = valueArray.length;
|
|
|
|
for (var i = 0; i < arrayLength; i++) {
|
|
|
|
$scope.toggleValueInSet(valueArray[i], set);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-24 15:38:27 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Array operations; similar to our Set operations, but operate on a
|
|
|
|
// Javascript Array so we *can* easily get a list of all values in the Set.
|
|
|
|
// TODO(epoger): move into a separate .js file?
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if value "value" is present within array "array".
|
|
|
|
*
|
|
|
|
* @param value a value of any type
|
|
|
|
* @param array a Javascript Array
|
|
|
|
*/
|
|
|
|
$scope.isValueInArray = function(value, array) {
|
|
|
|
return (-1 != array.indexOf(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If value "value" is already in array "array", remove it; otherwise,
|
|
|
|
* add it.
|
|
|
|
*
|
|
|
|
* @param value a value of any type
|
|
|
|
* @param array a Javascript Array
|
|
|
|
*/
|
|
|
|
$scope.toggleValueInArray = function(value, array) {
|
|
|
|
var i = array.indexOf(value);
|
|
|
|
if (-1 == i) {
|
|
|
|
array.push(value);
|
|
|
|
} else {
|
|
|
|
array.splice(i, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Miscellaneous utility functions.
|
|
|
|
// TODO(epoger): move into a separate .js file?
|
|
|
|
//
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a human-readable (in local time zone) time string for a
|
|
|
|
* particular moment in time.
|
|
|
|
*
|
|
|
|
* @param secondsPastEpoch (numeric): seconds past epoch in UTC
|
|
|
|
*/
|
|
|
|
$scope.localTimeString = function(secondsPastEpoch) {
|
|
|
|
var d = new Date(secondsPastEpoch * 1000);
|
|
|
|
return d.toString();
|
|
|
|
}
|
|
|
|
|
2014-02-05 19:49:17 +00:00
|
|
|
/**
|
|
|
|
* Returns a hex color string (such as "#aabbcc") for the given RGB values.
|
|
|
|
*
|
|
|
|
* @param r (numeric): red channel value, 0-255
|
|
|
|
* @param g (numeric): green channel value, 0-255
|
|
|
|
* @param b (numeric): blue channel value, 0-255
|
|
|
|
*/
|
|
|
|
$scope.hexColorString = function(r, g, b) {
|
|
|
|
var rString = r.toString(16);
|
|
|
|
if (r < 16) {
|
|
|
|
rString = "0" + rString;
|
|
|
|
}
|
|
|
|
var gString = g.toString(16);
|
|
|
|
if (g < 16) {
|
|
|
|
gString = "0" + gString;
|
|
|
|
}
|
|
|
|
var bString = b.toString(16);
|
|
|
|
if (b < 16) {
|
|
|
|
bString = "0" + bString;
|
|
|
|
}
|
|
|
|
return '#' + rString + gString + bString;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a hex color string (such as "#aabbcc") for the given brightness.
|
|
|
|
*
|
|
|
|
* @param brightnessString (string): 0-255, 0 is completely black
|
|
|
|
*
|
|
|
|
* TODO(epoger): It might be nice to tint the color when it's not completely
|
|
|
|
* black or completely white.
|
|
|
|
*/
|
|
|
|
$scope.brightnessStringToHexColor = function(brightnessString) {
|
|
|
|
var v = parseInt(brightnessString);
|
|
|
|
return $scope.hexColorString(v, v, v);
|
|
|
|
}
|
|
|
|
|
2014-02-26 19:05:20 +00:00
|
|
|
/**
|
|
|
|
* Returns the last path component of image diff URL for a given ImagePair.
|
|
|
|
*
|
|
|
|
* Depending on which diff this is (whitediffs, pixeldiffs, etc.) this
|
|
|
|
* will be relative to different base URLs.
|
|
|
|
*
|
|
|
|
* We must keep this function in sync with _get_difference_locator() in
|
|
|
|
* ../imagediffdb.py
|
|
|
|
*
|
|
|
|
* @param imagePair: ImagePair to generate image diff URL for
|
|
|
|
*/
|
|
|
|
$scope.getImageDiffRelativeUrl = function(imagePair) {
|
|
|
|
var before =
|
|
|
|
imagePair[constants.KEY__IMAGE_A_URL] + "-vs-" +
|
|
|
|
imagePair[constants.KEY__IMAGE_B_URL];
|
|
|
|
return before.replace(/[^\w\-]/g, "_") + ".png";
|
|
|
|
}
|
|
|
|
|
2013-09-27 15:02:44 +00:00
|
|
|
}
|
|
|
|
);
|