fixing issues w/ lazyloaded states

This commit is contained in:
Jared Tabor
2017-10-05 10:55:30 -04:00
parent 07139820cb
commit 6e3f4a7a6e
12 changed files with 30 additions and 31 deletions

View File

@@ -175,12 +175,12 @@ angular
'CheckLicense', '$location', 'Authorization', 'LoadBasePaths', 'Timer',
'LoadConfig', 'Store', 'pendoService', 'Prompt', 'Rest',
'Wait', 'ProcessErrors', '$state', 'GetBasePath', 'ConfigService',
'FeaturesService', '$filter', 'SocketService', 'AppStrings',
'FeaturesService', '$filter', 'SocketService', 'AppStrings', '$transitions',
function($stateExtender, $q, $compile, $cookies, $rootScope, $log, $stateParams,
CheckLicense, $location, Authorization, LoadBasePaths, Timer,
LoadConfig, Store, pendoService, Prompt, Rest, Wait,
ProcessErrors, $state, GetBasePath, ConfigService, FeaturesService,
$filter, SocketService, AppStrings) {
$filter, SocketService, AppStrings, $transitions) {
$rootScope.$state = $state;
$rootScope.$state.matches = function(stateName) {
@@ -243,9 +243,7 @@ angular
$rootScope.crumbCache = [];
$rootScope.$on("$stateChangeStart", function (event, next) {
// let current_title = $rootScope.$state.current.ncyBreadcrumbLabel || "";
// $rootScope.tabTitle = `Ansible ${$rootScope.BRAND_NAME} ${current_title}`;
$transitions.onStart({}, function(trans) {
// Remove any lingering intervals
// except on jobResults.* states
var jobResultStates = [
@@ -256,10 +254,10 @@ angular
'jobResult.host-events',
'jobResult.host-event.stdout'
];
if ($rootScope.jobResultInterval && !_.includes(jobResultStates, next.name) ) {
if ($rootScope.jobResultInterval && !_.includes(jobResultStates, trans.to().name) ) {
window.clearInterval($rootScope.jobResultInterval);
}
if ($rootScope.jobStdOutInterval && !_.includes(jobResultStates, next.name) ) {
if ($rootScope.jobStdOutInterval && !_.includes(jobResultStates, trans.to().name) ) {
window.clearInterval($rootScope.jobStdOutInterval);
}
@@ -298,19 +296,19 @@ angular
}
if (Authorization.isUserLoggedIn() === false) {
if (next.name !== "signIn") {
if (trans.to().name !== "signIn") {
$state.go('signIn');
}
} else if ($rootScope && $rootScope.sessionTimer && $rootScope.sessionTimer.isExpired()) {
// gets here on timeout
if (next.name !== "signIn") {
if (trans.to().name !== "signIn") {
$state.go('signIn');
}
} else {
if ($rootScope.current_user === undefined || $rootScope.current_user === null) {
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() {
// if not headed to /login or /logout, then check the license
CheckLicense.test(event);
@@ -320,20 +318,21 @@ angular
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
let toParamsWithoutSearchKeys = {};
let fromParamsWithoutSearchKeys = {};
for (let key in toParams) {
if (toParams.hasOwnProperty(key) && !/_search/.test(key)) {
toParamsWithoutSearchKeys[key] = toParams[key];
for (let key in trans.$to().params) {
if (trans.$to().params.hasOwnProperty(key) && !/_search/.test(key)) {
toParamsWithoutSearchKeys[key] = trans.$to().params[key];
}
}
for (let key in fromParams) {
if (fromParams.hasOwnProperty(key) && !/_search/.test(key)) {
fromParamsWithoutSearchKeys[key] = fromParams[key];
for (let key in trans.$from().params) {
if (trans.$from().params.hasOwnProperty(key) && !/_search/.test(key)) {
fromParamsWithoutSearchKeys[key] = trans.$from().params[key];
}
}
@@ -345,8 +344,8 @@ angular
document.body.scrollTop = document.documentElement.scrollTop = 0;
}
if (fromState.name === 'license' && toParams.hasOwnProperty('licenseMissing')) {
$rootScope.licenseMissing = toParams.licenseMissing;
if (trans.from().name === 'license' && trans.$to().params.hasOwnProperty('licenseMissing')) {
$rootScope.licenseMissing = trans.$to().params.licenseMissing;
}
var list, id;
// broadcast event change if editing crud object

View File

@@ -24,7 +24,7 @@ angular.module('credentialTypes', [
let stateDefinitions = stateDefinitionsProvider.$get();
$stateProvider.state({
name: 'credentialTypes',
name: 'credentialTypes.**',
url: '/credential_type',
lazyLoad: () => stateDefinitions.generateTree({
parent: 'credentialTypes',

View File

@@ -51,7 +51,7 @@ angular.module('instanceGroups', [CapacityBar.name])
}
$stateProvider.state({
name: 'instanceGroups',
name: 'instanceGroups.**',
url: '/instance_groups',
lazyLoad: () => generateInstanceGroupsStates()
});

View File

@@ -104,7 +104,7 @@ angular.module('host', [
};
$stateProvider.state({
name: 'hosts',
name: 'hosts.**',
url: '/hosts',
lazyLoad: () => generateHostStates()
});

View File

@@ -349,7 +349,7 @@ angular.module('inventory', [
}
$stateProvider.state({
name: 'inventories',
name: 'inventories.**',
url: '/inventories',
lazyLoad: () => generateInventoryStates()
});

View File

@@ -24,7 +24,7 @@ angular.module('inventoryScripts', [
let stateDefinitions = stateDefinitionsProvider.$get();
$stateProvider.state({
name: 'inventoryScripts',
name: 'inventoryScripts.**',
url: '/inventory_script',
lazyLoad: () => stateDefinitions.generateTree({
parent: 'inventoryScripts',

View File

@@ -36,7 +36,7 @@ angular.module('notifications', [
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
// see: stateDefinition.factory for usage documentation
$stateProvider.state({
name: 'notifications',
name: 'notifications.**',
url: '/notification_templates',
ncyBreadcrumb: {
label: N_("NOTIFICATIONS")

View File

@@ -32,7 +32,7 @@ angular.module('Organizations', [
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
// see: stateDefinition.factory for usage documentation
$stateProvider.state({
name: 'organizations',
name: 'organizations.**',
url: '/organizations',
lazyLoad: () => stateDefinitions.generateTree({
parent: 'organizations', // top-most node in the generated tree

View File

@@ -48,7 +48,7 @@ angular.module('Projects', [])
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
// see: stateDefinition.factory for usage documentation
$stateProvider.state({
name: 'projects',
name: 'projects.**',
url: '/projects',
lazyLoad: () => stateDefinitions.generateTree({
parent: 'projects', // top-most node in the generated tree (will replace this state definition)

View File

@@ -25,7 +25,7 @@ angular.module('Teams', [])
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
// see: stateDefinition.factory for usage documentation
$stateProvider.state({
name: 'teams',
name: 'teams.**',
url: '/teams',
lazyLoad: () => stateDefinitions.generateTree({
parent: 'teams',

View File

@@ -892,7 +892,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates.
}
stateTree = {
name: 'templates',
name: 'templates.**',
url: '/templates',
lazyLoad: () => generateStateTree()
};

View File

@@ -25,7 +25,7 @@ angular.module('Users', [])
// lazily generate a tree of substates which will replace this node in ui-router's stateRegistry
// see: stateDefinition.factory for usage documentation
$stateProvider.state({
name: 'users',
name: 'users.**',
url: '/users',
lazyLoad: () => stateDefinitions.generateTree({
parent: 'users',