diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js
index 3896f92460..968cf37fb6 100644
--- a/awx/ui/client/src/app.js
+++ b/awx/ui/client/src/app.js
@@ -31,7 +31,6 @@ import systemTracking from './system-tracking/main';
import inventoryScripts from './inventory-scripts/main';
import permissions from './permissions/main';
import managementJobs from './management-jobs/main';
-// import routeExtensions from './shared/route-extensions/main';
import breadcrumbs from './shared/breadcrumbs/main';
@@ -78,11 +77,9 @@ __deferLoadIfEnabled();
var tower = angular.module('Tower', [
// 'ngAnimate',
- 'ngRoute',
'ngSanitize',
'ngCookies',
RestServices.name,
- // routeExtensions.name,
browserData.name,
breadcrumbs.name,
systemTracking.name,
diff --git a/awx/ui/client/src/bread-crumb/bread-crumb.directive.js b/awx/ui/client/src/bread-crumb/bread-crumb.directive.js
index 55e3db0a47..2ffc037268 100644
--- a/awx/ui/client/src/bread-crumb/bread-crumb.directive.js
+++ b/awx/ui/client/src/bread-crumb/bread-crumb.directive.js
@@ -1,7 +1,7 @@
/* jshint unused: vars */
export default
- [ 'templateUrl', '$route', function(templateUrl, $route) {
+ [ 'templateUrl', '$state', function(templateUrl, $state) {
return {
restrict: 'E',
templateUrl: templateUrl('bread-crumb/bread-crumb'),
@@ -10,11 +10,11 @@ export default
scope.toggleActivityStreamActive = function(){
scope.activityStreamActive = !scope.activityStreamActive;
- }
+ };
scope.isActive = function (path) {
- if ($route.current && $route.current.regexp) {
- return $route.current.regexp.test(path);
+ if ($state.current && $state.current.regexp) {
+ return $state.current.regexp.test(path);
}
return false;
};
diff --git a/awx/ui/client/src/controllers/Inventories.js b/awx/ui/client/src/controllers/Inventories.js
index bef5ae1680..4c9323f17b 100644
--- a/awx/ui/client/src/controllers/Inventories.js
+++ b/awx/ui/client/src/controllers/Inventories.js
@@ -863,7 +863,9 @@ export function InventoriesManage ($log, $scope, $rootScope, $location,
});
$scope.systemTracking = function() {
- $state.transitionTo('systemTracking',
+ $scope.inventory = JSON.stringify($scope.inventory);
+ $scope.hostsSelectedItems = JSON.stringify($scope.hostsSelectedItems);
+ $state.go('systemTracking',
{ inventory: $scope.inventory,
hosts: $scope.hostsSelectedItems
});
diff --git a/awx/ui/client/src/controllers/Projects.js b/awx/ui/client/src/controllers/Projects.js
index 93ae7eee7c..57ecd6c786 100644
--- a/awx/ui/client/src/controllers/Projects.js
+++ b/awx/ui/client/src/controllers/Projects.js
@@ -343,7 +343,7 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $stateParams,
.error(function (data, status) {
ProcessErrors($scope, data, status, null, { hdr: 'Error!',
msg: 'Call to get project failed. GET status: ' + status });
- })
+ });
};
$scope.refresh = function () {
diff --git a/awx/ui/client/src/permissions/add/main.js b/awx/ui/client/src/permissions/add/main.js
index d25d107646..a92b224a3c 100644
--- a/awx/ui/client/src/permissions/add/main.js
+++ b/awx/ui/client/src/permissions/add/main.js
@@ -11,11 +11,7 @@ import controller from './add.controller';
export default
angular.module('permissionsAdd', [])
.controller('permissionsAddController', controller)
- .config(['$routeProvider', function($routeProvider) {
- var url = userRoute.route;
- delete userRoute.route;
- $routeProvider.when(url, userRoute);
- url = teamRoute.route;
- delete teamRoute.route;
- $routeProvider.when(url, teamRoute);
+ .run(['$stateExtender', function($stateExtender) {
+ $stateExtender.addState(userRoute);
+ $stateExtender.addState(teamRoute);
}]);
diff --git a/awx/ui/client/src/permissions/edit/main.js b/awx/ui/client/src/permissions/edit/main.js
index 08e4aa2b85..ea5103225e 100644
--- a/awx/ui/client/src/permissions/edit/main.js
+++ b/awx/ui/client/src/permissions/edit/main.js
@@ -11,11 +11,7 @@ import controller from './edit.controller';
export default
angular.module('permissionsEdit', [])
.controller('permissionsEditController', controller)
- .config(['$routeProvider', function($routeProvider) {
- var url = userRoute.route;
- delete userRoute.route;
- $routeProvider.when(url, userRoute);
- url = teamRoute.route;
- delete teamRoute.route;
- $routeProvider.when(url, teamRoute);
+ .run(['$stateExtender', function($stateExtender) {
+ $stateExtender.addState(userRoute);
+ $stateExtender.addState(teamRoute);
}]);
diff --git a/awx/ui/client/src/permissions/list/main.js b/awx/ui/client/src/permissions/list/main.js
index beed341e5b..b6f1770609 100644
--- a/awx/ui/client/src/permissions/list/main.js
+++ b/awx/ui/client/src/permissions/list/main.js
@@ -11,11 +11,7 @@ import controller from './list.controller';
export default
angular.module('permissionsList', [])
.controller('permissionsListController', controller)
- .config(['$routeProvider', function($routeProvider) {
- var url = userRoute.route;
- delete userRoute.route;
- $routeProvider.when(url, userRoute);
- url = teamRoute.route;
- delete teamRoute.route;
- $routeProvider.when(url, teamRoute);
+ .run(['$stateExtender', function($stateExtender) {
+ $stateExtender.addState(userRoute);
+ $stateExtender.addState(teamRoute);
}]);
diff --git a/awx/ui/client/src/shared/route-extensions/link-to.directive.js b/awx/ui/client/src/shared/route-extensions/link-to.directive.js
deleted file mode 100644
index a27782a6bc..0000000000
--- a/awx/ui/client/src/shared/route-extensions/link-to.directive.js
+++ /dev/null
@@ -1,96 +0,0 @@
-/*************************************************
- * Copyright (c) 2015 Ansible, Inc.
- *
- * All Rights Reserved
- *************************************************/
-
-/* jshint unused: vars */
-
-import {lookupRouteUrl} from './lookup-route-url';
-
-/**
- *
- * @ngdoc directive
- * @name routeExtensions.directive:linkTo
- * @desription
- * The `linkTo` directive looks up a route's URL and generates a link to that route. When a user
- * clicks the link, this directive calls the `transitionTo` factory to send them to the given
- * URL. For accessibility and fallback purposes, it also sets the `href` attribute of the link
- * to the path.
- *
- * Note that in this example the model object uses a key that matches up with the route parameteer
- * name in the route url (in this case `:id`).
- *
- * **N.B.** The below example currently won't run. It's included to show an example of using
- * the `linkTo` directive within code. In order for this to run, we will need to run
- * the code in an iframe (using something like `dgeni` instead of `grunt-ngdocs`).
- *
- * @example
- *
-
-
- angular.module('simpleRouteExample', ['ngRoute', 'routeExtensions'])
- .config(['$routeProvider', function($route) {
- $route.when('/posts/:id', {
- name: 'post',
- template: '{{post.title}}
{{post.body}}
',
- controller: 'post'
- });
- }]).controller('post', function($scope) {
- });
-
-
-
-
-
- *
- */
-export default
- [ '$route',
- '$location',
- 'transitionTo',
- function($routeProvider, $location, transitionTo) {
-
- function transitionListener(routeName, model, e) {
- e.stopPropagation();
- e.preventDefault();
- transitionTo(routeName, model);
- }
- return {
- restrict: 'A',
- scope: {
- routeName: '@linkTo',
- model: '&'
- },
- link: function (scope, element, attrs) {
-
- var listener;
-
- scope.$watch(function() {
- var model = scope.$eval(scope.model);
- return model;
- }, function(newValue) {
-
- var model = scope.$eval(scope.model);
- scope.url = lookupRouteUrl(scope.routeName, $routeProvider.routes, model, $location.$$html5);
- element.off('click', listener);
-
- listener = _.partial(transitionListener, scope.routeName, model);
-
- element.on('click', listener);
-
- element.attr('href', scope.url);
- }, true);
-
- }
- };
- }
- ];
diff --git a/awx/ui/client/src/shared/route-extensions/lookup-route-url.js b/awx/ui/client/src/shared/route-extensions/lookup-route-url.js
deleted file mode 100644
index 25e0b9b9b0..0000000000
--- a/awx/ui/client/src/shared/route-extensions/lookup-route-url.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/*************************************************
- * Copyright (c) 2015 Ansible, Inc.
- *
- * All Rights Reserved
- *************************************************/
-
-export function lookupRouteUrl(name, routes, models, html5Mode) {
- var route = _.find(routes, {name: name});
-
- if (angular.isUndefined(route)) {
- throw "Unknown route " + name;
- }
-
- var routeUrl = route.originalPath;
-
- if (!angular.isUndefined(models) && angular.isObject(models)) {
- var match = routeUrl.match(route.regexp);
- var keyMatchers = match.slice(1);
-
- routeUrl =
- keyMatchers.reduce(function(url, keyMatcher) {
- var value;
- var key = keyMatcher.replace(/^:/, '');
-
- var model = models[key];
-
- if (angular.isArray(model)) {
- value = _.compact(_.pluck(model, key));
-
- if (_.isEmpty(value)) {
- value = _.pluck(model, 'id');
- }
-
- value = value.join(',');
- } else if (angular.isObject(model)) {
- value = model[key];
-
- if (_.isEmpty(value)) {
- value = model.id;
- }
- }
-
- return url.replace(keyMatcher, value);
- }, routeUrl);
-
- }
-
- if (!html5Mode) {
- routeUrl = '#' + routeUrl;
- }
-
- return routeUrl;
-}
diff --git a/awx/ui/client/src/shared/route-extensions/main.js b/awx/ui/client/src/shared/route-extensions/main.js
deleted file mode 100644
index 859a3a2969..0000000000
--- a/awx/ui/client/src/shared/route-extensions/main.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*************************************************
- * Copyright (c) 2015 Ansible, Inc.
- *
- * All Rights Reserved
- *************************************************/
-
-import linkTo from './link-to.directive';
-import transitionTo from './transition-to.factory';
-import modelListener from './model-listener.config';
-
-/**
- * @ngdoc overview
- * @name routeExtensions
- * @description
- *
- * # routeExtensions
- *
- * Adds a couple useful features to ngRoute:
- * - Adds a `name` property to route objects; used to identify the route in transitions & links
- * - Adds the ability to pass model data when clicking a link that goes to a route
- * - Adds a directive that generates a route's URL from the route name & given models
- * - Adds the ability to specify models in route resolvers
- *
- * ## Usage
- *
- * If you need to generate a link to a route, then use the {@link routeExtensions.directive:linkTo `linkTo directive`}. If you need to transition to a route in JavaScript code, then use the {@link routeExtensions.factory:transitionTo `transitionTo service`}.
- *
-*/
-export default
- angular.module('routeExtensions',
- ['ngRoute'])
- .factory('transitionTo', transitionTo)
- .run(modelListener)
- .directive('linkTo', linkTo);
diff --git a/awx/ui/client/src/shared/route-extensions/model-listener.config.js b/awx/ui/client/src/shared/route-extensions/model-listener.config.js
deleted file mode 100644
index e685ab1a30..0000000000
--- a/awx/ui/client/src/shared/route-extensions/model-listener.config.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/*************************************************
- * Copyright (c) 2015 Ansible, Inc.
- *
- * All Rights Reserved
- *************************************************/
-
-import {wrapDelegate} from './route-params.decorator';
-
-export default
- [ '$rootScope',
- '$stateParams',
- function($rootScope, $stateParams) {
- $rootScope.$on('$routeChangeStart', function(e, newRoute) {
- wrapDelegate(newRoute);
- });
-
- $rootScope.$on('$routeChangeSuccess', function(e, newRoute) {
- if (angular.isUndefined(newRoute.model)) {
- var keys = Object.keys(newRoute.params);
- var models = keys.reduce(function(model, key) {
- model[key] = newRoute.locals[key];
- return model;
- }, {});
-
- $stateParams.model = models;
- }
- });
- }
- ];
diff --git a/awx/ui/client/src/shared/route-extensions/route-params.decorator.js b/awx/ui/client/src/shared/route-extensions/route-params.decorator.js
deleted file mode 100644
index 7702031c4b..0000000000
--- a/awx/ui/client/src/shared/route-extensions/route-params.decorator.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/*************************************************
- * Copyright (c) 2015 Ansible, Inc.
- *
- * All Rights Reserved
- *************************************************/
-
-export function wrapDelegate($delegate) {
- $delegate.hasModelKey = function hasModelKey(key) {
- return $delegate.params.hasOwnProperty('model') &&
- $delegate.params.model.hasOwnProperty(key);
- };
-
- return $delegate;
-}
-
-export default
- [ '$provide',
- function($provide) {
- $provide.decorator('$route', wrapDelegate);
-
- }
- ];
diff --git a/awx/ui/client/src/shared/route-extensions/transition-to.factory.js b/awx/ui/client/src/shared/route-extensions/transition-to.factory.js
deleted file mode 100644
index aeec18e43e..0000000000
--- a/awx/ui/client/src/shared/route-extensions/transition-to.factory.js
+++ /dev/null
@@ -1,137 +0,0 @@
-/*************************************************
- * Copyright (c) 2015 Ansible, Inc.
- *
- * All Rights Reserved
- *************************************************/
-
-import {lookupRouteUrl} from './lookup-route-url';
-
-/**
- * @ngdoc service
- * @name routeExtensions.service:transitionTo
- * @description
- * The `transitionTo` service generates a URL given a route name and model parameters, then
- * updates the browser's URL via `$location.path`. Use this in situations where you cannot
- * use the `linkTo` directive, for example to redirect the user after saving an object.
- *
- * @param {string} routeName The name of the route whose URL you want to redirect to (corresponds
- * name property of route)
- * @param {object} model The model you want to use to generate the URL and be passed to the new
- * route. This object follows a strict key/value naming convention where
- * the keys match the parameters listed in the route's URL. For example,
- * a URL of `/posts/:id` would require a model object like: `{ id: post }`,
- * where `post` is the object you want to pass to the new route.
- *
- * **N.B.** The below example currently won't run. It's included to show an example of using
- * the `transitionTo` function within code. In order for this to run, we will need to run
- * the code in an iframe (using something like `dgeni` instead of `grunt-ngdocs`).
- *
- * @example
- *
-
-
- angular.module('transitionToExample',
- ['ngRoute',
- 'routeExtensions'
- ])
- .config(function($routeProvider, $locationProvider) {
- $routeProvider
- .when('/post/:id',
- { name: 'post',
- template: '{{post.title}}
{{post.body}}
'
- });
-
- $locationProvider.html5Mode(true);
- $locationProvider.hashPrefix('!');
- })
- .controller('post', ['$scope', function($scope) {
-
- }])
- .controller('postForm', ['$scope', 'transitionTo', function($scope, transitionTo) {
- $scope.post = {
- id: 1,
- title: 'A post',
- body: 'Some text'
- };
-
- $scope.savePost = function() {
- transitionTo('post', { id: $scope.post });
- }
- }]);
-
-
-
-
-
-
-
- */
-
-function safeApply(fn, $rootScope) {
- var currentPhase = $rootScope.$$phase;
-
- if (currentPhase === '$apply' || currentPhase === '$digest') {
- fn();
- } else {
- $rootScope.$apply(fn);
- }
-}
-
-export default
- [ '$location',
- '$rootScope',
- '$route',
- '$q',
- function($location, $rootScope, $route, $q) {
- return function(routeName, model) {
- var deferred = $q.defer();
- var url = lookupRouteUrl(routeName, $route.routes, model, true);
-
- var offRouteChangeStart =
- $rootScope.$on('$routeChangeStart', function(e, newRoute) {
- if (newRoute.$$route.name === routeName) {
- deferred.resolve(newRoute, model);
- newRoute.params.model = model;
- }
-
- offRouteChangeStart();
- });
-
- var offRouteChangeSuccess =
- $rootScope.$on('$routeChangeSuccess', function(e, newRoute) {
- if (newRoute.$$route.name === routeName) {
- deferred.resolve(newRoute);
- }
-
- offRouteChangeSuccess();
- });
-
- var offRouteChangeError =
- $rootScope.$on('$routeChangeError', function(e, newRoute, previousRoute, rejection) {
- if (newRoute.$$route.name === routeName) {
- deferred.reject(newRoute, previousRoute, rejection);
- }
-
- offRouteChangeError();
- });
-
- safeApply(function() {
- $location.path(url);
- }, $rootScope);
-
- return deferred;
- };
- }
- ];
diff --git a/awx/ui/client/src/system-tracking/system-tracking.controller.js b/awx/ui/client/src/system-tracking/system-tracking.controller.js
index 6512342ff1..8db1b319ba 100644
--- a/awx/ui/client/src/system-tracking/system-tracking.controller.js
+++ b/awx/ui/client/src/system-tracking/system-tracking.controller.js
@@ -14,6 +14,7 @@ function controller($rootScope,
$stateParams,
$location,
$q,
+ $state,
moduleOptions,
getDataForComparison,
waitIndicator,
@@ -317,6 +318,7 @@ export default
'$stateParams',
'$location',
'$q',
+ '$state',
'moduleOptions',
'getDataForComparison',
'Wait',
diff --git a/awx/ui/client/src/system-tracking/system-tracking.route.js b/awx/ui/client/src/system-tracking/system-tracking.route.js
index e5108a8c9d..15d5ba7cde 100644
--- a/awx/ui/client/src/system-tracking/system-tracking.route.js
+++ b/awx/ui/client/src/system-tracking/system-tracking.route.js
@@ -17,9 +17,11 @@ export default {
[ 'getModuleOptions',
'lodashAsPromised',
'ProcessErrors',
- '$route',
- function(getModuleOptions, _, ProcessErrors, $route) {
- var hostIds = $route.current.params.hosts.split(',');
+ '$state',
+ '$stateParams',
+ function(getModuleOptions, _, ProcessErrors, $state, $stateParams) {
+ var hostIds = JSON.parse($stateParams.hosts);
+ // hostIds = hostIds.split(',');
var data =
getModuleOptions(hostIds[0])
@@ -37,17 +39,18 @@ export default {
}
],
inventory:
- [ '$route',
+ [ '$state',
'$q',
'Rest',
'GetBasePath',
'ProcessErrors',
- function($route, $q, rest, getBasePath, ProcessErrors) {
- if ($route.current.hasModelKey('inventory')) {
- return $q.when($route.current.params.model.inventory);
+ function($state, $q, rest, getBasePath, ProcessErrors) {
+
+ if ($state.current.hasModelKey('inventory')) {
+ return $q.when($state.current.params.model.inventory);
}
- var inventoryId = $route.current.params.inventory;
+ var inventoryId = $state.current.params.inventory;
var url = getBasePath('inventory') + inventoryId + '/';
rest.setUrl(url);
@@ -64,17 +67,17 @@ export default {
}
],
hosts:
- [ '$route',
+ [ '$state',
'$q',
'Rest',
'GetBasePath',
'ProcessErrors',
- function($route, $q, rest, getBasePath, ProcessErrors) {
- if ($route.current.hasModelKey('hosts')) {
- return $q.when($route.current.params.model.hosts);
+ function($state, $q, rest, getBasePath, ProcessErrors) {
+ if ($state.current.hasModelKey('hosts')) {
+ return $q.when($state.current.params.model.hosts);
}
- var hostIds = $route.current.params.hosts.split(',');
+ var hostIds = $state.current.params.hosts.split(',');
var hosts =
hostIds.map(function(hostId) {