mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 16:51:11 +03:00
Improvements to feature service timing for AS button
This commit is contained in:
parent
4d1c43f4bd
commit
40abf57b4a
@ -920,6 +920,10 @@ var tower = angular.module('Tower', [
|
||||
// create a promise that will resolve state $AnsibleConfig is loaded
|
||||
$rootScope.loginConfig = $q.defer();
|
||||
}
|
||||
if (!$rootScope.featuresConfigured) {
|
||||
// create a promise that will resolve state $AnsibleConfig is loaded
|
||||
$rootScope.featuresConfigured = $q.defer();
|
||||
}
|
||||
$rootScope.licenseMissing = true;
|
||||
//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.
|
||||
|
@ -52,22 +52,15 @@ export default
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.$on('featuresLoaded', function(){
|
||||
FeaturesService.get()
|
||||
.then(function() {
|
||||
// scope.$on('featuresLoaded', function(){
|
||||
$rootScope.featuresConfigured.promise.then(function(features){
|
||||
// var features = FeaturesService.get();
|
||||
if(features){
|
||||
scope.loadingLicense = false;
|
||||
scope.activityStreamActive = ($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
|
||||
});
|
||||
});
|
||||
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || $state.name ==='activityStream') ? true : false;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
@ -29,9 +29,7 @@ export default
|
||||
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) {
|
||||
if (!license.valid_key){
|
||||
return false;
|
||||
@ -45,6 +43,7 @@ export default
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
test: function(event){
|
||||
var //deferred = $q.defer(),
|
||||
license = this.get();
|
||||
|
@ -8,31 +8,23 @@ export default ['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', '$http',
|
||||
'$q', 'ConfigService',
|
||||
function ($rootScope, Rest, GetBasePath, ProcessErrors, $http, $q,
|
||||
ConfigService) {
|
||||
var license_info;
|
||||
|
||||
return {
|
||||
getFeatures: function(){
|
||||
var config = ConfigService.get();
|
||||
if(config){
|
||||
license_info = config.license_info;
|
||||
$rootScope.features = config.license_info.features;
|
||||
$rootScope.$emit('featuresLoaded');
|
||||
get: function(){
|
||||
if (_.isEmpty($rootScope.features)) {
|
||||
var config = ConfigService.get();
|
||||
if(config){
|
||||
$rootScope.features = config.license_info.features;
|
||||
if($rootScope.featuresConfigured){
|
||||
$rootScope.featuresConfigured.resolve($rootScope.features);
|
||||
}
|
||||
return $rootScope.features;
|
||||
}
|
||||
}
|
||||
else{
|
||||
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) {
|
||||
if($rootScope.features && $rootScope.features[feature] && $rootScope.features[feature] === true) {
|
||||
return true;
|
||||
|
@ -1,36 +1,15 @@
|
||||
export default function($stateProvider) {
|
||||
this.$get = function() {
|
||||
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) {
|
||||
var route = state.route || state.url,
|
||||
resolve = this.getResolves(state);
|
||||
var route = state.route || state.url;
|
||||
|
||||
$stateProvider.state(state.name, {
|
||||
url: route,
|
||||
controller: state.controller,
|
||||
templateUrl: state.templateUrl,
|
||||
resolve: resolve,
|
||||
resolve: state.resolve,
|
||||
params: state.params,
|
||||
data: state.data,
|
||||
ncyBreadcrumb: state.ncyBreadcrumb,
|
||||
|
Loading…
Reference in New Issue
Block a user