aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skpdiff/diff_viewer.js
diff options
context:
space:
mode:
authorGravatar zachr@google.com <zachr@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-07 18:06:39 +0000
committerGravatar zachr@google.com <zachr@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-07 18:06:39 +0000
commit74c5ab19fd69d3c030f53e5b64493d548b74f916 (patch)
treebd57d431e3817665da5872a066f03ec5a2cf283c /tools/skpdiff/diff_viewer.js
parente57c62d039cbd67a4e52776b3e95c5d002b818d2 (diff)
add ui for mutli-rebaselining
R=epoger@google.com Review URL: https://codereview.chromium.org/22580004 git-svn-id: http://skia.googlecode.com/svn/trunk@10618 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/skpdiff/diff_viewer.js')
-rw-r--r--tools/skpdiff/diff_viewer.js64
1 files changed, 52 insertions, 12 deletions
diff --git a/tools/skpdiff/diff_viewer.js b/tools/skpdiff/diff_viewer.js
index e7156b359f..9c33f84fa1 100644
--- a/tools/skpdiff/diff_viewer.js
+++ b/tools/skpdiff/diff_viewer.js
@@ -76,7 +76,11 @@ directive('swapImg', function() {
};
});
-function DiffListController($scope, $http, $timeout) {
+function DiffListController($scope, $http, $location, $timeout, $parse) {
+ // Detect if we are running the web server version of the viewer. If so, we set a flag and
+ // enable some extra functionality of the website for rebaselining.
+ $scope.isDynamic = ($location.protocol() == "http" || $location.protocol() == "https");
+
// Label each kind of differ for the sort buttons.
$scope.differs = [
{
@@ -90,12 +94,20 @@ function DiffListController($scope, $http, $timeout) {
// Puts the records within AngularJS scope
$scope.records = SkPDiffRecords.records;
+ // Keep track of the index of the last record to change so that shift clicking knows what range
+ // of records to apply the action to.
+ $scope.lastSelectedIndex = undefined;
+
// Indicates which diff metric is used for sorting
$scope.sortIndex = 1;
// Called by the sort buttons to adjust the metric used for sorting
$scope.setSortIndex = function(idx) {
$scope.sortIndex = idx;
+
+ // Because the index of things has most likely changed, the ranges of shift clicking no
+ // longer make sense from the user's point of view. We reset it to avoid confusion.
+ $scope.lastSelectedIndex = undefined;
};
// A predicate for pulling out the number used for sorting
@@ -103,30 +115,58 @@ function DiffListController($scope, $http, $timeout) {
return record.diffs[$scope.sortIndex].result;
};
- // Flash status indicators on the rows, and then remove them so the style can potentially be
+ // Flash status indicator on the page, and then remove it so the style can potentially be
// reapplied later.
- $scope.flashRowStatus = function(success, record) {
+ $scope.flashStatus = function(success) {
var flashStyle = success ? "success-flash" : "failure-flash";
var flashDurationMillis = success ? 500 : 800;
// Store the style in the record. The row will pick up the style this way instead of through
// index because index can change with sort order.
- record.cssClasses = flashStyle;
+ $scope.statusClass = flashStyle;
// The animation cannot be repeated unless the class is removed the element.
$timeout(function() {
- record.cssClasses = "";
+ $scope.statusClass = "";
}, flashDurationMillis);
- }
+ };
+
+ $scope.selectedRebaseline = function(index, event) {
+ // Retrieve the records in the same order they are displayed.
+ var recordsInOrder = $parse("records | orderBy:sortingDiffer")($scope);
+
+ // If the user is shift clicking, apply the last tick/untick to all elements in between this
+ // record, and the last one they ticked/unticked.
+ if (event.shiftKey && $scope.lastSelectedIndex !== undefined) {
+ var currentAction = recordsInOrder[index].isRebaselined;
+ var smallerIndex = Math.min($scope.lastSelectedIndex, index);
+ var largerIndex = Math.max($scope.lastSelectedIndex, index);
+ for (var recordIndex = smallerIndex; recordIndex <= largerIndex; recordIndex++) {
+ recordsInOrder[recordIndex].isRebaselined = currentAction;
+ }
+ $scope.lastSelectedIndex = index;
+ }
+ else
+ {
+ $scope.lastSelectedIndex = index;
+ }
+
+ };
- $scope.setHashOf = function(imagePath, record) {
- $http.post("/set_hash", {
- "path": imagePath
+ $scope.commitRebaselines = function() {
+ // Gather up all records that have the rebaseline set.
+ var rebaselines = [];
+ for (var recordIndex = 0; recordIndex < $scope.records.length; recordIndex++) {
+ if ($scope.records[recordIndex].isRebaselined) {
+ rebaselines.push($scope.records[recordIndex].testPath);
+ }
+ }
+ $http.post("/commit_rebaselines", {
+ "rebaselines": rebaselines
}).success(function(data) {
- $scope.flashRowStatus(data.success, record);
+ $scope.flashStatus(data.success);
}).error(function() {
- $scope.flashRowStatus(false, record);
+ $scope.flashStatus(false);
});
-
};
}