diff --git a/ui/index.html b/ui/index.html index 67af155d03a..2f9a6a46e9a 100755 --- a/ui/index.html +++ b/ui/index.html @@ -40,7 +40,7 @@ - + diff --git a/ui/js/controllers/jobs.js b/ui/js/controllers/jobs.js index 025fa7ec41e..7a2c22f1196 100644 --- a/ui/js/controllers/jobs.js +++ b/ui/js/controllers/jobs.js @@ -2,12 +2,12 @@ treeherder.controller('JobsCtrl', [ '$scope', '$http', '$rootScope', '$routeParams', 'ThLog', '$cookies', - 'localStorageService', 'thUrl', 'ThRepositoryModel', + 'localStorageService', 'thUrl', 'ThRepositoryModel', 'thDefaultRepo', 'ThResultSetModel', 'thResultStatusList', '$location', 'thEvents', 'ThJobModel', function JobsCtrl( $scope, $http, $rootScope, $routeParams, ThLog, $cookies, - localStorageService, thUrl, ThRepositoryModel, + localStorageService, thUrl, ThRepositoryModel, thDefaultRepo, ThResultSetModel, thResultStatusList, $location, thEvents, ThJobModel) { var $log = new ThLog(this.constructor.name); @@ -23,8 +23,8 @@ treeherder.controller('JobsCtrl', [ $routeParams.repo !== "") { $rootScope.repoName = $routeParams.repo; } else { - $rootScope.repoName = "mozilla-central"; - $location.search("repo", "mozilla-central"); + $rootScope.repoName = thDefaultRepo; + $location.search("repo", $rootScope.repoName); } ThResultSetModel.addRepository($scope.repoName); diff --git a/ui/js/controllers/main.js b/ui/js/controllers/main.js index dd0790413cb..5837ccf03f8 100644 --- a/ui/js/controllers/main.js +++ b/ui/js/controllers/main.js @@ -5,11 +5,13 @@ treeherder.controller('MainCtrl', [ 'localStorageService', 'ThRepositoryModel', 'thPinboard', 'thClassificationTypes', 'thEvents', '$interval', '$window', 'ThExclusionProfileModel', 'thJobFilters', 'ThResultSetModel', + 'thDefaultRepo', function MainController( $scope, $rootScope, $routeParams, $location, ThLog, localStorageService, ThRepositoryModel, thPinboard, thClassificationTypes, thEvents, $interval, $window, - ThExclusionProfileModel, thJobFilters, ThResultSetModel) { + ThExclusionProfileModel, thJobFilters, ThResultSetModel, + thDefaultRepo) { var $log = new ThLog("MainCtrl"); @@ -205,12 +207,17 @@ treeherder.controller('MainCtrl', [ // when the app redirects internally $rootScope.urlBasePath = $location.absUrl().split('?')[0]; - // give the page a way to determine which nav toolbar to show + // reload the page if certain params were changed in the URL. For + // others, such as filtering, just re-filter without reload. $rootScope.$on('$locationChangeSuccess', function(ev,newUrl, oldUrl) { - $log.debug("reload", "newUrl=", newUrl, "oldUrl=", oldUrl); - - if (!_.isEqual(getTriggerParams(oldUrl), - getTriggerParams(newUrl))) { + $log.debug("check for reload", "newUrl=", newUrl, "oldUrl=", oldUrl); + + var oldParams = getTriggerParams(oldUrl); + var newParams = getTriggerParams(newUrl); + // if we are just setting the repo to the default because none was + // set initially, then don't reload the page. + var defaulting = newParams.repo === thDefaultRepo && !oldParams.repo; + if (!_.isEqual(oldParams, newParams) && !defaulting) { $window.location.reload(); } else { thJobFilters.buildFiltersFromQueryString(); diff --git a/ui/js/values.js b/ui/js/values.js index a9dfd0a2901..c599a77efda 100644 --- a/ui/js/values.js +++ b/ui/js/values.js @@ -48,3 +48,5 @@ treeherder.value("thRepoGroupOrder", { "taskcluster": 5, "qa automation tests": 6 }); + +treeherder.value("thDefaultRepo", "mozilla-central"); diff --git a/ui/vendor/jquery.ba-bbq.min.js b/ui/vendor/jquery.ba-bbq.min.js deleted file mode 100644 index bcbf24834ac..00000000000 --- a/ui/vendor/jquery.ba-bbq.min.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010 - * http://benalman.com/projects/jquery-bbq-plugin/ - * - * Copyright (c) 2010 "Cowboy" Ben Alman - * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ - */ -(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this); \ No newline at end of file diff --git a/ui/vendor/jquery.deparam.js b/ui/vendor/jquery.deparam.js new file mode 100644 index 00000000000..7a26f0385e4 --- /dev/null +++ b/ui/vendor/jquery.deparam.js @@ -0,0 +1,20 @@ +/** + * jQuery.deparam - The oposite of jQuery param. Creates an object of query string parameters. + * + * Credits for the idea and Regex: + * http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/ +*/ +(function($){ + $.deparam = $.deparam || function(uri){ + if(uri === undefined){ + uri = window.location.search; + } + var queryString = {}; + uri.replace( + new RegExp( + "([^?=&]+)(=([^&#]*))?", "g"), + function($0, $1, $2, $3) { queryString[$1] = $3; } + ); + return queryString; + }; +})(jQuery); \ No newline at end of file