Merge "Only add parameters to the URL when changed from defaults"

This commit is contained in:
Jenkins 2016-06-09 16:40:16 +00:00 committed by Gerrit Code Review
commit 0af008c696
3 changed files with 27 additions and 19 deletions

View File

@ -162,7 +162,6 @@ function HomeController(
// ViewModel
var vm = this;
vm.loadData = loadData;
vm.groupKey = viewService.groupKey();
vm.searchProject = $location.search().searchProject || '';
vm.loaded = false;
vm.hold = 0;
@ -170,6 +169,11 @@ function HomeController(
vm.recentRuns = {};
vm.apiRoot = null;
vm.groupKey = viewService.groupKey();
if (vm.groupKey !== 'project') {
$location.search('groupKey', vm.groupKey);
}
configurePeriods();
loadData();
@ -177,6 +181,10 @@ function HomeController(
vm.groupKey = groupKey;
configurePeriods();
loadData();
// set the groupKey here instead of in the viewService, since we only need
// it to be sharable from the this page
$location.search('groupKey', groupKey).replace();
});
$scope.$on('view:resolution', function(event, resolution) {

View File

@ -48,12 +48,10 @@ function crumbMenu() {
};
$scope.$on('view:resolution', function(event, resolution) {
$location.search('resolutionKey', resolution.key).replace();
$scope.selectedResolution = resolution;
});
$scope.$on('view:groupKey', function(event, groupKey) {
$location.search('groupKey', groupKey).replace();
$scope.selectedGroupKey = groupKey;
});

View File

@ -24,19 +24,6 @@ var viewService = function($rootScope, $location) {
}
});
var regActionSuccess = $rootScope.$on('$locationChangeSuccess', function() {
$location.search('groupKey', groupKey);
$location.search('resolutionKey', resolution.key);
if (userDuration !== null) {
$location.search('duration', userDuration.toISOString());
}
if (periodEnd !== null) {
$location.search('end', periodEnd.toISOString());
}
$location.replace();
});
var periodEnd = new Date();
var periodOptions = [
moment.duration({ hours: 1 }),
@ -62,6 +49,20 @@ var viewService = function($rootScope, $location) {
periodEnd = new Date(searchEnd);
}
var searchParams = new Map();
var search = function(key, value) {
$location.search(key, value).replace();
searchParams.set(key, value);
};
var regActionSuccess = $rootScope.$on('$locationChangeSuccess', function() {
searchParams.forEach(function(value, key) {
$location.search(key, value);
});
$location.replace();
});
var selectDuration = function() {
if (userDuration) {
return userDuration;
@ -77,6 +78,7 @@ var viewService = function($rootScope, $location) {
if (arguments.length === 1) {
resolution = res;
$rootScope.$broadcast('view:resolution', res);
search('resolutionKey', resolution.key);
}
return resolution;
@ -87,7 +89,7 @@ var viewService = function($rootScope, $location) {
},
groupKey: function(key) {
if (arguments.length === 1) {
if (arguments.length === 1 && groupKey !== key) {
groupKey = key;
$rootScope.$broadcast('view:groupKey', groupKey);
}
@ -104,7 +106,7 @@ var viewService = function($rootScope, $location) {
return periodEnd;
}
$location.search('end', end.toISOString()).replace();
search('end', end.toISOString());
periodEnd = end;
$rootScope.$broadcast('view:periodEnd', end);
@ -176,7 +178,7 @@ var viewService = function($rootScope, $location) {
$rootScope.$broadcast('view:duration', duration, false);
$rootScope.$broadcast('view:period', false);
$location.search('duration', userDuration.toISOString()).replace();
search('duration', userDuration.toISOString());
return duration;
},