mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Fixing live events for inventory-manage page
This commit is contained in:
parent
0fb4a1a62a
commit
947571fe26
@ -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 });
|
||||
};
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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;
|
||||
});
|
||||
}];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user