diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-05 18:03:24 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-12-05 18:03:24 +0000 |
commit | 62a5ef0a9b8e5e5b6fdc6bab8aa4910ad23b8e62 (patch) | |
tree | d6874d7f2384bdc9f6dd78f7cf4a309c38a64574 /gm/rebaseline_server | |
parent | cc6db406e482914ab6abbe86aa89f0f0d4ec83c7 (diff) |
rebaseline_server: add "deep linking" to allow bookmarking of particular views
(SkipBuildbotRuns)
R=jcgregorio@google.com
Review URL: https://codereview.chromium.org/104623003
git-svn-id: http://skia.googlecode.com/svn/trunk@12513 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/rebaseline_server')
-rw-r--r-- | gm/rebaseline_server/static/index.html | 4 | ||||
-rw-r--r-- | gm/rebaseline_server/static/loader.js | 103 |
2 files changed, 100 insertions, 7 deletions
diff --git a/gm/rebaseline_server/static/index.html b/gm/rebaseline_server/static/index.html index f0cbb4346e..39991e0888 100644 --- a/gm/rebaseline_server/static/index.html +++ b/gm/rebaseline_server/static/index.html @@ -9,13 +9,13 @@ Here are links to the result pages: <ul> <li> - <a href="/static/view.html?resultsToLoad=failures"> + <a href="/static/view.html#/view.html?resultsToLoad=failures"> failures only </a> (loads faster) </li> <li> - <a href="/static/view.html?resultsToLoad=all"> + <a href="/static/view.html#/view.html?resultsToLoad=all"> all results </a> (includes successful test results) diff --git a/gm/rebaseline_server/static/loader.js b/gm/rebaseline_server/static/loader.js index ccd29c205a..fa74ed8eff 100644 --- a/gm/rebaseline_server/static/loader.js +++ b/gm/rebaseline_server/static/loader.js @@ -42,8 +42,8 @@ Loader.controller( 'Loader.Controller', function($scope, $http, $filter, $location, $timeout) { $scope.windowTitle = "Loading GM Results..."; - var resultsToLoad = $location.search().resultsToLoad; - $scope.loadingMessage = "Loading results of type '" + resultsToLoad + + $scope.resultsToLoad = $location.search().resultsToLoad; + $scope.loadingMessage = "Loading results of type '" + $scope.resultsToLoad + "', please wait..."; /** @@ -51,7 +51,7 @@ Loader.controller( * Once the dictionary is loaded, unhide the page elements so they can * render the data. */ - $http.get("/results/" + resultsToLoad).success( + $http.get("/results/" + $scope.resultsToLoad).success( function(data, status, header, config) { if (data.header.resultsStillLoading) { $scope.loadingMessage = @@ -118,6 +118,9 @@ Loader.controller( $scope.categoryValueMatch.builder = ""; $scope.categoryValueMatch.test = ""; + // If any defaults were overridden in the URL, get them now. + $scope.queryParameters.load(); + $scope.updateResults(); $scope.loadingMessage = ""; $scope.windowTitle = "Current GM Results"; @@ -126,7 +129,7 @@ Loader.controller( ).error( function(data, status, header, config) { $scope.loadingMessage = "Failed to load results of type '" - + resultsToLoad + "'"; + + $scope.resultsToLoad + "'"; $scope.windowTitle = "Failed to Load GM Results"; } ); @@ -220,6 +223,93 @@ Loader.controller( // + // $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 = { + 'resultsToLoad': $scope.queryParameters.copiers.simple, + 'displayLimitPending': $scope.queryParameters.copiers.simple, + 'imageSizePending': $scope.queryParameters.copiers.simple, + 'sortColumn': $scope.queryParameters.copiers.simple, + + 'builder': $scope.queryParameters.copiers.categoryValueMatch, + 'test': $scope.queryParameters.copiers.categoryValueMatch, + + 'hiddenResultTypes': $scope.queryParameters.copiers.set, + 'hiddenConfigs': $scope.queryParameters.copiers.set, + }; + + // 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); + }; + + + // // updateResults() and friends. // @@ -241,7 +331,9 @@ Loader.controller( } /** - * Update the displayed results, based on filters/settings. + * Update the displayed results, based on filters/settings, + * and call $scope.queryParameters.save() so that the new filter results + * can be bookmarked. */ $scope.updateResults = function() { $scope.displayLimit = $scope.displayLimitPending; @@ -284,6 +376,7 @@ Loader.controller( } $scope.imageSize = $scope.imageSizePending; $scope.setUpdatesPending(false); + $scope.queryParameters.save(); } /** |