mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 00:57:48 -02:30
Removes GET requests in response to websocket messages on the org job templates list. List is solely updated based on data from the websocket messages.
This commit is contained in:
@@ -4,25 +4,41 @@
|
|||||||
* All Rights Reserved
|
* All Rights Reserved
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
export default ['$scope', '$rootScope',
|
export default ['$scope', '$stateParams', 'Rest', 'GetBasePath', '$state', 'OrgJobTemplateList', 'OrgJobTemplateDataset',
|
||||||
'$stateParams', 'Rest', 'ProcessErrors',
|
function($scope, $stateParams, Rest, GetBasePath, $state, OrgJobTemplateList, Dataset) {
|
||||||
'GetBasePath', 'Wait',
|
|
||||||
'$state', 'OrgJobTemplateList', 'OrgJobTemplateDataset', 'QuerySet',
|
|
||||||
function($scope, $rootScope,
|
|
||||||
$stateParams, Rest, ProcessErrors,
|
|
||||||
GetBasePath, Wait,
|
|
||||||
$state, OrgJobTemplateList, Dataset, qs) {
|
|
||||||
|
|
||||||
var list = OrgJobTemplateList,
|
var list = OrgJobTemplateList,
|
||||||
orgBase = GetBasePath('organizations');
|
orgBase = GetBasePath('organizations');
|
||||||
|
|
||||||
$scope.$on(`ws-jobs`, function () {
|
$scope.$on(`ws-jobs`, function (e, msg) {
|
||||||
let path = GetBasePath(list.basePath) || GetBasePath(list.name);
|
if (msg.unified_job_template_id && $scope[list.name]) {
|
||||||
qs.search(path, $state.params[`${list.iterator}_search`])
|
const template = $scope[list.name].find((t) => t.id === msg.unified_job_template_id);
|
||||||
.then(function(searchResponse) {
|
if (template) {
|
||||||
$scope[`${list.iterator}_dataset`] = searchResponse.data;
|
if (msg.status === 'pending') {
|
||||||
$scope[list.name] = $scope[`${list.iterator}_dataset`].results;
|
// This is a new job - add it to the front of the
|
||||||
|
// recent_jobs array
|
||||||
|
if (template.summary_fields.recent_jobs.length === 10) {
|
||||||
|
template.summary_fields.recent_jobs.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
template.summary_fields.recent_jobs.unshift({
|
||||||
|
id: msg.unified_job_id,
|
||||||
|
status: msg.status,
|
||||||
|
type: msg.type
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// This is an update to an existing job. Check to see
|
||||||
|
// if we have it in our array of recent_jobs
|
||||||
|
for (let i=0; i<template.summary_fields.recent_jobs.length; i++) {
|
||||||
|
const recentJob = template.summary_fields.recent_jobs[i];
|
||||||
|
if (recentJob.id === msg.unified_job_id) {
|
||||||
|
recentJob.status = msg.status;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
Reference in New Issue
Block a user