mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 07:17:40 -02:30
fixing issues w/ lazyloaded states
This commit is contained in:
@@ -175,12 +175,12 @@ angular
|
|||||||
'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer',
|
'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer',
|
||||||
'LoadConfig', 'Store', 'pendoService', 'Prompt', 'Rest',
|
'LoadConfig', 'Store', 'pendoService', 'Prompt', 'Rest',
|
||||||
'Wait', 'ProcessErrors', '$state', 'GetBasePath', 'ConfigService',
|
'Wait', 'ProcessErrors', '$state', 'GetBasePath', 'ConfigService',
|
||||||
'FeaturesService', '$filter', 'SocketService', 'AppStrings',
|
'FeaturesService', '$filter', 'SocketService', 'AppStrings', '$transitions',
|
||||||
function($stateExtender, $q, $compile, $cookies, $rootScope, $log, $stateParams,
|
function($stateExtender, $q, $compile, $cookies, $rootScope, $log, $stateParams,
|
||||||
CheckLicense, $location, Authorization, LoadBasePaths, Timer,
|
CheckLicense, $location, Authorization, LoadBasePaths, Timer,
|
||||||
LoadConfig, Store, pendoService, Prompt, Rest, Wait,
|
LoadConfig, Store, pendoService, Prompt, Rest, Wait,
|
||||||
ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService,
|
ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService,
|
||||||
$filter, SocketService, AppStrings) {
|
$filter, SocketService, AppStrings, $transitions) {
|
||||||
|
|
||||||
$rootScope.$state = $state;
|
$rootScope.$state = $state;
|
||||||
$rootScope.$state.matches = function(stateName) {
|
$rootScope.$state.matches = function(stateName) {
|
||||||
@@ -243,9 +243,7 @@ angular
|
|||||||
|
|
||||||
$rootScope.crumbCache = [];
|
$rootScope.crumbCache = [];
|
||||||
|
|
||||||
$rootScope.$on("$stateChangeStart", function (event, next) {
|
$transitions.onStart({}, function(trans) {
|
||||||
// let current_title = $rootScope.$state.current.ncyBreadcrumbLabel || "";
|
|
||||||
// $rootScope.tabTitle = `Ansible ${$rootScope.BRAND_NAME} ${current_title}`;
|
|
||||||
// Remove any lingering intervals
|
// Remove any lingering intervals
|
||||||
// except on jobResults.* states
|
// except on jobResults.* states
|
||||||
var jobResultStates = [
|
var jobResultStates = [
|
||||||
@@ -256,10 +254,10 @@ angular
|
|||||||
'jobResult.host-events',
|
'jobResult.host-events',
|
||||||
'jobResult.host-event.stdout'
|
'jobResult.host-event.stdout'
|
||||||
];
|
];
|
||||||
if ($rootScope.jobResultInterval && !_.includes(jobResultStates, next.name) ) {
|
if ($rootScope.jobResultInterval && !_.includes(jobResultStates, trans.to().name) ) {
|
||||||
window.clearInterval($rootScope.jobResultInterval);
|
window.clearInterval($rootScope.jobResultInterval);
|
||||||
}
|
}
|
||||||
if ($rootScope.jobStdOutInterval && !_.includes(jobResultStates, next.name) ) {
|
if ($rootScope.jobStdOutInterval && !_.includes(jobResultStates, trans.to().name) ) {
|
||||||
window.clearInterval($rootScope.jobStdOutInterval);
|
window.clearInterval($rootScope.jobStdOutInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,19 +296,19 @@ angular
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Authorization.isUserLoggedIn() === false) {
|
if (Authorization.isUserLoggedIn() === false) {
|
||||||
if (next.name !== "signIn") {
|
if (trans.to().name !== "signIn") {
|
||||||
$state.go('signIn');
|
$state.go('signIn');
|
||||||
}
|
}
|
||||||
} else if ($rootScope && $rootScope.sessionTimer && $rootScope.sessionTimer.isExpired()) {
|
} else if ($rootScope && $rootScope.sessionTimer && $rootScope.sessionTimer.isExpired()) {
|
||||||
// gets here on timeout
|
// gets here on timeout
|
||||||
if (next.name !== "signIn") {
|
if (trans.to().name !== "signIn") {
|
||||||
$state.go('signIn');
|
$state.go('signIn');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($rootScope.current_user === undefined || $rootScope.current_user === null) {
|
if ($rootScope.current_user === undefined || $rootScope.current_user === null) {
|
||||||
Authorization.restoreUserInfo(); //user must have hit browser refresh
|
Authorization.restoreUserInfo(); //user must have hit browser refresh
|
||||||
}
|
}
|
||||||
if (next && (next.name !== "signIn" && next.name !== "signOut" && next.name !== "license")) {
|
if (trans.to().name && (trans.to().name !== "signIn" && trans.to().name !== "signOut" && trans.to().name !== "license")) {
|
||||||
ConfigService.getConfig().then(function() {
|
ConfigService.getConfig().then(function() {
|
||||||
// if not headed to /login or /logout, then check the license
|
// if not headed to /login or /logout, then check the license
|
||||||
CheckLicense.test(event);
|
CheckLicense.test(event);
|
||||||
@@ -320,20 +318,21 @@ angular
|
|||||||
activateTab();
|
activateTab();
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
|
// $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams) {
|
||||||
|
$transitions.onSuccess({}, function(trans) {
|
||||||
|
|
||||||
if(toState === fromState) {
|
if(trans.to() === trans.from()) {
|
||||||
// check to see if something other than a search param has changed
|
// check to see if something other than a search param has changed
|
||||||
let toParamsWithoutSearchKeys = {};
|
let toParamsWithoutSearchKeys = {};
|
||||||
let fromParamsWithoutSearchKeys = {};
|
let fromParamsWithoutSearchKeys = {};
|
||||||
for (let key in toParams) {
|
for (let key in trans.$to().params) {
|
||||||
if (toParams.hasOwnProperty(key) && !/_search/.test(key)) {
|
if (trans.$to().params.hasOwnProperty(key) && !/_search/.test(key)) {
|
||||||
toParamsWithoutSearchKeys[key] = toParams[key];
|
toParamsWithoutSearchKeys[key] = trans.$to().params[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (let key in fromParams) {
|
for (let key in trans.$from().params) {
|
||||||
if (fromParams.hasOwnProperty(key) && !/_search/.test(key)) {
|
if (trans.$from().params.hasOwnProperty(key) && !/_search/.test(key)) {
|
||||||
fromParamsWithoutSearchKeys[key] = fromParams[key];
|
fromParamsWithoutSearchKeys[key] = trans.$from().params[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,8 +344,8 @@ angular
|
|||||||
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
document.body.scrollTop = document.documentElement.scrollTop = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromState.name === 'license' && toParams.hasOwnProperty('licenseMissing')) {
|
if (trans.from().name === 'license' && trans.$to().params.hasOwnProperty('licenseMissing')) {
|
||||||
$rootScope.licenseMissing = toParams.licenseMissing;
|
$rootScope.licenseMissing = trans.$to().params.licenseMissing;
|
||||||
}
|
}
|
||||||
var list, id;
|
var list, id;
|
||||||
// broadcast event change if editing crud object
|
// broadcast event change if editing crud object
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ angular.module('credentialTypes', [
|
|||||||
let stateDefinitions = stateDefinitionsProvider.$get();
|
let stateDefinitions = stateDefinitionsProvider.$get();
|
||||||
|
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'credentialTypes',
|
name: 'credentialTypes.**',
|
||||||
url: '/credential_type',
|
url: '/credential_type',
|
||||||
lazyLoad: () => stateDefinitions.generateTree({
|
lazyLoad: () => stateDefinitions.generateTree({
|
||||||
parent: 'credentialTypes',
|
parent: 'credentialTypes',
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ angular.module('instanceGroups', [CapacityBar.name])
|
|||||||
}
|
}
|
||||||
|
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'instanceGroups',
|
name: 'instanceGroups.**',
|
||||||
url: '/instance_groups',
|
url: '/instance_groups',
|
||||||
lazyLoad: () => generateInstanceGroupsStates()
|
lazyLoad: () => generateInstanceGroupsStates()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ angular.module('host', [
|
|||||||
};
|
};
|
||||||
|
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'hosts',
|
name: 'hosts.**',
|
||||||
url: '/hosts',
|
url: '/hosts',
|
||||||
lazyLoad: () => generateHostStates()
|
lazyLoad: () => generateHostStates()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ angular.module('inventory', [
|
|||||||
}
|
}
|
||||||
|
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'inventories',
|
name: 'inventories.**',
|
||||||
url: '/inventories',
|
url: '/inventories',
|
||||||
lazyLoad: () => generateInventoryStates()
|
lazyLoad: () => generateInventoryStates()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ angular.module('inventoryScripts', [
|
|||||||
let stateDefinitions = stateDefinitionsProvider.$get();
|
let stateDefinitions = stateDefinitionsProvider.$get();
|
||||||
|
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'inventoryScripts',
|
name: 'inventoryScripts.**',
|
||||||
url: '/inventory_script',
|
url: '/inventory_script',
|
||||||
lazyLoad: () => stateDefinitions.generateTree({
|
lazyLoad: () => stateDefinitions.generateTree({
|
||||||
parent: 'inventoryScripts',
|
parent: 'inventoryScripts',
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ angular.module('notifications', [
|
|||||||
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
||||||
// see: stateDefinition.factory for usage documentation
|
// see: stateDefinition.factory for usage documentation
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'notifications',
|
name: 'notifications.**',
|
||||||
url: '/notification_templates',
|
url: '/notification_templates',
|
||||||
ncyBreadcrumb: {
|
ncyBreadcrumb: {
|
||||||
label: N_("NOTIFICATIONS")
|
label: N_("NOTIFICATIONS")
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ angular.module('Organizations', [
|
|||||||
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
||||||
// see: stateDefinition.factory for usage documentation
|
// see: stateDefinition.factory for usage documentation
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'organizations',
|
name: 'organizations.**',
|
||||||
url: '/organizations',
|
url: '/organizations',
|
||||||
lazyLoad: () => stateDefinitions.generateTree({
|
lazyLoad: () => stateDefinitions.generateTree({
|
||||||
parent: 'organizations', // top-most node in the generated tree
|
parent: 'organizations', // top-most node in the generated tree
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ angular.module('Projects', [])
|
|||||||
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
||||||
// see: stateDefinition.factory for usage documentation
|
// see: stateDefinition.factory for usage documentation
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'projects',
|
name: 'projects.**',
|
||||||
url: '/projects',
|
url: '/projects',
|
||||||
lazyLoad: () => stateDefinitions.generateTree({
|
lazyLoad: () => stateDefinitions.generateTree({
|
||||||
parent: 'projects', // top-most node in the generated tree (will replace this state definition)
|
parent: 'projects', // top-most node in the generated tree (will replace this state definition)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ angular.module('Teams', [])
|
|||||||
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
||||||
// see: stateDefinition.factory for usage documentation
|
// see: stateDefinition.factory for usage documentation
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'teams',
|
name: 'teams.**',
|
||||||
url: '/teams',
|
url: '/teams',
|
||||||
lazyLoad: () => stateDefinitions.generateTree({
|
lazyLoad: () => stateDefinitions.generateTree({
|
||||||
parent: 'teams',
|
parent: 'teams',
|
||||||
|
|||||||
@@ -892,7 +892,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates.
|
|||||||
}
|
}
|
||||||
|
|
||||||
stateTree = {
|
stateTree = {
|
||||||
name: 'templates',
|
name: 'templates.**',
|
||||||
url: '/templates',
|
url: '/templates',
|
||||||
lazyLoad: () => generateStateTree()
|
lazyLoad: () => generateStateTree()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ angular.module('Users', [])
|
|||||||
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
|
||||||
// see: stateDefinition.factory for usage documentation
|
// see: stateDefinition.factory for usage documentation
|
||||||
$stateProvider.state({
|
$stateProvider.state({
|
||||||
name: 'users',
|
name: 'users.**',
|
||||||
url: '/users',
|
url: '/users',
|
||||||
lazyLoad: () => stateDefinitions.generateTree({
|
lazyLoad: () => stateDefinitions.generateTree({
|
||||||
parent: 'users',
|
parent: 'users',
|
||||||
|
|||||||
Reference in New Issue
Block a user