mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
AC-1123 fixed issues related to job submission and cancellation.
This commit is contained in:
@@ -124,7 +124,7 @@ Home.$inject = ['$scope', '$compile', '$routeParams', '$rootScope', '$location',
|
|||||||
|
|
||||||
function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewer, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewer, HomeGroupList, GenerateList, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||||
GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream, GroupsEdit, Wait,
|
GetBasePath, SearchInit, PaginateInit, FormatDate, GetHostsStatusMsg, GetSyncStatusMsg, ViewUpdateStatus, Stream, GroupsEdit, Wait,
|
||||||
Alert, Rest, Empty, InventoryUpdate, Find) {
|
Alert, Rest, Empty, InventoryUpdate, Find, GroupsCancelUpdate) {
|
||||||
|
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -347,7 +347,7 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
|
|||||||
};
|
};
|
||||||
|
|
||||||
scope.refresh = function () {
|
scope.refresh = function () {
|
||||||
scope.search(list.iterator, null, false, true);
|
scope.search(list.iterator);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -426,7 +426,7 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
|
|||||||
if (!Empty(id)) {
|
if (!Empty(id)) {
|
||||||
group = Find({ list: scope.home_groups, key: 'id', val: id });
|
group = Find({ list: scope.home_groups, key: 'id', val: id });
|
||||||
status = group.summary_fields.inventory_source.status;
|
status = group.summary_fields.inventory_source.status;
|
||||||
if (status === 'failed' || status === 'error' || status === 'successful') {
|
if (status === 'running' || status === 'failed' || status === 'error' || status === 'successful') {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(group.related.inventory_sources + '?or__source=ec2&or__source=rax&order_by=-last_job_run&page_size=5');
|
Rest.setUrl(group.related.inventory_sources + '?or__source=ec2&or__source=rax&order_by=-last_job_run&page_size=5');
|
||||||
Rest.get()
|
Rest.get()
|
||||||
@@ -479,17 +479,22 @@ function HomeGroups($scope, $filter, $compile, $location, $routeParams, LogViewe
|
|||||||
|
|
||||||
scope.viewJob = function(url) {
|
scope.viewJob = function(url) {
|
||||||
LogViewer({
|
LogViewer({
|
||||||
scope: scope,
|
scope: modal_scope,
|
||||||
url: url
|
url: url
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scope.cancelUpdate = function(id) {
|
||||||
|
var group = Find({ list: scope.home_groups, key: 'id', val: id });
|
||||||
|
GroupsCancelUpdate({ scope: scope, group: group });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HomeGroups.$inject = ['$scope', '$filter', '$compile', '$location', '$routeParams', 'LogViewer', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
HomeGroups.$inject = ['$scope', '$filter', '$compile', '$location', '$routeParams', 'LogViewer', 'HomeGroupList', 'GenerateList', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller',
|
||||||
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus',
|
'ClearScope', 'GetBasePath', 'SearchInit', 'PaginateInit', 'FormatDate', 'GetHostsStatusMsg', 'GetSyncStatusMsg', 'ViewUpdateStatus',
|
||||||
'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find'
|
'Stream', 'GroupsEdit', 'Wait', 'Alert', 'Rest', 'Empty', 'InventoryUpdate', 'Find', 'GroupsCancelUpdate'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -687,7 +687,7 @@ function InventoriesEdit($scope, $location, $routeParams, $compile, GenerateList
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.cancelUpdate = function (tree_id) {
|
$scope.cancelUpdate = function (tree_id) {
|
||||||
GroupsCancelUpdate({ scope: $scope, tree_id: tree_id });
|
GroupsCancelUpdate({ scope: $scope, id: tree_id });
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.toggle = function (tree_id) {
|
$scope.toggle = function (tree_id) {
|
||||||
|
|||||||
@@ -251,13 +251,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
|
|
||||||
|
|
||||||
// Cancel a pending or running inventory sync
|
// Cancel a pending or running inventory sync
|
||||||
.factory('GroupsCancelUpdate', ['Rest', 'ProcessErrors', 'Alert', 'Wait', 'Find',
|
.factory('GroupsCancelUpdate', ['Empty', 'Rest', 'ProcessErrors', 'Alert', 'Wait', 'Find',
|
||||||
function (Rest, ProcessErrors, Alert, Wait, Find) {
|
function (Empty, Rest, ProcessErrors, Alert, Wait, Find) {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
|
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
id = params.tree_id,
|
id = params.id,
|
||||||
group;
|
group = params.group;
|
||||||
|
|
||||||
if (scope.removeCancelUpdate) {
|
if (scope.removeCancelUpdate) {
|
||||||
scope.removeCancelUpdate();
|
scope.removeCancelUpdate();
|
||||||
@@ -268,7 +268,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
Rest.post()
|
Rest.post()
|
||||||
.success(function () {
|
.success(function () {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
Alert('Inventory Sync Cancelled', 'Your request to cancel the sync process was submitted to the task manger. ' +
|
Alert('Inventory Sync Cancelled', 'Request to cancel the sync process was submitted to the task manger. ' +
|
||||||
'Click the <i class="fa fa-refresh fa-lg"></i> button to monitor the status.', 'alert-info');
|
'Click the <i class="fa fa-refresh fa-lg"></i> button to monitor the status.', 'alert-info');
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
@@ -294,8 +294,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
scope.$emit('CancelUpdate', url);
|
scope.$emit('CancelUpdate', url);
|
||||||
} else {
|
} else {
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
Alert('Cancel Inventory Sync', 'Either you do not have access or the sync process completed.<br /> ' +
|
Alert('Cancel Inventory Sync', 'The sync process completed. Click the <i class="fa fa-refresh fa-lg"></i> button to view ' +
|
||||||
'Click the <i class="fa fa-refresh fa-lg"></i> button to view the latest status.', 'alert-info');
|
'the latest status.', 'alert-info');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
@@ -308,11 +308,13 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Cancel the update process
|
// Cancel the update process
|
||||||
group = Find({ list: scope.groups, key: 'id', val: id });
|
if (Empty(group)) {
|
||||||
scope.selected_tree_id = group.id;
|
group = Find({ list: scope.groups, key: 'id', val: id });
|
||||||
scope.selected_group_id = group.group_id;
|
scope.selected_tree_id = group.id;
|
||||||
|
scope.selected_group_id = group.group_id;
|
||||||
|
}
|
||||||
|
|
||||||
if (group && (group.status === 'updating' || group.status === 'pending')) {
|
if (group && (group.status === 'running' || group.status === 'pending')) {
|
||||||
// We found the group, and there is a running update
|
// We found the group, and there is a running update
|
||||||
Wait('start');
|
Wait('start');
|
||||||
Rest.setUrl(group.related.inventory_source);
|
Rest.setUrl(group.related.inventory_source);
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
scope.removePlaybookLaunchFinished = scope.$on('PlaybookLaunchFinished', function() {
|
scope.removePlaybookLaunchFinished = scope.$on('PlaybookLaunchFinished', function() {
|
||||||
var base = $location.path().replace(/^\//, '').split('/')[0];
|
var base = $location.path().replace(/^\//, '').split('/')[0];
|
||||||
if (base === 'jobs') {
|
if (base === 'jobs') {
|
||||||
scope.refresh();
|
scope.refreshJobs();
|
||||||
} else {
|
} else {
|
||||||
$location.path('/jobs');
|
$location.path('/jobs');
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
// Sumbit SCM Update request
|
// Submit SCM Update request
|
||||||
.factory('ProjectUpdate', ['PromptForPasswords', 'LaunchJob', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert',
|
.factory('ProjectUpdate', ['PromptForPasswords', 'LaunchJob', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert',
|
||||||
'ProjectsForm', 'Wait',
|
'ProjectsForm', 'Wait',
|
||||||
function (PromptForPasswords, LaunchJob, Rest, $location, GetBasePath, ProcessErrors, Alert, ProjectsForm, Wait) {
|
function (PromptForPasswords, LaunchJob, Rest, $location, GetBasePath, ProcessErrors, Alert, ProjectsForm, Wait) {
|
||||||
@@ -357,6 +357,7 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
url = params.url,
|
url = params.url,
|
||||||
group_id = params.group_id,
|
group_id = params.group_id,
|
||||||
tree_id = params.tree_id,
|
tree_id = params.tree_id,
|
||||||
|
base = $location.path().replace(/^\//, '').split('/')[0],
|
||||||
inventory_source;
|
inventory_source;
|
||||||
|
|
||||||
if (scope.removeHostReloadComplete) {
|
if (scope.removeHostReloadComplete) {
|
||||||
@@ -376,7 +377,10 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
}
|
}
|
||||||
scope.removeUpdateSubmitted = scope.$on('UpdateSubmitted', function () {
|
scope.removeUpdateSubmitted = scope.$on('UpdateSubmitted', function () {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (scope.refreshGroups) {
|
if (base === 'jobs') {
|
||||||
|
scope.refreshJobs();
|
||||||
|
}
|
||||||
|
else if (scope.refreshGroups) {
|
||||||
scope.selected_tree_id = tree_id;
|
scope.selected_tree_id = tree_id;
|
||||||
scope.selected_group_id = group_id;
|
scope.selected_group_id = group_id;
|
||||||
scope.refreshGroups();
|
scope.refreshGroups();
|
||||||
@@ -384,7 +388,7 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
scope.refresh();
|
scope.refresh();
|
||||||
}
|
}
|
||||||
scope.$emit('HostReloadComplete');
|
scope.$emit('HostReloadComplete');
|
||||||
}, 2000);
|
}, 300);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (scope.removePromptForPasswords) {
|
if (scope.removePromptForPasswords) {
|
||||||
|
|||||||
@@ -384,8 +384,8 @@ angular.module('JobsHelper', ['Utilities', 'RestServices', 'FormGenerator', 'Job
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('DeleteJob', ['Find', 'GetBasePath', 'Rest', 'Wait', 'ProcessErrors', 'Prompt',
|
.factory('DeleteJob', ['Find', 'GetBasePath', 'Rest', 'Wait', 'ProcessErrors', 'Prompt', 'Alert',
|
||||||
function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt){
|
function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt, Alert){
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
@@ -441,12 +441,45 @@ function(Find, GetBasePath, Rest, Wait, ProcessErrors, Prompt){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Prompt({
|
if (scope.removeCancelNotAllowed) {
|
||||||
hdr: hdr,
|
scope.removeCancelNotAllowed();
|
||||||
body: "<div class=\"alert alert-info\">Are you sure you want to " + action_label + " job " + id + " <em>" + job.name + "</em>?</div>",
|
}
|
||||||
action: action
|
scope.removeCancelNotAllowed = scope.$on('CancelNotAllowed', function() {
|
||||||
|
Alert('Job Completed', 'The job completed. Click the <i class="fa fa-refresh fa-lg"></i> button to view ' +
|
||||||
|
'the latest status.', 'alert-info');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (scope.removeCancelJob) {
|
||||||
|
scope.removeCancelJob();
|
||||||
|
}
|
||||||
|
scope.removeCancelJob = scope.$on('CancelJob', function() {
|
||||||
|
Prompt({
|
||||||
|
hdr: hdr,
|
||||||
|
body: "<div class=\"alert alert-info\">Submit the request to " + action_label + " job #" + id + " " + job.name + "?</div>",
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (action_label === 'cancel') {
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.get()
|
||||||
|
.success(function(data) {
|
||||||
|
if (data.can_cancel) {
|
||||||
|
scope.$emit('CancelJob');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope.$emit('CancelNotAllowed');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error(function(data, status) {
|
||||||
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url +
|
||||||
|
' failed. GET returned: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope.$emit('CancelJob');
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ angular.module('LogViewerHelper', ['ModalDialog', 'Utilities', 'FormGenerator',
|
|||||||
callback: 'ModalReady',
|
callback: 'ModalReady',
|
||||||
id: 'logviewer-modal-dialog',
|
id: 'logviewer-modal-dialog',
|
||||||
onResizeStop: resizeText,
|
onResizeStop: resizeText,
|
||||||
|
title: 'Job Results',
|
||||||
onOpen: function() {
|
onOpen: function() {
|
||||||
$('#logview-tabs a:first').tab('show');
|
$('#logview-tabs a:first').tab('show');
|
||||||
$('#dialog-ok-button').focus();
|
$('#dialog-ok-button').focus();
|
||||||
|
|||||||
@@ -89,18 +89,20 @@ angular.module('ModalDialog', ['Utilities', 'ParseHelper'])
|
|||||||
// Fix the close button
|
// Fix the close button
|
||||||
$('.ui-dialog[aria-describedby="' + id + '"]').find('.ui-dialog-titlebar button').empty().attr({'class': 'close'}).text('x');
|
$('.ui-dialog[aria-describedby="' + id + '"]').find('.ui-dialog-titlebar button').empty().attr({'class': 'close'}).text('x');
|
||||||
|
|
||||||
// Make buttons bootstrapy
|
setTimeout(function() {
|
||||||
$('.ui-dialog[aria-describedby="' + id + '"]').find('.ui-dialog-buttonset button').each(function () {
|
// Make buttons bootstrapy
|
||||||
var txt = $(this).text(), self = $(this);
|
$('.ui-dialog[aria-describedby="' + id + '"]').find('.ui-dialog-buttonset button').each(function () {
|
||||||
buttonSet.forEach(function(btn) {
|
var txt = $(this).text(), self = $(this);
|
||||||
if (txt === btn.label) {
|
buttonSet.forEach(function(btn) {
|
||||||
self.attr({ "class": btn['class'], "id": btn.id });
|
if (txt === btn.label) {
|
||||||
if (btn.icon) {
|
self.attr({ "class": btn['class'], "id": btn.id });
|
||||||
self.empty().html('<i class="fa ' + btn.icon + '"></i> ' + btn.label);
|
if (btn.icon) {
|
||||||
|
self.empty().html('<i class="fa ' + btn.icon + '"></i> ' + btn.label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
});
|
}, 300);
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
scope.$apply(function() {
|
scope.$apply(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user