fixed login modal straggling issues

This commit is contained in:
John Mitchell
2015-11-23 10:43:43 -05:00
parent 77f9523984
commit 16340975fd
6 changed files with 85 additions and 45 deletions

View File

@@ -80,7 +80,9 @@ export default
$rootScope.lastPath = '/home'; $rootScope.lastPath = '/home';
} }
x = Store('sessionTime'); x = Store('sessionTime');
x[$rootScope.current_user.id].loggedIn = false; if ($rootScope.current_user) {
x[$rootScope.current_user.id].loggedIn = false;
}
Store('sessionTime', x); Store('sessionTime', x);
$rootScope.lastUser = $cookieStore.get('current_user').id; $rootScope.lastUser = $cookieStore.get('current_user').id;
@@ -98,7 +100,9 @@ export default
$rootScope.token_expires = null; $rootScope.token_expires = null;
$rootScope.login_username = null; $rootScope.login_username = null;
$rootScope.login_password = null; $rootScope.login_password = null;
$rootScope.sessionTimer.clearTimers(); if ($rootScope.sessionTimer) {
$rootScope.sessionTimer.clearTimers();
}
}, },
getLicense: function () { getLicense: function () {

View File

@@ -9,5 +9,11 @@ import {templateUrl} from '../shared/template-url/template-url.factory';
export default { export default {
name: 'signIn', name: 'signIn',
route: '/login', route: '/login',
templateUrl: templateUrl('login/loginBackDrop') templateUrl: templateUrl('login/loginBackDrop'),
controller: ['$rootScope', 'Authorization', function($rootScope, Authorization) {
if (Authorization.isUserLoggedIn()) {
Authorization.logout();
}
$(".LoginModal-dialog").remove();
}]
}; };

View File

@@ -1,4 +1,20 @@
/** @define LoginModal */ /** @define LoginModal */
.LoginModal-backDrop {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
z-index: 1041;
opacity: 0;
transition: 0.5s opacity;
background: #000;
}
.LoginModal-backDrop.is-loggedOut {
opacity: 0.2;
}
.LoginModal-dialog { .LoginModal-dialog {
margin: 30px auto; margin: 30px auto;
margin-top: 135px; margin-top: 135px;
@@ -14,6 +30,8 @@
border-radius: 4px; border-radius: 4px;
opacity: 0; opacity: 0;
transition: opacity 0.5s; transition: opacity 0.5s;
z-index: 1042;
position: relative;
} }
.LoginModal-content.is-loggedOut { .LoginModal-content.is-loggedOut {

View File

@@ -59,13 +59,7 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l
function ($log, $cookieStore, $compile, $window, $rootScope, $location, Authorization, ToggleClass, Alert, Wait, function ($log, $cookieStore, $compile, $window, $rootScope, $location, Authorization, ToggleClass, Alert, Wait,
Timer, Empty, ClearScope, scope, pendoService) { Timer, Empty, ClearScope, scope, pendoService) {
var setLoginFocus, lastPath, lastUser, sessionExpired, loginAgain; var lastPath, lastUser, sessionExpired, loginAgain;
setLoginFocus = function () {
// Need to clear out any open dialog windows that might be open when this modal opens.
ClearScope();
$('#login-username').focus();
};
loginAgain = function() { loginAgain = function() {
setTimeout(function() { setTimeout(function() {
@@ -93,27 +87,17 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l
$log.debug('User session expired: ' + sessionExpired); $log.debug('User session expired: ' + sessionExpired);
$log.debug('Last URL: ' + lastPath()); $log.debug('Last URL: ' + lastPath());
// Hide any lingering modal dialogs
$('.modal[aria-hidden=false]').each(function () {
if ($(this).attr('id') !== 'login-modal') {
$(this).modal('hide');
}
});
// Just in case, make sure the wait widget is not active
// and scroll the window to the top
Wait('stop');
window.scrollTo(0,0);
// Set focus to username field
$('#login-modal').on('shown.bs.modal', function () {
setLoginFocus();
});
$rootScope.loginConfig.promise.then(function () { $rootScope.loginConfig.promise.then(function () {
scope.customLogo = ($AnsibleConfig.custom_logo) ? "custom_console_logo.png" : "tower_console_logo.png"; if ($AnsibleConfig.custom_logo) {
scope.customLogo = "custom_console_logo.png";
scope.customLogoPresent = true;
} else {
scope.customLogo = "login_modal_logo.png";
scope.customLogoPresent = false;
}
scope.customLoginInfo = $AnsibleConfig.custom_login_info; scope.customLoginInfo = $AnsibleConfig.custom_login_info;
scope.customLoginInfoPresent = ($AnsibleConfig.customLoginInfo) ? true : false; scope.customLoginInfoPresent = (scope.customLoginInfo) ? true : false;
}); });
// Reset the login form // Reset the login form
@@ -122,19 +106,6 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l
//$rootScope.userLoggedIn = false; //hide the logout link. if you got here, you're logged out. //$rootScope.userLoggedIn = false; //hide the logout link. if you got here, you're logged out.
//$cookieStore.put('userLoggedIn', false); //gets set back to true by Authorization.setToken(). //$cookieStore.put('userLoggedIn', false); //gets set back to true by Authorization.setToken().
$('#login-password').bind('keypress', function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code === 13) {
$('#login-button').click();
}
});
scope.reset = function () {
$('#login-form input').each(function () {
$(this).val('');
});
};
if (scope.removeAuthorizationGetLicense) { if (scope.removeAuthorizationGetLicense) {
scope.removeAuthorizationGetLicense(); scope.removeAuthorizationGetLicense();
} }

View File

@@ -7,14 +7,53 @@ import authenticationController from './loginModal.controller';
/* jshint unused: vars */ /* jshint unused: vars */
export default export default
[ 'templateUrl', [ 'templateUrl',
function(templateUrl) { 'ClearScope',
'Wait',
function(templateUrl, ClearScope, Wait) {
return { return {
restrict: 'E', restrict: 'E',
scope: true, scope: true,
controller: authenticationController, controller: authenticationController,
templateUrl: templateUrl('login/loginModal/loginModal'), templateUrl: templateUrl('login/loginModal/loginModal'),
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
var setLoginFocus = function () {
// Need to clear out any open dialog windows that might be open when this modal opens.
ClearScope();
$('#login-username').focus();
};
setLoginFocus();
// Hide any lingering modal dialogs
$('.modal[aria-hidden=false]').each(function () {
if ($(this).attr('id') !== 'login-modal') {
$(this).modal('hide');
}
});
// Just in case, make sure the wait widget is not active
// and scroll the window to the top
Wait('stop');
window.scrollTo(0,0);
// Set focus to username field
$('#login-modal').on('shown.bs.modal', function () {
setLoginFocus();
});
$('#login-password').bind('keypress', function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
if (code === 13) {
$('#login-button').click();
}
});
scope.reset = function () {
$('#login-form input').each(function () {
$(this).val('');
});
};
} }
}; };
} }

View File

@@ -1,4 +1,6 @@
<div id="login-modal" class="LoginModal"> <div id="login-modal" class="LoginModal">
<div class="LoginModal-backDrop"
ng-class="{'is-loggedOut' : !$root.current_user.username}"></div>
<div class="LoginModal-dialog"> <div class="LoginModal-dialog">
<div class="LoginModal-content" <div class="LoginModal-content"
ng-class="{'is-loggedOut' : !$root.current_user.username}"> ng-class="{'is-loggedOut' : !$root.current_user.username}">