diff --git a/awx/ui/client/src/inventories/manage/groups/groups-list.controller.js b/awx/ui/client/src/inventories/manage/groups/groups-list.controller.js index a2f843793b..cf81927116 100644 --- a/awx/ui/client/src/inventories/manage/groups/groups-list.controller.js +++ b/awx/ui/client/src/inventories/manage/groups/groups-list.controller.js @@ -5,12 +5,14 @@ *************************************************/ export default ['$scope', '$rootScope', '$state', '$stateParams', 'InventoryGroups', 'generateList', 'InventoryUpdate', 'GroupManageService', 'GroupsCancelUpdate', 'ViewUpdateStatus', - 'InventoryManageService', 'groupsUrl', 'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'Rest', 'GetBasePath', 'rbacUiControlService', + 'InventoryManageService', 'groupsUrl', 'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'Find', 'Rest', 'GetBasePath', 'rbacUiControlService', function($scope, $rootScope, $state, $stateParams, InventoryGroups, generateList, InventoryUpdate, GroupManageService, GroupsCancelUpdate, ViewUpdateStatus, - InventoryManageService, groupsUrl, SearchInit, PaginateInit, GetSyncStatusMsg, GetHostsStatusMsg, Rest, GetBasePath, rbacUiControlService){ + InventoryManageService, groupsUrl, SearchInit, PaginateInit, GetSyncStatusMsg, GetHostsStatusMsg, Find, Rest, GetBasePath, rbacUiControlService){ var list = InventoryGroups, view = generateList, pageSize = 20; + + $scope.inventory_id = $stateParams.inventory_id; $scope.canAdd = false; @@ -97,26 +99,30 @@ group_name: group.name, group_source: res.data.results[0].source })); - $scope.$emit('WatchUpdateStatus'); // init socket io conneciton and start watching for status updates - $rootScope.$on('JobStatusChange-inventory', (event, data) => { - switch(data.status){ - case 'failed' || 'successful': - $state.reload(); - break; - default: - var status = GetSyncStatusMsg({ - status: data.status, - has_inventory_sources: group.has_inventory_sources, - source: group.source - }); - group.status = data.status; - group.status_class = status.class; - group.status_tooltip = status.tooltip; - group.launch_tooltip = status.launch_tip; - group.launch_class = status.launch_class; - } - }); }; + + if ($rootScope.inventoryManageStatus) { + $rootScope.inventoryManageStatus(); + } + $rootScope.inventoryManageStatus = $rootScope.$on('JobStatusChange-inventory', function(e, data){ + var group = Find({ list: $scope.groups, key: 'id', val: data.group_id }); + if(data.status === 'failed' || data.status === 'successful'){ + $state.reload(); + } + else{ + var status = GetSyncStatusMsg({ + status: data.status, + has_inventory_sources: group.has_inventory_sources, + source: group.source + }); + group.status = data.status; + group.status_class = status.class; + group.status_tooltip = status.tooltip; + group.launch_tooltip = status.launch_tip; + group.launch_class = status.launch_class; + } + }); + $scope.cancelUpdate = function (id) { GroupsCancelUpdate({ scope: $scope, id: id }); }; diff --git a/awx/ui/client/src/login/loginModal/loginModal.controller.js b/awx/ui/client/src/login/loginModal/loginModal.controller.js index 020c64b1ca..69d509925f 100644 --- a/awx/ui/client/src/login/loginModal/loginModal.controller.js +++ b/awx/ui/client/src/login/loginModal/loginModal.controller.js @@ -136,7 +136,6 @@ export default ['$log', '$cookieStore', '$compile', '$window', '$rootScope', Authorization.setUserInfo(data); Timer.init().then(function(timer){ $rootScope.sessionTimer = timer; - // $rootScope.$emit('OpenSocket'); SocketService.init(); $rootScope.user_is_superuser = data.results[0].is_superuser; $rootScope.user_is_system_auditor = data.results[0].is_system_auditor; diff --git a/awx/ui/client/src/shared/socket/socket.service.js b/awx/ui/client/src/shared/socket/socket.service.js index efa4d0bbee..75b3281c2e 100644 --- a/awx/ui/client/src/shared/socket/socket.service.js +++ b/awx/ui/client/src/shared/socket/socket.service.js @@ -62,8 +62,9 @@ export default $rootScope.$emit('JobStatusChange-portal', data); } else if ($state.is('projects')) { $rootScope.$emit('JobStatusChange-projects', data); - } else if ($state.is('inventoryManage')) { - $rootScope.$emit('JobStatusChange-inventory', data); + } else if ($state.is('inventoryManage') || + $state.includes('inventoryManage')) { + $rootScope.$emit('JobStatusChange-inventory', data); } } if(data.group_name==="job_events"){ @@ -98,7 +99,7 @@ export default $log.debug('socket status: ' + $rootScope.socketStatus); }, 2000); }, - subscribe2: function(state){ + subscribe: function(state){ console.log(state.name); this.emit(JSON.stringify(state.socket)); }, @@ -137,11 +138,11 @@ export default } }, - emit: function (eventName, data, callback) { + emit: function(data, callback) { var self = this; $log.debug('Sent to Server: ' + data); $rootScope.socketPromise.promise.then(function(){ - self.socket.send(eventName, data, function () { + self.socket.send(data, function () { var args = arguments; self.scope.$apply(function () { if (callback) { diff --git a/awx/ui/client/src/shared/stateExtender.provider.js b/awx/ui/client/src/shared/stateExtender.provider.js index 320853876c..d58c530a4c 100644 --- a/awx/ui/client/src/shared/stateExtender.provider.js +++ b/awx/ui/client/src/shared/stateExtender.provider.js @@ -15,7 +15,7 @@ export default function($stateProvider) { if(state.socket.groups.hasOwnProperty( "ad_hoc_command_events")){ state.socket.groups.job_events = [$stateParams.id]; } - SocketService.subscribe2(state); + SocketService.subscribe(state); return true; }); }];