update for redirection to last page and other refinements.

This commit is contained in:
kunw 2016-07-07 13:15:00 +08:00
parent 83aa56a1e4
commit 81363ad1fb
5 changed files with 27 additions and 13 deletions

View File

@ -44,13 +44,14 @@
}
function getProjectSuccess(data, status) {
vm.projects = data || [];
vm.projects = data;
if(!angular.isDefined(vm.projects)) {
if(vm.projects == null) {
vm.isPublic = 1;
vm.publicity = 1;
vm.publicity = true;
vm.projectType = 'public_projects';
console.log('vm.projects is undefined, load public projects.');
console.log('vm.projects is null, load public projects.');
return;
}
if(angular.isArray(vm.projects) && vm.projects.length > 0) {
@ -78,9 +79,9 @@
}
function getProjectFailed() {
// $scope.$emit('modalTitle', $filter('tr')('error'));
// $scope.$emit('modalMessage', $filter('tr')('failed_to_get_project'));
// $scope.$emit('raiseError', true);
$scope.$emit('modalTitle', $filter('tr')('error'));
$scope.$emit('modalMessage', $filter('tr')('failed_to_get_project'));
$scope.$emit('raiseError', true);
console.log('Failed to list projects.');
}

View File

@ -6,8 +6,8 @@
.module('harbor.sign.in')
.directive('signIn', signIn);
SignInController.$inject = ['SignInService', 'LogOutService', 'currentUser', 'I18nService', '$window', '$scope'];
function SignInController(SignInService, LogOutService, currentUser, I18nService, $window, $scope) {
SignInController.$inject = ['SignInService', 'LogOutService', 'currentUser', 'I18nService', '$window', '$scope', 'getParameterByName', '$location'];
function SignInController(SignInService, LogOutService, currentUser, I18nService, $window, $scope, getParameterByName, $location) {
var vm = this;
vm.hasError = false;
@ -20,7 +20,7 @@
vm.doContinue = doContinue;
vm.doLogOut = doLogOut;
vm.signInTIP = false;
function reset() {
@ -30,6 +30,7 @@
function doSignIn(user) {
if(user && angular.isDefined(user.principal) && angular.isDefined(user.password)) {
vm.lastUrl = getParameterByName('last_url', $location.absUrl());
vm.signInTIP = true;
SignInService(user.principal, user.password)
.success(signedInSuccess)
@ -38,6 +39,10 @@
}
function signedInSuccess(data, status) {
if(vm.lastUrl) {
$window.location.href = vm.lastUrl;
return;
}
$window.location.href = "/dashboard";
}

View File

@ -22,9 +22,9 @@
.filter('dateL', localizeDate)
.filter('tr', tr);
RedirectInterceptorService.$inject = ['$q', '$window'];
RedirectInterceptorService.$inject = ['$q', '$window', '$location'];
function RedirectInterceptorService($q, $window) {
function RedirectInterceptorService($q, $window, $location) {
return {
'responseError': function(rejection) {
var url = rejection.config.url;
@ -55,7 +55,7 @@
}
}
if(!isExcluded && rejection.status === 401) {
$window.location.href = '/';
$window.location.href = '/?last_url=' + encodeURIComponent(location.pathname + '#' + $location.url());
return;
}
return $q.reject(rejection);

View File

@ -22,6 +22,10 @@
vm.cancel = cancel;
$scope.user = currentUser.get();
if(!$scope.user) {
$window.location.href = '/';
return;
}
var userId = $scope.user.user_id;
//Error message dialog handler for account setting.

View File

@ -23,6 +23,10 @@
vm.cancel = cancel;
$scope.user = currentUser.get();
if(!$scope.user) {
$window.location.href = '/';
return;
}
var userId = $scope.user.user_id;
//Error message dialog handler for account setting.