mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 11:40:05 -03:30
fixing issue where first route was empty on refresh
This commit is contained in:
@@ -214,8 +214,10 @@ var tower = angular.module('Tower', [
|
||||
timeout: 4000
|
||||
});
|
||||
}])
|
||||
.config(['$stateProvider', '$urlRouterProvider', '$breadcrumbProvider', '$urlMatcherFactoryProvider',
|
||||
function ($stateProvider, $urlRouterProvider, $breadcrumbProvider, $urlMatcherFactoryProvider) {
|
||||
.config(['$stateProvider', '$urlRouterProvider', '$breadcrumbProvider',
|
||||
'$urlMatcherFactoryProvider',
|
||||
function ($stateProvider, $urlRouterProvider, $breadcrumbProvider,
|
||||
$urlMatcherFactoryProvider) {
|
||||
$urlMatcherFactoryProvider.strictMode(false);
|
||||
$breadcrumbProvider.setOptions({
|
||||
templateUrl: urlPrefix + 'partials/breadcrumb.html'
|
||||
@@ -246,7 +248,7 @@ var tower = angular.module('Tower', [
|
||||
graphData: ['$q', 'jobStatusGraphData', 'FeaturesService', function($q, jobStatusGraphData, FeaturesService) {
|
||||
return $q.all({
|
||||
jobStatus: jobStatusGraphData.get("month", "all"),
|
||||
features: FeaturesService.get()
|
||||
// features: FeaturesService.get()
|
||||
});
|
||||
}]
|
||||
}
|
||||
@@ -521,10 +523,11 @@ var tower = angular.module('Tower', [
|
||||
'ClearScope', 'Socket', 'LoadConfig', 'Store',
|
||||
'ShowSocketHelp', 'pendoService', 'Prompt', 'Rest', 'Wait',
|
||||
'ProcessErrors', '$state', 'GetBasePath', 'ConfigService',
|
||||
'FeaturesService',
|
||||
function ($q, $compile, $cookieStore, $rootScope, $log, CheckLicense,
|
||||
$location, Authorization, LoadBasePaths, Timer, ClearScope, Socket,
|
||||
LoadConfig, Store, ShowSocketHelp, pendoService, Prompt, Rest, Wait,
|
||||
ProcessErrors, $state, GetBasePath, ConfigService) {
|
||||
ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService) {
|
||||
var sock;
|
||||
$rootScope.addPermission = function (scope) {
|
||||
$compile("<add-permissions class='AddPermissions'></add-permissions>")(scope);
|
||||
@@ -879,14 +882,14 @@ var tower = angular.module('Tower', [
|
||||
$rootScope.$emit('OpenSocket');
|
||||
ConfigService.getConfig().then(function(){
|
||||
pendoService.issuePendoIdentity();
|
||||
CheckLicense.test().then(function(){
|
||||
// $state.go(next);
|
||||
return;
|
||||
})
|
||||
.catch(function(){
|
||||
event.preventDefault();
|
||||
$state.go('license');
|
||||
});
|
||||
CheckLicense.test();
|
||||
FeaturesService.get();
|
||||
if($location.$$path === "/home" && $state.current && $state.current.name === ""){
|
||||
$state.go('dashboard');
|
||||
}
|
||||
else if($location.$$path === "/portal" && $state.current && $state.current.name === ""){
|
||||
$state.go('portalMode');
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export default
|
||||
[ 'templateUrl', '$state', 'FeaturesService', 'ProcessErrors', 'Store', 'Empty', '$log', function(templateUrl, $state, FeaturesService, ProcessErrors, Store, Empty, $log) {
|
||||
['templateUrl', '$state', 'FeaturesService', 'ProcessErrors', '$rootScope',
|
||||
function(templateUrl, $state, FeaturesService, ProcessErrors, $rootScope) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: templateUrl('bread-crumb/bread-crumb'),
|
||||
@@ -10,90 +11,62 @@ export default
|
||||
scope.showActivityStreamButton = false;
|
||||
scope.loadingLicense = true;
|
||||
|
||||
scope.toggleActivityStream = function() {
|
||||
scope.openActivityStream = function() {
|
||||
|
||||
// If the user is not already on the activity stream then they want to navigate to it
|
||||
if(!scope.activityStreamActive) {
|
||||
var stateGoParams = {};
|
||||
|
||||
if(streamConfig && streamConfig.activityStream) {
|
||||
if(streamConfig.activityStreamTarget) {
|
||||
stateGoParams.target = streamConfig.activityStreamTarget;
|
||||
}
|
||||
if(streamConfig.activityStreamId) {
|
||||
stateGoParams.id = $state.params[streamConfig.activityStreamId];
|
||||
}
|
||||
}
|
||||
|
||||
$state.go('activityStream', stateGoParams);
|
||||
}
|
||||
// The user is navigating away from the activity stream - take them back from whence they came
|
||||
else {
|
||||
// Pull the previous state out of local storage
|
||||
var previousState = Store('previous_state');
|
||||
|
||||
if(previousState && !Empty(previousState.name)) {
|
||||
$state.go(previousState.name, previousState.fromParams);
|
||||
}
|
||||
else {
|
||||
// If for some reason something went wrong (like local storage was wiped, etc) take the
|
||||
// user back to the dashboard
|
||||
$state.go('dashboard');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
scope.$on("$stateChangeSuccess", function updateActivityStreamButton(event, toState, toParams, fromState, fromParams) {
|
||||
|
||||
if(fromState && !Empty(fromState.name)) {
|
||||
// Go ahead and attach the from params to the state object so that it can all be stored together
|
||||
fromState.fromParams = fromParams ? fromParams : {};
|
||||
|
||||
// Store the state that we're coming from in local storage to be accessed when navigating away from the
|
||||
// activity stream
|
||||
Store('previous_state', fromState);
|
||||
}
|
||||
|
||||
streamConfig = (toState && toState.data) ? toState.data : {};
|
||||
var stateGoParams = {};
|
||||
|
||||
if(streamConfig && streamConfig.activityStream) {
|
||||
|
||||
// Check to see if activity_streams is an enabled feature. $stateChangeSuccess fires
|
||||
// after the resolve on the state declaration so features should be available at this
|
||||
// point. We use the get() function call here just in case the features aren't available.
|
||||
// The get() function will only fire off the server call if the features aren't already
|
||||
// attached to the $rootScope.
|
||||
|
||||
FeaturesService.get()
|
||||
.then(function() {
|
||||
scope.loadingLicense = false;
|
||||
scope.activityStreamActive = (toState.name === 'activityStream') ? true : false;
|
||||
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || toState.name === 'activityStream') ? true : false;
|
||||
var licenseInfo = FeaturesService.getLicenseInfo();
|
||||
scope.licenseType = licenseInfo ? licenseInfo.license_type : null;
|
||||
if (!licenseInfo) {
|
||||
console.warn("License info not loaded correctly"); // jshint ignore:line
|
||||
$log.error("License info not loaded correctly");
|
||||
}
|
||||
})
|
||||
.catch(function (response) {
|
||||
ProcessErrors(null, response.data, response.status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get feature info. GET returned status: ' +
|
||||
response.status
|
||||
});
|
||||
});
|
||||
|
||||
if(streamConfig.activityStreamTarget) {
|
||||
stateGoParams.target = streamConfig.activityStreamTarget;
|
||||
}
|
||||
if(streamConfig.activityStreamId) {
|
||||
stateGoParams.id = $state.params[streamConfig.activityStreamId];
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
scope.showActivityStreamButton = false;
|
||||
$state.go('activityStream', stateGoParams);
|
||||
};
|
||||
|
||||
}
|
||||
});
|
||||
scope.$on("$stateChangeStart", function updateActivityStreamButton(event, toState) {
|
||||
|
||||
}
|
||||
};
|
||||
}];
|
||||
streamConfig = (toState && toState.data) ? toState.data : {};
|
||||
|
||||
if(streamConfig && streamConfig.activityStream) {
|
||||
|
||||
// Check to see if activity_streams is an enabled feature. $stateChangeSuccess fires
|
||||
// after the resolve on the state declaration so features should be available at this
|
||||
// point. We use the get() function call here just in case the features aren't available.
|
||||
// The get() function will only fire off the server call if the features aren't already
|
||||
// attached to the $rootScope.
|
||||
var features = FeaturesService.get();
|
||||
if(features){
|
||||
scope.loadingLicense = false;
|
||||
scope.activityStreamActive = (toState.name === 'activityStream') ? true : false;
|
||||
scope.showActivityStreamButton = (FeaturesService.featureEnabled('activity_streams') || toState.name ==='activityStream') ? true : false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
scope.showActivityStreamButton = false;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.$on('featuresLoaded', function(){
|
||||
FeaturesService.get()
|
||||
.then(function() {
|
||||
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
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
||||
@@ -22,9 +22,6 @@ var dashboardHostsList = {
|
||||
label: "HOSTS"
|
||||
},
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}],
|
||||
hosts: ['Rest', 'GetBasePath', '$stateParams', function(Rest, GetBasePath, $stateParams){
|
||||
var defaultUrl = GetBasePath('hosts') + '?page_size=10' + ($stateParams['active-failures'] ? '&has_active_failures=true' : '' );
|
||||
Rest.setUrl(defaultUrl);
|
||||
|
||||
@@ -17,10 +17,5 @@ export default {
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
label: "INVENTORY EDIT"
|
||||
},
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,10 +17,5 @@ export default {
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
label: "JOB TEMPLATES"
|
||||
},
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -33,20 +33,20 @@ export default
|
||||
// Intended to for runtime or pre-state checks
|
||||
// Returns false if invalid
|
||||
valid: function(license) {
|
||||
if (!license.valid_key){
|
||||
return false;
|
||||
}
|
||||
else if (license.free_instances <= 0){
|
||||
return false;
|
||||
}
|
||||
// notify if less than 15 days remaining
|
||||
else if (license.time_remaining / 1000 / 60 / 60 / 24 > 15){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (!license.valid_key){
|
||||
return false;
|
||||
}
|
||||
else if (license.free_instances <= 0){
|
||||
return false;
|
||||
}
|
||||
// notify if less than 15 days remaining
|
||||
else if (license.time_remaining / 1000 / 60 / 60 / 24 > 15){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
test: function(event){
|
||||
var deferred = $q.defer(),
|
||||
var //deferred = $q.defer(),
|
||||
license = this.get();
|
||||
if(license === null || !$rootScope.license_tested){
|
||||
if(this.valid(license) === false) {
|
||||
@@ -55,11 +55,11 @@ export default
|
||||
event.preventDefault();
|
||||
}
|
||||
$state.go('license');
|
||||
deferred.reject();
|
||||
// deferred.reject();
|
||||
}
|
||||
else {
|
||||
$rootScope.licenseMissing = false;
|
||||
deferred.resolve();
|
||||
// deferred.resolve();
|
||||
}
|
||||
}
|
||||
else if(this.valid(license) === false) {
|
||||
@@ -68,13 +68,13 @@ export default
|
||||
if(event){
|
||||
event.preventDefault();
|
||||
}
|
||||
deferred.reject(license);
|
||||
// deferred.reject(license);
|
||||
}
|
||||
else {
|
||||
$rootScope.licenseMissing = false;
|
||||
deferred.resolve(license);
|
||||
// deferred.resolve(license);
|
||||
}
|
||||
return deferred.promise;
|
||||
return;// deferred.promise;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -11,11 +11,6 @@ export default {
|
||||
route: '/add',
|
||||
templateUrl: templateUrl('notifications/add/add'),
|
||||
controller: 'notificationsAddController',
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
},
|
||||
ncyBreadcrumb: {
|
||||
parent: 'notifications',
|
||||
label: 'Create Notification Template'
|
||||
|
||||
@@ -15,10 +15,5 @@ export default {
|
||||
ncyBreadcrumb: {
|
||||
parent: "organizations",
|
||||
label: "CREATE ORGANIZATION"
|
||||
},
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -10,10 +10,5 @@ export default {
|
||||
name: 'userPermissionsAdd',
|
||||
route: '/users/:user_id/permissions/add',
|
||||
templateUrl: templateUrl('permissions/shared/user-permissions'),
|
||||
controller: 'permissionsAddController',
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
}
|
||||
controller: 'permissionsAddController'
|
||||
};
|
||||
|
||||
@@ -10,10 +10,5 @@ export default {
|
||||
name: 'userPermissionsEdit',
|
||||
route: '/users/:user_id/permissions/:permission_id',
|
||||
templateUrl: templateUrl('permissions/shared/user-permissions'),
|
||||
controller: 'permissionsEditController',
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
}
|
||||
controller: 'permissionsEditController'
|
||||
};
|
||||
|
||||
@@ -10,11 +10,6 @@ export default {
|
||||
ncyBreadcrumb: {
|
||||
label: "MY VIEW"
|
||||
},
|
||||
resolve: {
|
||||
features: ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}]
|
||||
},
|
||||
views: {
|
||||
// the empty parent ui-view
|
||||
"" : {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
|
||||
export default
|
||||
['GetBasePath', 'ProcessErrors', '$q', 'Rest', '$rootScope',
|
||||
function (GetBasePath, ProcessErrors, $q, Rest, $rootScope) {
|
||||
['GetBasePath', 'ProcessErrors', '$q', 'Rest', '$rootScope', '$state',
|
||||
function (GetBasePath, ProcessErrors, $q, Rest, $rootScope, $state) {
|
||||
return {
|
||||
get: function(){
|
||||
return this.config;
|
||||
@@ -20,7 +20,7 @@ export default
|
||||
delete: function(){
|
||||
delete(this.config);
|
||||
},
|
||||
|
||||
|
||||
getConfig: function () {
|
||||
var config = this.get(),
|
||||
that = this,
|
||||
|
||||
@@ -13,23 +13,12 @@ function ($rootScope, Rest, GetBasePath, ProcessErrors, $http, $q,
|
||||
return {
|
||||
getFeatures: function(){
|
||||
var config = ConfigService.get();
|
||||
license_info = config.license_info;
|
||||
$rootScope.features = config.license_info.features;
|
||||
return $rootScope.features;
|
||||
// var promise;
|
||||
// Rest.setUrl(GetBasePath('config'));
|
||||
// promise = Rest.get();
|
||||
// return promise.then(function (data) {
|
||||
// license_info = data.data.license_info;
|
||||
// $rootScope.features = data.data.license_info.features;
|
||||
// return $rootScope.features;
|
||||
// }).catch(function (response) {
|
||||
// ProcessErrors($rootScope, response.data, response.status, null, {
|
||||
// hdr: 'Error!',
|
||||
// msg: 'Failed to get license info. GET returned status: ' +
|
||||
// response.status
|
||||
// });
|
||||
// });
|
||||
if(config){
|
||||
license_info = config.license_info;
|
||||
$rootScope.features = config.license_info.features;
|
||||
return $rootScope.features;
|
||||
}
|
||||
return {};
|
||||
},
|
||||
get: function(){
|
||||
if(_.isEmpty($rootScope.features)){
|
||||
|
||||
@@ -8,9 +8,9 @@ export default function($stateProvider) {
|
||||
return;
|
||||
}
|
||||
else{
|
||||
resolve.features = ['FeaturesService', function(FeaturesService) {
|
||||
return FeaturesService.get();
|
||||
}];
|
||||
// resolve.features = ['FeaturesService', function(FeaturesService) {
|
||||
// return FeaturesService.get();
|
||||
// }];
|
||||
// resolve.features = ['CheckLicense', 'Store', '$state',
|
||||
// function(CheckLicense, Store, $state) {
|
||||
// var license = Store('license');
|
||||
|
||||
Reference in New Issue
Block a user