mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
Update relaunch button on details page in real time as status changes
This commit is contained in:
parent
05556809d3
commit
5ef297aec1
@ -556,7 +556,7 @@ function AtJobDetailsController (
|
||||
vm.labels = getLabelDetails();
|
||||
|
||||
// Relaunch and Delete Components
|
||||
vm.job = _.get(resource.model, 'model.GET', {});
|
||||
vm.job = angular.copy(_.get(resource.model, 'model.GET', {}));
|
||||
vm.canDelete = resource.model.get('summary_fields.user_capabilities.delete');
|
||||
|
||||
vm.cancelJob = cancelJob;
|
||||
@ -568,10 +568,14 @@ function AtJobDetailsController (
|
||||
};
|
||||
|
||||
observe(status.getStarted, getStartDetails, 'started');
|
||||
observe(status.getJobStatus, getStatusDetails, 'status');
|
||||
observe(status.getFinished, getFinishDetails, 'finished');
|
||||
observe(status.getProjectUpdateId, getProjectUpdateDetails, 'projectUpdate');
|
||||
observe(status.getProjectStatus, getProjectStatusDetails, 'projectStatus');
|
||||
|
||||
$scope.$watch(status.getJobStatus, jobStatus => {
|
||||
vm.status = getStatusDetails(jobStatus);
|
||||
vm.job.status = jobStatus;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,14 @@ function atRelaunchCtrl (
|
||||
const jobObj = new Job();
|
||||
const jobTemplate = new JobTemplate();
|
||||
|
||||
const updateTooltip = () => {
|
||||
if (vm.job.type === 'job' && vm.job.status === 'failed') {
|
||||
vm.tooltip = strings.get('relaunch.HOSTS');
|
||||
} else {
|
||||
vm.tooltip = strings.get('relaunch.DEFAULT');
|
||||
}
|
||||
};
|
||||
|
||||
const checkRelaunchPlaybook = (option) => {
|
||||
jobObj.getRelaunch({
|
||||
id: vm.job.id
|
||||
@ -113,7 +121,7 @@ function atRelaunchCtrl (
|
||||
|
||||
jobObj.postRelaunch(launchParams)
|
||||
.then((launchRes) => {
|
||||
if (!$state.includes('jobs')) {
|
||||
if (!$state.is('jobs')) {
|
||||
const relaunchType = launchRes.data.type === 'job' ? 'playbook' : launchRes.data.type;
|
||||
$state.go('jobz', { id: launchRes.data.id, type: relaunchType }, { reload: true });
|
||||
}
|
||||
@ -129,13 +137,7 @@ function atRelaunchCtrl (
|
||||
|
||||
vm.$onInit = () => {
|
||||
vm.showRelaunch = vm.job.type !== 'system_job' && vm.job.summary_fields.user_capabilities.start;
|
||||
vm.showDropdown = vm.job.type === 'job' && vm.job.status === 'failed';
|
||||
|
||||
vm.createDropdown();
|
||||
vm.createTooltips();
|
||||
};
|
||||
|
||||
vm.createDropdown = () => {
|
||||
vm.icon = 'icon-launch';
|
||||
vm.dropdownTitle = strings.get('relaunch.DROPDOWN_TITLE');
|
||||
vm.dropdownOptions = [
|
||||
@ -148,14 +150,12 @@ function atRelaunchCtrl (
|
||||
icon: 'icon-host-failed'
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
vm.createTooltips = () => {
|
||||
if (vm.showDropdown) {
|
||||
vm.tooltip = strings.get('relaunch.HOSTS');
|
||||
} else {
|
||||
vm.tooltip = strings.get('relaunch.DEFAULT');
|
||||
}
|
||||
updateTooltip();
|
||||
|
||||
$scope.$watch('vm.job.status', () => {
|
||||
updateTooltip();
|
||||
});
|
||||
};
|
||||
|
||||
vm.relaunchJob = () => {
|
||||
@ -167,7 +167,7 @@ function atRelaunchCtrl (
|
||||
if (getUpdateRes.data.can_update) {
|
||||
inventorySource.postUpdate(vm.job.inventory_source)
|
||||
.then((postUpdateRes) => {
|
||||
if (!$state.includes('jobs')) {
|
||||
if (!$state.is('jobs')) {
|
||||
$state.go('jobz', { id: postUpdateRes.data.id, type: 'inventory' }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status, config }) => {
|
||||
@ -191,7 +191,7 @@ function atRelaunchCtrl (
|
||||
if (getUpdateRes.data.can_update) {
|
||||
project.postUpdate(vm.job.project)
|
||||
.then((postUpdateRes) => {
|
||||
if (!$state.includes('jobs')) {
|
||||
if (!$state.is('jobs')) {
|
||||
$state.go('jobz', { id: postUpdateRes.data.id, type: 'project' }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status, config }) => {
|
||||
@ -213,7 +213,7 @@ function atRelaunchCtrl (
|
||||
workflowJob.postRelaunch({
|
||||
id: vm.job.id
|
||||
}).then((launchRes) => {
|
||||
if (!$state.includes('jobs')) {
|
||||
if (!$state.is('jobs')) {
|
||||
$state.go('workflowResults', { id: launchRes.data.id }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status, config }) => {
|
||||
@ -237,7 +237,7 @@ function atRelaunchCtrl (
|
||||
adHocCommand.postRelaunch({
|
||||
id: vm.job.id
|
||||
}).then((launchRes) => {
|
||||
if (!$state.includes('jobs')) {
|
||||
if (!$state.is('jobs')) {
|
||||
$state.go('jobz', { id: launchRes.data.id, type: 'command' }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status, config }) => {
|
||||
@ -262,7 +262,7 @@ function atRelaunchCtrl (
|
||||
id: vm.promptData.job,
|
||||
relaunchData: PromptService.bundlePromptDataForRelaunch(vm.promptData)
|
||||
}).then((launchRes) => {
|
||||
if (!$state.includes('jobs')) {
|
||||
if (!$state.is('jobs')) {
|
||||
$state.go('jobz', { id: launchRes.data.job, type: 'playbook' }, { reload: true });
|
||||
}
|
||||
}).catch(({ data, status }) => {
|
||||
|
@ -1,9 +1,10 @@
|
||||
<div ng-if="vm.showRelaunch"
|
||||
class="at-Relaunch"
|
||||
aw-tool-tip="{{ vm.tooltip }}"
|
||||
data-tip-watch="vm.tooltip"
|
||||
data-placement="top">
|
||||
|
||||
<div class="btn-group" role="group" ng-if="vm.showDropdown">
|
||||
<div class="btn-group" role="group" ng-if="vm.job.type === 'job' && vm.job.status === 'failed'">
|
||||
<button class="at-Relaunch--button"
|
||||
data-toggle="dropdown"
|
||||
aria-expanded="false"
|
||||
@ -27,7 +28,7 @@
|
||||
|
||||
<button class="at-Relaunch--button"
|
||||
ng-click="vm.relaunchJob()"
|
||||
ng-if="!vm.showDropdown">
|
||||
ng-if="!(vm.job.type === 'job' && vm.job.status === 'failed')">
|
||||
<i class="{{ vm.icon }}"></i>
|
||||
</button>
|
||||
<prompt prompt-data="vm.promptData" on-finish="vm.relaunchJobWithPassword()"></prompt>
|
||||
|
Loading…
Reference in New Issue
Block a user