mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 15:09:32 -02:30
fixing login and submit for new license
This commit is contained in:
@@ -879,7 +879,14 @@ var tower = angular.module('Tower', [
|
|||||||
$rootScope.$emit('OpenSocket');
|
$rootScope.$emit('OpenSocket');
|
||||||
ConfigService.getConfig().then(function(){
|
ConfigService.getConfig().then(function(){
|
||||||
pendoService.issuePendoIdentity();
|
pendoService.issuePendoIdentity();
|
||||||
CheckLicense.test(event);
|
CheckLicense.test().then(function(){
|
||||||
|
// $state.go(next);
|
||||||
|
return;
|
||||||
|
})
|
||||||
|
.catch(function(){
|
||||||
|
event.preventDefault();
|
||||||
|
$state.go('license');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
export default
|
export default
|
||||||
['$state', '$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', '$q',
|
['$state', '$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', '$q',
|
||||||
'Store', 'ConfigService',
|
'ConfigService',
|
||||||
function($state, $rootScope, Rest, GetBasePath, ProcessErrors, $q, Store,
|
function($state, $rootScope, Rest, GetBasePath, ProcessErrors, $q,
|
||||||
ConfigService){
|
ConfigService){
|
||||||
return {
|
return {
|
||||||
get: function() {
|
get: function() {
|
||||||
@@ -46,7 +46,7 @@ export default
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
test: function(event){
|
test: function(event){
|
||||||
var //deferred = $q.defer(),
|
var deferred = $q.defer(),
|
||||||
license = this.get();
|
license = this.get();
|
||||||
if(license === null || !$rootScope.license_tested){
|
if(license === null || !$rootScope.license_tested){
|
||||||
if(this.valid(license) === false) {
|
if(this.valid(license) === false) {
|
||||||
@@ -55,11 +55,11 @@ export default
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
$state.go('license');
|
$state.go('license');
|
||||||
// deferred.reject();
|
deferred.reject();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$rootScope.licenseMissing = false;
|
$rootScope.licenseMissing = false;
|
||||||
// deferred.resolve();
|
deferred.resolve();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(this.valid(license) === false) {
|
else if(this.valid(license) === false) {
|
||||||
@@ -68,14 +68,13 @@ export default
|
|||||||
if(event){
|
if(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
// deferred.reject(license);
|
deferred.reject(license);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$rootScope.licenseMissing = false;
|
$rootScope.licenseMissing = false;
|
||||||
// deferred.resolve(license);
|
deferred.resolve(license);
|
||||||
}
|
}
|
||||||
return;
|
return deferred.promise;
|
||||||
// return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
export default
|
export default
|
||||||
['Wait', '$state', '$scope', '$rootScope', '$location', 'GetBasePath',
|
['Wait', '$state', '$scope', '$rootScope', '$location', 'GetBasePath',
|
||||||
'Rest', 'ProcessErrors', 'CheckLicense', 'moment','$window',
|
'Rest', 'ProcessErrors', 'CheckLicense', 'moment','$window',
|
||||||
|
'ConfigService',
|
||||||
function( Wait, $state, $scope, $rootScope, $location, GetBasePath, Rest,
|
function( Wait, $state, $scope, $rootScope, $location, GetBasePath, Rest,
|
||||||
ProcessErrors, CheckLicense, moment, $window){
|
ProcessErrors, CheckLicense, moment, $window, ConfigService){
|
||||||
$scope.getKey = function(event){
|
$scope.getKey = function(event){
|
||||||
// Mimic HTML5 spec, show filename
|
// Mimic HTML5 spec, show filename
|
||||||
$scope.fileName = event.target.files[0].name;
|
$scope.fileName = event.target.files[0].name;
|
||||||
@@ -47,20 +48,24 @@ export default
|
|||||||
.success(function(){
|
.success(function(){
|
||||||
reset();
|
reset();
|
||||||
init();
|
init();
|
||||||
if($rootScope.licenseMissing === true){
|
ConfigService.delete();
|
||||||
$state.go('dashboard', {
|
ConfigService.getConfig().then(function(){
|
||||||
licenseMissing: false
|
if($rootScope.licenseMissing === true){
|
||||||
});
|
$state.go('dashboard', {
|
||||||
}
|
licenseMissing: false
|
||||||
else{
|
});
|
||||||
$scope.success = true;
|
}
|
||||||
$rootScope.licenseMissing = false;
|
else{
|
||||||
// for animation purposes
|
$scope.success = true;
|
||||||
var successTimeout = setTimeout(function(){
|
$rootScope.licenseMissing = false;
|
||||||
$scope.success = false;
|
// for animation purposes
|
||||||
clearTimeout(successTimeout);
|
var successTimeout = setTimeout(function(){
|
||||||
}, 4000);
|
$scope.success = false;
|
||||||
}
|
clearTimeout(successTimeout);
|
||||||
|
}, 4000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var calcDaysRemaining = function(seconds){
|
var calcDaysRemaining = function(seconds){
|
||||||
@@ -80,16 +85,15 @@ export default
|
|||||||
$scope.fileName = "No file selected.";
|
$scope.fileName = "No file selected.";
|
||||||
$scope.title = $rootScope.licenseMissing ? "Tower License" : "License Management";
|
$scope.title = $rootScope.licenseMissing ? "Tower License" : "License Management";
|
||||||
Wait('start');
|
Wait('start');
|
||||||
var license = CheckLicense.get();
|
ConfigService.getConfig().then(function(config){
|
||||||
//.then(function(res){
|
$scope.license = config;
|
||||||
$scope.license = license;
|
$scope.license.version = config.version.split('-')[0];
|
||||||
$scope.license.version = license.version.split('-')[0];
|
|
||||||
$scope.time = {};
|
$scope.time = {};
|
||||||
$scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining);
|
$scope.time.remaining = calcDaysRemaining($scope.license.license_info.time_remaining);
|
||||||
$scope.time.expiresOn = calcExpiresOn($scope.time.remaining);
|
$scope.time.expiresOn = calcExpiresOn($scope.time.remaining);
|
||||||
$scope.valid = CheckLicense.valid($scope.license.license_info);
|
$scope.valid = CheckLicense.valid($scope.license.license_info);
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
// });
|
});
|
||||||
};
|
};
|
||||||
var reset = function(){
|
var reset = function(){
|
||||||
document.getElementById('License-form').reset();
|
document.getElementById('License-form').reset();
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
export default
|
export default
|
||||||
['$http', '$rootScope', '$location', '$cookieStore', 'GetBasePath', 'Store',
|
['$http', '$rootScope', '$location', '$cookieStore', 'GetBasePath', 'Store',
|
||||||
function ($http, $rootScope, $location, $cookieStore, GetBasePath, Store) {
|
'$injector',
|
||||||
|
function ($http, $rootScope, $location, $cookieStore, GetBasePath, Store,
|
||||||
|
$injector) {
|
||||||
return {
|
return {
|
||||||
setToken: function (token, expires) {
|
setToken: function (token, expires) {
|
||||||
// set the session cookie
|
// set the session cookie
|
||||||
@@ -61,11 +63,12 @@ export default
|
|||||||
// the following puts our primary scope up for garbage collection, which
|
// the following puts our primary scope up for garbage collection, which
|
||||||
// should prevent content flash from the prior user.
|
// should prevent content flash from the prior user.
|
||||||
|
|
||||||
var x, scope = angular.element(document.getElementById('main-view')).scope();
|
var x,
|
||||||
|
ConfigService = $injector.get('ConfigService'),
|
||||||
|
scope = angular.element(document.getElementById('main-view')).scope();
|
||||||
scope.$destroy();
|
scope.$destroy();
|
||||||
//$rootScope.$destroy();
|
//$rootScope.$destroy();
|
||||||
|
|
||||||
|
|
||||||
if($cookieStore.get('lastPath')==='/portal'){
|
if($cookieStore.get('lastPath')==='/portal'){
|
||||||
$cookieStore.put( 'lastPath', '/portal');
|
$cookieStore.put( 'lastPath', '/portal');
|
||||||
$rootScope.lastPath = '/portal';
|
$rootScope.lastPath = '/portal';
|
||||||
@@ -88,6 +91,7 @@ export default
|
|||||||
if ($cookieStore.get('current_user')) {
|
if ($cookieStore.get('current_user')) {
|
||||||
$rootScope.lastUser = $cookieStore.get('current_user').id;
|
$rootScope.lastUser = $cookieStore.get('current_user').id;
|
||||||
}
|
}
|
||||||
|
ConfigService.delete();
|
||||||
$cookieStore.remove('token_expires');
|
$cookieStore.remove('token_expires');
|
||||||
$cookieStore.remove('current_user');
|
$cookieStore.remove('current_user');
|
||||||
$cookieStore.remove('token');
|
$cookieStore.remove('token');
|
||||||
@@ -125,10 +129,10 @@ export default
|
|||||||
license.version = data.version;
|
license.version = data.version;
|
||||||
license.ansible_version = data.ansible_version;
|
license.ansible_version = data.ansible_version;
|
||||||
license.tested = false;
|
license.tested = false;
|
||||||
Store('license', license);
|
|
||||||
$rootScope.features = Store('license').features;
|
$rootScope.features = license.features;
|
||||||
},
|
},
|
||||||
|
|
||||||
licenseTested: function () {
|
licenseTested: function () {
|
||||||
var license, result;
|
var license, result;
|
||||||
if ($rootScope.license_tested !== undefined) {
|
if ($rootScope.license_tested !== undefined) {
|
||||||
|
|||||||
@@ -54,10 +54,12 @@
|
|||||||
* This is usage information.
|
* This is usage information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait',
|
export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope',
|
||||||
'Timer', 'Empty', 'ClearScope', '$scope', 'pendoService',
|
'$location', 'Authorization', 'ToggleClass', 'Alert', 'Wait', 'Timer',
|
||||||
function ($log, $cookieStore, $compile, $window, $rootScope, $location, Authorization, ToggleClass, Alert, Wait,
|
'Empty', 'ClearScope', '$scope', 'pendoService', 'ConfigService',
|
||||||
Timer, Empty, ClearScope, scope, pendoService) {
|
function ($log, $cookieStore, $compile, $window, $rootScope, $location,
|
||||||
|
Authorization, ToggleClass, Alert, Wait, Timer, Empty, ClearScope,
|
||||||
|
scope, pendoService, ConfigService) {
|
||||||
|
|
||||||
var lastPath, lastUser, sessionExpired, loginAgain;
|
var lastPath, lastUser, sessionExpired, loginAgain;
|
||||||
|
|
||||||
@@ -110,9 +112,10 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l
|
|||||||
scope.removeAuthorizationGetLicense();
|
scope.removeAuthorizationGetLicense();
|
||||||
}
|
}
|
||||||
scope.removeAuthorizationGetLicense = scope.$on('AuthorizationGetLicense', function() {
|
scope.removeAuthorizationGetLicense = scope.$on('AuthorizationGetLicense', function() {
|
||||||
Authorization.getLicense()
|
// Authorization.getLicense()
|
||||||
.success(function (data) {
|
// .success(function (data) {
|
||||||
Authorization.setLicense(data);
|
// Authorization.setLicense(data);
|
||||||
|
ConfigService.getConfig().then(function(){
|
||||||
pendoService.issuePendoIdentity();
|
pendoService.issuePendoIdentity();
|
||||||
Wait("stop");
|
Wait("stop");
|
||||||
if (lastPath() && lastUser()) {
|
if (lastPath() && lastUser()) {
|
||||||
@@ -122,7 +125,7 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', '$l
|
|||||||
$location.url('/home');
|
$location.url('/home');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error(function () {
|
.catch(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', loginAgain);
|
Alert('Error', 'Failed to access license information. GET returned status: ' + status, 'alert-danger', loginAgain);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
[ '$rootScope', '$pendolytics', 'Rest', 'GetBasePath', 'ProcessErrors', '$q',
|
['GetBasePath', 'ProcessErrors', '$q', 'Rest', '$rootScope',
|
||||||
function ($rootScope, $pendolytics, Rest, GetBasePath, ProcessErrors, $q) {
|
function (GetBasePath, ProcessErrors, $q, Rest, $rootScope) {
|
||||||
return {
|
return {
|
||||||
get: function(){
|
get: function(){
|
||||||
return this.config;
|
return this.config;
|
||||||
@@ -17,6 +17,10 @@ export default
|
|||||||
this.config = config;
|
this.config = config;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
delete: function(){
|
||||||
|
delete(this.config);
|
||||||
|
},
|
||||||
|
|
||||||
getConfig: function () {
|
getConfig: function () {
|
||||||
var config = this.get(),
|
var config = this.get(),
|
||||||
that = this,
|
that = this,
|
||||||
@@ -33,7 +37,7 @@ export default
|
|||||||
promise.catch(function (response) {
|
promise.catch(function (response) {
|
||||||
ProcessErrors($rootScope, response.data, response.status, null, {
|
ProcessErrors($rootScope, response.data, response.status, null, {
|
||||||
hdr: 'Error!',
|
hdr: 'Error!',
|
||||||
msg: 'Failed to get inventory name. GET returned status: ' +
|
msg: 'Failed to get config. GET returned status: ' +
|
||||||
response.status });
|
response.status });
|
||||||
deferred.reject('Could not resolve pendo config.');
|
deferred.reject('Could not resolve pendo config.');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user