From 87b0a9ababc538d0207f9e1775674852baf5e263 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Tue, 5 Jan 2016 13:53:28 -0500 Subject: [PATCH] fixing system tracking route --- awx/ui/client/src/controllers/Inventories.js | 13 ++++---- .../src/shared/stateExtender.provider.js | 1 + .../system-tracking.controller.js | 9 ++++-- .../system-tracking/system-tracking.route.js | 30 +++++++++---------- 4 files changed, 30 insertions(+), 23 deletions(-) diff --git a/awx/ui/client/src/controllers/Inventories.js b/awx/ui/client/src/controllers/Inventories.js index c1171da9ce..a5f6d1861a 100644 --- a/awx/ui/client/src/controllers/Inventories.js +++ b/awx/ui/client/src/controllers/Inventories.js @@ -843,11 +843,14 @@ export function InventoriesManage ($log, $scope, $rootScope, $location, }); $scope.systemTracking = function() { - $scope.inventory = JSON.stringify($scope.inventory); - $scope.hostsSelectedItems = JSON.stringify($scope.hostsSelectedItems); - $state.go('systemTracking', + var hostIds = _.map($scope.hostsSelectedItems, function(x){ + return x.id; + }); + $state.transitionTo('systemTracking', { inventory: $scope.inventory, - hosts: $scope.hostsSelectedItems + inventoryId: $scope.inventory.id, + hosts: $scope.hostsSelectedItems, + hostIds: hostIds }); }; @@ -922,7 +925,7 @@ export function InventoriesManage ($log, $scope, $rootScope, $location, $scope.removeInventoryLoaded(); } $scope.removeInventoryLoaded = $scope.$on('InventoryLoaded', function() { - var e, rows; + var rows; // Add groups view generateList.inject(InventoryGroups, { diff --git a/awx/ui/client/src/shared/stateExtender.provider.js b/awx/ui/client/src/shared/stateExtender.provider.js index 87cea8965a..6499418993 100644 --- a/awx/ui/client/src/shared/stateExtender.provider.js +++ b/awx/ui/client/src/shared/stateExtender.provider.js @@ -8,6 +8,7 @@ export default function($stateProvider){ controller: state.controller, templateUrl: state.templateUrl, resolve: state.resolve, + params: state.params, ncyBreadcrumb: state.ncyBreadcrumb }); } 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 8db1b319ba..2df9b46941 100644 --- a/awx/ui/client/src/system-tracking/system-tracking.controller.js +++ b/awx/ui/client/src/system-tracking/system-tracking.controller.js @@ -16,20 +16,21 @@ function controller($rootScope, $q, $state, moduleOptions, + inventory, + hosts, getDataForComparison, waitIndicator, moment, _) { // var inventoryId = $stateParams.id; - var hostIds = $stateParams.hosts.split(','); - var hosts = $stateParams.model.hosts; + var hostIds = $stateParams.hostIds.split(','); var moduleParam = $stateParams.module || 'packages'; $scope.compareMode = hostIds.length === 1 ? 'single-host' : 'host-to-host'; $scope.hostIds = $stateParams.hosts; - $scope.inventory = $stateParams.model.inventory; + $scope.inventory = inventory; $scope.noModuleData = false; // this means no scans have been run @@ -320,6 +321,8 @@ export default '$q', '$state', 'moduleOptions', + 'inventory', + 'hosts', 'getDataForComparison', 'Wait', 'moment', 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 15d5ba7cde..0149587769 100644 --- a/awx/ui/client/src/system-tracking/system-tracking.route.js +++ b/awx/ui/client/src/system-tracking/system-tracking.route.js @@ -8,20 +8,20 @@ import {templateUrl} from '../shared/template-url/template-url.factory'; export default { name: 'systemTracking', - route: '/inventories/:inventory/system-tracking/:hosts', + route: '/inventories/:inventoryId/system-tracking/:hostIds', controller: 'systemTracking', templateUrl: templateUrl('system-tracking/system-tracking'), + params: {hosts: null, inventory: null}, reloadOnSearch: false, resolve: { moduleOptions: [ 'getModuleOptions', 'lodashAsPromised', 'ProcessErrors', - '$state', '$stateParams', - function(getModuleOptions, _, ProcessErrors, $state, $stateParams) { - var hostIds = JSON.parse($stateParams.hosts); - // hostIds = hostIds.split(','); + function(getModuleOptions, _, ProcessErrors, $stateParams) { + + var hostIds = $stateParams.hostIds.split(','); var data = getModuleOptions(hostIds[0]) @@ -39,18 +39,18 @@ export default { } ], inventory: - [ '$state', + [ '$stateParams', '$q', 'Rest', 'GetBasePath', 'ProcessErrors', - function($state, $q, rest, getBasePath, ProcessErrors) { + function($stateParams, $q, rest, getBasePath, ProcessErrors) { - if ($state.current.hasModelKey('inventory')) { - return $q.when($state.current.params.model.inventory); + if ($stateParams.inventory) { + return $q.when($stateParams.inventory); } - var inventoryId = $state.current.params.inventory; + var inventoryId = $stateParams.inventoryId; var url = getBasePath('inventory') + inventoryId + '/'; rest.setUrl(url); @@ -67,17 +67,17 @@ export default { } ], hosts: - [ '$state', + [ '$stateParams', '$q', 'Rest', 'GetBasePath', 'ProcessErrors', - function($state, $q, rest, getBasePath, ProcessErrors) { - if ($state.current.hasModelKey('hosts')) { - return $q.when($state.current.params.model.hosts); + function($stateParams, $q, rest, getBasePath, ProcessErrors) { + if ($stateParams.hosts) { + return $q.when($stateParams.hosts); } - var hostIds = $state.current.params.hosts.split(','); + var hostIds = $stateParams.hostIds.split(','); var hosts = hostIds.map(function(hostId) {