mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 19:37:38 -02:30
Merge pull request #1344 from mabashian/845-jobs-list-cancel
Added cancel job logic to the jobs list
This commit is contained in:
@@ -118,6 +118,48 @@ function ListJobsController (
|
|||||||
actionText: 'DELETE'
|
actionText: 'DELETE'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vm.cancelJob = (job) => {
|
||||||
|
const action = () => {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
Wait('start');
|
||||||
|
Rest.setUrl(job.related.cancel);
|
||||||
|
Rest.post()
|
||||||
|
.then(() => {
|
||||||
|
let reloadListStateParams = null;
|
||||||
|
|
||||||
|
if ($scope.jobs.length === 1 && $state.params.job_search &&
|
||||||
|
!_.isEmpty($state.params.job_search.page) &&
|
||||||
|
$state.params.job_search.page !== '1') {
|
||||||
|
const page = `${(parseInt(reloadListStateParams
|
||||||
|
.job_search.page, 10) - 1)}`;
|
||||||
|
reloadListStateParams = _.cloneDeep($state.params);
|
||||||
|
reloadListStateParams.job_search.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
$state.go('.', reloadListStateParams, { reload: true });
|
||||||
|
})
|
||||||
|
.catch(({ data, status }) => {
|
||||||
|
ProcessErrors($scope, data, status, null, {
|
||||||
|
hdr: strings.get('error.HEADER'),
|
||||||
|
msg: strings.get('error.CALL', { path: `${job.url}`, status })
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
Wait('stop');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteModalBody = `<div class="Prompt-bodyQuery">${strings.get('cancelJob.SUBMIT_REQUEST')}</div>`;
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: strings.get('cancelJob.HEADER'),
|
||||||
|
resourceName: $filter('sanitize')(job.name),
|
||||||
|
body: deleteModalBody,
|
||||||
|
action,
|
||||||
|
actionText: strings.get('CANCEL')
|
||||||
|
});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
ListJobsController.$inject = [
|
ListJobsController.$inject = [
|
||||||
|
|||||||
@@ -71,8 +71,17 @@
|
|||||||
<at-relaunch job="job"
|
<at-relaunch job="job"
|
||||||
ng-show="job.summary_fields.user_capabilities.start">
|
ng-show="job.summary_fields.user_capabilities.start">
|
||||||
</at-relaunch>
|
</at-relaunch>
|
||||||
|
<at-row-action icon="fa-minus-circle" ng-click="vm.cancelJob(job)"
|
||||||
|
ng-show="job.summary_fields.user_capabilities.start &&
|
||||||
|
(job.status === 'pending' ||
|
||||||
|
job.status === 'waiting' ||
|
||||||
|
job.status === 'running')">
|
||||||
|
</at-row-action>
|
||||||
<at-row-action icon="fa-trash" ng-click="vm.deleteJob(job)"
|
<at-row-action icon="fa-trash" ng-click="vm.deleteJob(job)"
|
||||||
ng-show="job.summary_fields.user_capabilities.delete">
|
ng-show="job.summary_fields.user_capabilities.delete &&
|
||||||
|
!(job.status === 'pending' ||
|
||||||
|
job.status === 'waiting' ||
|
||||||
|
job.status === 'running')">
|
||||||
</at-row-action>
|
</at-row-action>
|
||||||
</div>
|
</div>
|
||||||
</at-row>
|
</at-row>
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ function BaseStringService (namespace) {
|
|||||||
CONFIRM: resourceType => t.s('Are you sure you want to delete this {{ resourceType }}?', { resourceType })
|
CONFIRM: resourceType => t.s('Are you sure you want to delete this {{ resourceType }}?', { resourceType })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.cancelJob = {
|
||||||
|
HEADER: t.s('Cancel'),
|
||||||
|
SUBMIT_REQUEST: t.s('Are you sure you want to submit the request to cancel this job?')
|
||||||
|
};
|
||||||
|
|
||||||
this.error = {
|
this.error = {
|
||||||
HEADER: t.s('Error!'),
|
HEADER: t.s('Error!'),
|
||||||
CALL: ({ path, action, status }) => t.s('Call to {{ path }} failed. {{ action }} returned status: {{ status }}.', { path, action, status }),
|
CALL: ({ path, action, status }) => t.s('Call to {{ path }} failed. {{ action }} returned status: {{ status }}.', { path, action, status }),
|
||||||
|
|||||||
Reference in New Issue
Block a user