mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 13:57:39 -02:30
Improvements to feature service timing for AS button
This commit is contained in:
@@ -920,6 +920,10 @@ var tower = angular.module('Tower', [
|
|||||||
// create a promise that will resolve state $AnsibleConfig is loaded
|
// create a promise that will resolve state $AnsibleConfig is loaded
|
||||||
$rootScope.loginConfig = $q.defer();
|
$rootScope.loginConfig = $q.defer();
|
||||||
}
|
}
|
||||||
|
if (!$rootScope.featuresConfigured) {
|
||||||
|
// create a promise that will resolve state $AnsibleConfig is loaded
|
||||||
|
$rootScope.featuresConfigured = $q.defer();
|
||||||
|
}
|
||||||
$rootScope.licenseMissing = true;
|
$rootScope.licenseMissing = true;
|
||||||
//the authorization controller redirects to the home page automatcially if there is no last path defined. in order to override
|
//the authorization controller redirects to the home page automatcially if there is no last path defined. in order to override
|
||||||
// this, set the last path to /portal for instances where portal is visited for the first time.
|
// this, set the last path to /portal for instances where portal is visited for the first time.
|
||||||
|
|||||||
@@ -52,22 +52,15 @@ export default
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('featuresLoaded', function(){
|
// scope.$on('featuresLoaded', function(){
|
||||||
FeaturesService.get()
|
$rootScope.featuresConfigured.promise.then(function(features){
|
||||||
.then(function() {
|
// var features = FeaturesService.get();
|
||||||
|
if(features){
|
||||||
scope.loadingLicense = false;
|
scope.loadingLicense = false;
|
||||||
scope.activityStreamActive = ($state.name === 'activityStream') ? true : false;
|
scope.activityStreamActive = ($state.name === 'activityStream') ? true : false;
|
||||||
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || $state.name === 'activityStream') ? true : false;
|
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || $state.name ==='activityStream') ? true : false;
|
||||||
})
|
}
|
||||||
.catch(function (response) {
|
|
||||||
ProcessErrors(null, response.data, response.status, null, {
|
|
||||||
hdr: 'Error!',
|
|
||||||
msg: 'Failed to get feature info. GET returned status: ' +
|
|
||||||
response.status
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -29,9 +29,7 @@ export default
|
|||||||
msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status});
|
msg: 'Call to '+ defaultUrl + ' failed. Return status: '+ status});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// Checks current license validity
|
|
||||||
// Intended to for runtime or pre-state checks
|
|
||||||
// Returns false if invalid
|
|
||||||
valid: function(license) {
|
valid: function(license) {
|
||||||
if (!license.valid_key){
|
if (!license.valid_key){
|
||||||
return false;
|
return false;
|
||||||
@@ -45,6 +43,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();
|
||||||
|
|||||||
@@ -8,31 +8,23 @@ export default ['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', '$http',
|
|||||||
'$q', 'ConfigService',
|
'$q', 'ConfigService',
|
||||||
function ($rootScope, Rest, GetBasePath, ProcessErrors, $http, $q,
|
function ($rootScope, Rest, GetBasePath, ProcessErrors, $http, $q,
|
||||||
ConfigService) {
|
ConfigService) {
|
||||||
var license_info;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getFeatures: function(){
|
get: function(){
|
||||||
var config = ConfigService.get();
|
if (_.isEmpty($rootScope.features)) {
|
||||||
if(config){
|
var config = ConfigService.get();
|
||||||
license_info = config.license_info;
|
if(config){
|
||||||
$rootScope.features = config.license_info.features;
|
$rootScope.features = config.license_info.features;
|
||||||
$rootScope.$emit('featuresLoaded');
|
if($rootScope.featuresConfigured){
|
||||||
|
$rootScope.featuresConfigured.resolve($rootScope.features);
|
||||||
|
}
|
||||||
|
return $rootScope.features;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
return $rootScope.features;
|
return $rootScope.features;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
get: function(){
|
|
||||||
if(_.isEmpty($rootScope.features)){
|
|
||||||
return this.getFeatures();
|
|
||||||
} else {
|
|
||||||
// $q.when will ensure that the result is returned
|
|
||||||
// as a resovled promise.
|
|
||||||
return $q.when($rootScope.features);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
featureEnabled: function(feature) {
|
featureEnabled: function(feature) {
|
||||||
if($rootScope.features && $rootScope.features[feature] && $rootScope.features[feature] === true) {
|
if($rootScope.features && $rootScope.features[feature] && $rootScope.features[feature] === true) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,36 +1,15 @@
|
|||||||
export default function($stateProvider) {
|
export default function($stateProvider) {
|
||||||
this.$get = function() {
|
this.$get = function() {
|
||||||
return {
|
return {
|
||||||
getResolves: function(state){
|
|
||||||
var resolve = state.resolve || {},
|
|
||||||
routes = ["signIn", "signOut"];
|
|
||||||
if(_.indexOf(routes, state.name)>-1){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
// resolve.features = ['FeaturesService', function(FeaturesService) {
|
|
||||||
// return FeaturesService.get();
|
|
||||||
// }];
|
|
||||||
// resolve.features = ['CheckLicense', 'Store', '$state',
|
|
||||||
// function(CheckLicense, Store, $state) {
|
|
||||||
// var license = Store('license');
|
|
||||||
// if(CheckLicense.valid(license)=== false){
|
|
||||||
// $state.go('license');
|
|
||||||
// }
|
|
||||||
// }];
|
|
||||||
return resolve;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
addState: function(state) {
|
addState: function(state) {
|
||||||
var route = state.route || state.url,
|
var route = state.route || state.url;
|
||||||
resolve = this.getResolves(state);
|
|
||||||
|
|
||||||
$stateProvider.state(state.name, {
|
$stateProvider.state(state.name, {
|
||||||
url: route,
|
url: route,
|
||||||
controller: state.controller,
|
controller: state.controller,
|
||||||
templateUrl: state.templateUrl,
|
templateUrl: state.templateUrl,
|
||||||
resolve: resolve,
|
resolve: state.resolve,
|
||||||
params: state.params,
|
params: state.params,
|
||||||
data: state.data,
|
data: state.data,
|
||||||
ncyBreadcrumb: state.ncyBreadcrumb,
|
ncyBreadcrumb: state.ncyBreadcrumb,
|
||||||
|
|||||||
Reference in New Issue
Block a user