mirror of
https://github.com/ansible/awx.git
synced 2026-05-22 08:17:39 -02: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
|
timeout: 4000
|
||||||
});
|
});
|
||||||
}])
|
}])
|
||||||
.config(['$stateProvider', '$urlRouterProvider', '$breadcrumbProvider', '$urlMatcherFactoryProvider',
|
.config(['$stateProvider', '$urlRouterProvider', '$breadcrumbProvider',
|
||||||
function ($stateProvider, $urlRouterProvider, $breadcrumbProvider, $urlMatcherFactoryProvider) {
|
'$urlMatcherFactoryProvider',
|
||||||
|
function ($stateProvider, $urlRouterProvider, $breadcrumbProvider,
|
||||||
|
$urlMatcherFactoryProvider) {
|
||||||
$urlMatcherFactoryProvider.strictMode(false);
|
$urlMatcherFactoryProvider.strictMode(false);
|
||||||
$breadcrumbProvider.setOptions({
|
$breadcrumbProvider.setOptions({
|
||||||
templateUrl: urlPrefix + 'partials/breadcrumb.html'
|
templateUrl: urlPrefix + 'partials/breadcrumb.html'
|
||||||
@@ -246,7 +248,7 @@ var tower = angular.module('Tower', [
|
|||||||
graphData: ['$q', 'jobStatusGraphData', 'FeaturesService', function($q, jobStatusGraphData, FeaturesService) {
|
graphData: ['$q', 'jobStatusGraphData', 'FeaturesService', function($q, jobStatusGraphData, FeaturesService) {
|
||||||
return $q.all({
|
return $q.all({
|
||||||
jobStatus: jobStatusGraphData.get("month", "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',
|
'ClearScope', 'Socket', 'LoadConfig', 'Store',
|
||||||
'ShowSocketHelp', 'pendoService', 'Prompt', 'Rest', 'Wait',
|
'ShowSocketHelp', 'pendoService', 'Prompt', 'Rest', 'Wait',
|
||||||
'ProcessErrors', '$state', 'GetBasePath', 'ConfigService',
|
'ProcessErrors', '$state', 'GetBasePath', 'ConfigService',
|
||||||
|
'FeaturesService',
|
||||||
function ($q, $compile, $cookieStore, $rootScope, $log, CheckLicense,
|
function ($q, $compile, $cookieStore, $rootScope, $log, CheckLicense,
|
||||||
$location, Authorization, LoadBasePaths, Timer, ClearScope, Socket,
|
$location, Authorization, LoadBasePaths, Timer, ClearScope, Socket,
|
||||||
LoadConfig, Store, ShowSocketHelp, pendoService, Prompt, Rest, Wait,
|
LoadConfig, Store, ShowSocketHelp, pendoService, Prompt, Rest, Wait,
|
||||||
ProcessErrors, $state, GetBasePath, ConfigService) {
|
ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService) {
|
||||||
var sock;
|
var sock;
|
||||||
$rootScope.addPermission = function (scope) {
|
$rootScope.addPermission = function (scope) {
|
||||||
$compile("<add-permissions class='AddPermissions'></add-permissions>")(scope);
|
$compile("<add-permissions class='AddPermissions'></add-permissions>")(scope);
|
||||||
@@ -879,14 +882,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().then(function(){
|
CheckLicense.test();
|
||||||
// $state.go(next);
|
FeaturesService.get();
|
||||||
return;
|
if($location.$$path === "/home" && $state.current && $state.current.name === ""){
|
||||||
})
|
$state.go('dashboard');
|
||||||
.catch(function(){
|
}
|
||||||
event.preventDefault();
|
else if($location.$$path === "/portal" && $state.current && $state.current.name === ""){
|
||||||
$state.go('license');
|
$state.go('portalMode');
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export default
|
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 {
|
return {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
templateUrl: templateUrl('bread-crumb/bread-crumb'),
|
templateUrl: templateUrl('bread-crumb/bread-crumb'),
|
||||||
@@ -10,90 +11,62 @@ export default
|
|||||||
scope.showActivityStreamButton = false;
|
scope.showActivityStreamButton = false;
|
||||||
scope.loadingLicense = true;
|
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
|
var stateGoParams = {};
|
||||||
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 : {};
|
|
||||||
|
|
||||||
if(streamConfig && streamConfig.activityStream) {
|
if(streamConfig && streamConfig.activityStream) {
|
||||||
|
if(streamConfig.activityStreamTarget) {
|
||||||
// Check to see if activity_streams is an enabled feature. $stateChangeSuccess fires
|
stateGoParams.target = streamConfig.activityStreamTarget;
|
||||||
// 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.
|
if(streamConfig.activityStreamId) {
|
||||||
// The get() function will only fire off the server call if the features aren't already
|
stateGoParams.id = $state.params[streamConfig.activityStreamId];
|
||||||
// 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
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
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"
|
label: "HOSTS"
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}],
|
|
||||||
hosts: ['Rest', 'GetBasePath', '$stateParams', function(Rest, GetBasePath, $stateParams){
|
hosts: ['Rest', 'GetBasePath', '$stateParams', function(Rest, GetBasePath, $stateParams){
|
||||||
var defaultUrl = GetBasePath('hosts') + '?page_size=10' + ($stateParams['active-failures'] ? '&has_active_failures=true' : '' );
|
var defaultUrl = GetBasePath('hosts') + '?page_size=10' + ($stateParams['active-failures'] ? '&has_active_failures=true' : '' );
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
|
|||||||
@@ -17,10 +17,5 @@ export default {
|
|||||||
},
|
},
|
||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
label: "INVENTORY EDIT"
|
label: "INVENTORY EDIT"
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,10 +17,5 @@ export default {
|
|||||||
},
|
},
|
||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
label: "JOB TEMPLATES"
|
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
|
// Intended to for runtime or pre-state checks
|
||||||
// Returns false if invalid
|
// Returns false if invalid
|
||||||
valid: function(license) {
|
valid: function(license) {
|
||||||
if (!license.valid_key){
|
if (!license.valid_key){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (license.free_instances <= 0){
|
else if (license.free_instances <= 0){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// notify if less than 15 days remaining
|
// notify if less than 15 days remaining
|
||||||
else if (license.time_remaining / 1000 / 60 / 60 / 24 > 15){
|
else if (license.time_remaining / 1000 / 60 / 60 / 24 > 15){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
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,13 +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 deferred.promise;
|
return;// deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,11 +11,6 @@ export default {
|
|||||||
route: '/add',
|
route: '/add',
|
||||||
templateUrl: templateUrl('notifications/add/add'),
|
templateUrl: templateUrl('notifications/add/add'),
|
||||||
controller: 'notificationsAddController',
|
controller: 'notificationsAddController',
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
parent: 'notifications',
|
parent: 'notifications',
|
||||||
label: 'Create Notification Template'
|
label: 'Create Notification Template'
|
||||||
|
|||||||
@@ -15,10 +15,5 @@ export default {
|
|||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
parent: "organizations",
|
parent: "organizations",
|
||||||
label: "CREATE ORGANIZATION"
|
label: "CREATE ORGANIZATION"
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,10 +10,5 @@ export default {
|
|||||||
name: 'userPermissionsAdd',
|
name: 'userPermissionsAdd',
|
||||||
route: '/users/:user_id/permissions/add',
|
route: '/users/:user_id/permissions/add',
|
||||||
templateUrl: templateUrl('permissions/shared/user-permissions'),
|
templateUrl: templateUrl('permissions/shared/user-permissions'),
|
||||||
controller: 'permissionsAddController',
|
controller: 'permissionsAddController'
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,10 +10,5 @@ export default {
|
|||||||
name: 'userPermissionsEdit',
|
name: 'userPermissionsEdit',
|
||||||
route: '/users/:user_id/permissions/:permission_id',
|
route: '/users/:user_id/permissions/:permission_id',
|
||||||
templateUrl: templateUrl('permissions/shared/user-permissions'),
|
templateUrl: templateUrl('permissions/shared/user-permissions'),
|
||||||
controller: 'permissionsEditController',
|
controller: 'permissionsEditController'
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ export default {
|
|||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
label: "MY VIEW"
|
label: "MY VIEW"
|
||||||
},
|
},
|
||||||
resolve: {
|
|
||||||
features: ['FeaturesService', function(FeaturesService) {
|
|
||||||
return FeaturesService.get();
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
views: {
|
views: {
|
||||||
// the empty parent ui-view
|
// the empty parent ui-view
|
||||||
"" : {
|
"" : {
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
['GetBasePath', 'ProcessErrors', '$q', 'Rest', '$rootScope',
|
['GetBasePath', 'ProcessErrors', '$q', 'Rest', '$rootScope', '$state',
|
||||||
function (GetBasePath, ProcessErrors, $q, Rest, $rootScope) {
|
function (GetBasePath, ProcessErrors, $q, Rest, $rootScope, $state) {
|
||||||
return {
|
return {
|
||||||
get: function(){
|
get: function(){
|
||||||
return this.config;
|
return this.config;
|
||||||
@@ -20,7 +20,7 @@ export default
|
|||||||
delete: function(){
|
delete: function(){
|
||||||
delete(this.config);
|
delete(this.config);
|
||||||
},
|
},
|
||||||
|
|
||||||
getConfig: function () {
|
getConfig: function () {
|
||||||
var config = this.get(),
|
var config = this.get(),
|
||||||
that = this,
|
that = this,
|
||||||
|
|||||||
@@ -13,23 +13,12 @@ function ($rootScope, Rest, GetBasePath, ProcessErrors, $http, $q,
|
|||||||
return {
|
return {
|
||||||
getFeatures: function(){
|
getFeatures: function(){
|
||||||
var config = ConfigService.get();
|
var config = ConfigService.get();
|
||||||
license_info = config.license_info;
|
if(config){
|
||||||
$rootScope.features = config.license_info.features;
|
license_info = config.license_info;
|
||||||
return $rootScope.features;
|
$rootScope.features = config.license_info.features;
|
||||||
// var promise;
|
return $rootScope.features;
|
||||||
// Rest.setUrl(GetBasePath('config'));
|
}
|
||||||
// promise = Rest.get();
|
return {};
|
||||||
// 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
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
},
|
},
|
||||||
get: function(){
|
get: function(){
|
||||||
if(_.isEmpty($rootScope.features)){
|
if(_.isEmpty($rootScope.features)){
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ export default function($stateProvider) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
resolve.features = ['FeaturesService', function(FeaturesService) {
|
// resolve.features = ['FeaturesService', function(FeaturesService) {
|
||||||
return FeaturesService.get();
|
// return FeaturesService.get();
|
||||||
}];
|
// }];
|
||||||
// resolve.features = ['CheckLicense', 'Store', '$state',
|
// resolve.features = ['CheckLicense', 'Store', '$state',
|
||||||
// function(CheckLicense, Store, $state) {
|
// function(CheckLicense, Store, $state) {
|
||||||
// var license = Store('license');
|
// var license = Store('license');
|
||||||
|
|||||||
Reference in New Issue
Block a user