Add support for deep linking of tabs
This commit is contained in:
parent
6cc0482bfb
commit
ecabcc3fc6
1 changed files with 65 additions and 7 deletions
|
@ -432,11 +432,13 @@ quayApp = angular.module('quay', ['ngRoute', 'restangular', 'angularMoment', 'an
|
||||||
when('/repository/:namespace/:name/tag/:tag', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl,
|
when('/repository/:namespace/:name/tag/:tag', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl,
|
||||||
fixFooter: true}).
|
fixFooter: true}).
|
||||||
when('/repository/:namespace/:name/image/:image', {templateUrl: '/static/partials/image-view.html', controller: ImageViewCtrl}).
|
when('/repository/:namespace/:name/image/:image', {templateUrl: '/static/partials/image-view.html', controller: ImageViewCtrl}).
|
||||||
when('/repository/:namespace/:name/admin', {templateUrl: '/static/partials/repo-admin.html', controller:RepoAdminCtrl}).
|
when('/repository/:namespace/:name/admin', {templateUrl: '/static/partials/repo-admin.html', controller:RepoAdminCtrl, reloadOnSearch: false}).
|
||||||
when('/repository/', {title: 'Repositories', description: 'Public and private docker repositories list',
|
when('/repository/', {title: 'Repositories', description: 'Public and private docker repositories list',
|
||||||
templateUrl: '/static/partials/repo-list.html', controller: RepoListCtrl}).
|
templateUrl: '/static/partials/repo-list.html', controller: RepoListCtrl}).
|
||||||
when('/user/', {title: 'Account Settings', description:'Account settings for Quay.io', templateUrl: '/static/partials/user-admin.html', controller: UserAdminCtrl}).
|
when('/user/', {title: 'Account Settings', description:'Account settings for Quay.io', templateUrl: '/static/partials/user-admin.html',
|
||||||
when('/guide/', {title: 'Guide', description:'Guide to using private docker repositories on Quay.io', templateUrl: '/static/partials/guide.html', controller: GuideCtrl}).
|
reloadOnSearch: false, controller: UserAdminCtrl}).
|
||||||
|
when('/guide/', {title: 'Guide', description:'Guide to using private docker repositories on Quay.io', templateUrl: '/static/partials/guide.html',
|
||||||
|
controller: GuideCtrl}).
|
||||||
when('/plans/', {title: 'Plans and Pricing', description: 'Plans and pricing for private docker repositories on Quay.io',
|
when('/plans/', {title: 'Plans and Pricing', description: 'Plans and pricing for private docker repositories on Quay.io',
|
||||||
templateUrl: '/static/partials/plans.html', controller: PlansCtrl}).
|
templateUrl: '/static/partials/plans.html', controller: PlansCtrl}).
|
||||||
when('/security/', {title: 'Security', description: 'Security features used when transmitting and storing data',
|
when('/security/', {title: 'Security', description: 'Security features used when transmitting and storing data',
|
||||||
|
@ -449,7 +451,7 @@ quayApp = angular.module('quay', ['ngRoute', 'restangular', 'angularMoment', 'an
|
||||||
when('/organizations/new/', {title: 'New Organization', description: 'Create a new organization on Quay.io',
|
when('/organizations/new/', {title: 'New Organization', description: 'Create a new organization on Quay.io',
|
||||||
templateUrl: '/static/partials/new-organization.html', controller: NewOrgCtrl}).
|
templateUrl: '/static/partials/new-organization.html', controller: NewOrgCtrl}).
|
||||||
when('/organization/:orgname', {templateUrl: '/static/partials/org-view.html', controller: OrgViewCtrl}).
|
when('/organization/:orgname', {templateUrl: '/static/partials/org-view.html', controller: OrgViewCtrl}).
|
||||||
when('/organization/:orgname/admin', {templateUrl: '/static/partials/org-admin.html', controller: OrgAdminCtrl}).
|
when('/organization/:orgname/admin', {templateUrl: '/static/partials/org-admin.html', controller: OrgAdminCtrl, reloadOnSearch: false}).
|
||||||
when('/organization/:orgname/teams/:teamname', {templateUrl: '/static/partials/team-view.html', controller: TeamViewCtrl}).
|
when('/organization/:orgname/teams/:teamname', {templateUrl: '/static/partials/team-view.html', controller: TeamViewCtrl}).
|
||||||
when('/organization/:orgname/logs/:membername', {templateUrl: '/static/partials/org-member-logs.html', controller: OrgMemberLogsCtrl}).
|
when('/organization/:orgname/logs/:membername', {templateUrl: '/static/partials/org-member-logs.html', controller: OrgMemberLogsCtrl}).
|
||||||
when('/v1/', {title: 'Activation information', templateUrl: '/static/partials/v1-page.html', controller: V1Ctrl}).
|
when('/v1/', {title: 'Activation information', templateUrl: '/static/partials/v1-page.html', controller: V1Ctrl}).
|
||||||
|
@ -783,7 +785,12 @@ quayApp.directive('logsView', function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
var update = function() {
|
var update = function() {
|
||||||
if (!$scope.visible || (!$scope.organization && !$scope.user && !$scope.repository)) {
|
var hasValidUser = !!$scope.user;
|
||||||
|
var hasValidOrg = !!$scope.organization;
|
||||||
|
var hasValidRepo = $scope.repository && $scope.repository.namespace;
|
||||||
|
var isValid = hasValidUser || hasValidOrg || hasValidRepo;
|
||||||
|
|
||||||
|
if (!$scope.visible || !isValid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1668,8 +1675,8 @@ quayApp.directive('ngBlur', function() {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', '$http',
|
quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', '$http', '$cookieStore', '$timeout',
|
||||||
function($location, $rootScope, Restangular, UserService, $http) {
|
function($location, $rootScope, Restangular, UserService, $http, $cookieStore, $timeout) {
|
||||||
Restangular.setErrorInterceptor(function(response) {
|
Restangular.setErrorInterceptor(function(response) {
|
||||||
if (response.status == 401) {
|
if (response.status == 401) {
|
||||||
$('#sessionexpiredModal').modal({});
|
$('#sessionexpiredModal').modal({});
|
||||||
|
@ -1679,6 +1686,35 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', '$http',
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var changeTab = function(activeTab) {
|
||||||
|
$timeout(function() {
|
||||||
|
$('a[data-toggle="tab"]').each(function(index) {
|
||||||
|
var tabName = this.getAttribute('data-target').substr(1);
|
||||||
|
if (tabName == activeTab) {
|
||||||
|
this.click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var resetDefaultTab = function() {
|
||||||
|
$timeout(function() {
|
||||||
|
$('a[data-toggle="tab"]').each(function(index) {
|
||||||
|
if (index == 0) {
|
||||||
|
this.click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$rootScope.$on('$routeUpdate', function(){
|
||||||
|
if ($location.search()['tab']) {
|
||||||
|
changeTab($location.search()['tab']);
|
||||||
|
} else {
|
||||||
|
resetDefaultTab();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
|
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
|
||||||
if (current.$$route.title) {
|
if (current.$$route.title) {
|
||||||
$rootScope.title = current.$$route.title;
|
$rootScope.title = current.$$route.title;
|
||||||
|
@ -1691,6 +1727,28 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', '$http',
|
||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.fixFooter = !!current.$$route.fixFooter;
|
$rootScope.fixFooter = !!current.$$route.fixFooter;
|
||||||
|
$rootScope.current = current.$$route;
|
||||||
|
});
|
||||||
|
|
||||||
|
$rootScope.$on('$viewContentLoaded', function(event, current) {
|
||||||
|
var activeTab = $location.search()['tab'];
|
||||||
|
|
||||||
|
// Setup deep linking of tabs. This will change the search field of the URL whenever a tab
|
||||||
|
// is changed in the UI.
|
||||||
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
||||||
|
var tabName = e.target.getAttribute('data-target').substr(1);
|
||||||
|
$rootScope.$apply(function() {
|
||||||
|
var isDefaultTab = $('a[data-toggle="tab"]')[0] == e.target;
|
||||||
|
var data = isDefaultTab ? {} : {'tab': tabName};
|
||||||
|
$location.search(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (activeTab) {
|
||||||
|
changeTab(activeTab);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var initallyChecked = false;
|
var initallyChecked = false;
|
||||||
|
|
Reference in a new issue