diff --git a/awx/ui/static/js/controllers/Projects.js b/awx/ui/static/js/controllers/Projects.js
index fa1979f614..27bbac4ed4 100644
--- a/awx/ui/static/js/controllers/Projects.js
+++ b/awx/ui/static/js/controllers/Projects.js
@@ -162,7 +162,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
scope.$emit('Cancel_Update', url);
}
else {
- Alert('Cancel Not Allowed', 'Either you do not have access or the SCM update process completed. Use the Refresh button to' +
+ Alert('Cancel Not Allowed', 'Either you do not have access or the SCM update process completed. Click the Refresh button to' +
' view the latest status.', 'alert-info');
}
})
@@ -173,12 +173,12 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
});
scope.cancelUpdate = function(id, name) {
- // Start the update process
+ // Start the cancel process
var project;
var found = false;
- for (var i=0; i < projects.length; i++) {
- if (projects[i].id == id) {
- project = projects[i];
+ for (var i=0; i < scope.projects.length; i++) {
+ if (scope.projects[i].id == id) {
+ project = scope.projects[i];
found = true;
break;
}
@@ -195,7 +195,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
});
}
else {
- Alert('Update Not Found', 'An SCM Update does not appear to be running for project ' + name + '. Click the Refresh ' +
+ Alert('Update Not Found', 'An SCM update does not appear to be running for project: ' + name + '. Click the Refresh ' +
'button to view the latet status.', 'alert-info');
}
}
diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js
index 4f2f6d52a3..2555f8f5ab 100644
--- a/awx/ui/static/js/helpers/Groups.js
+++ b/awx/ui/static/js/helpers/Groups.js
@@ -314,6 +314,74 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
$('#tree-view').jstree('select_node', node);
}
+ if (scope.removeCancelUpdate) {
+ scope.removeCancelUpdate();
+ }
+ scope.removeCancelUpdate = scope.$on('Cancel_Update', function(e, url) {
+ // Cancel the project update process
+ Rest.setUrl(url)
+ Rest.post()
+ .success( function(data, status, headers, config) {
+ Alert('SCM Update Cancel', 'Your request to cancel the update was submitted to the task maanger.', 'alert-info');
+ scope.refresh();
+ })
+ .error( function(data, status, headers, config) {
+ ProcessErrors(scope, data, status, null,
+ { hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST status: ' + status });
+ });
+ });
+
+ if (scope.removeCheckCancel) {
+ scope.removeCheckCancel();
+ }
+ scope.removeCheckCancel = scope.$on('Check_Cancel', function(e, data) {
+ // Check that we 'can' cancel the update
+ var url = data.related.cancel;
+ Rest.setUrl(url);
+ Rest.get()
+ .success( function(data, status, headers, config) {
+ if (data.can_cancel) {
+ scope.$emit('Cancel_Update', url);
+ }
+ else {
+ Alert('Cancel Not Allowed', 'Either you do not have access or the Inventory update process completed. Click the Refresh button to' +
+ ' view the latest status.', 'alert-info');
+ }
+ })
+ .error( function(data, status, headers, config) {
+ ProcessErrors(scope, data, status, null,
+ { hdr: 'Error!', msg: 'Call to ' + url + ' failed. GET status: ' + status });
+ });
+ });
+
+ scope.cancelUpdate = function(id, name) {
+ // Cancel the update process
+ var group;
+ var found = false;
+ for (var i=0; i < scope.groups.length; i++) {
+ if (scope.groups[i].id == id) {
+ group = scope.groups[i];
+ found = true;
+ break;
+ }
+ }
+ if (found && group.related.current_update) {
+ Rest.setUrl(group.related.current_update);
+ Rest.get()
+ .success( function(data, status, headers, config) {
+ scope.$emit('Check_Cancel', data);
+ })
+ .error( function(data, status, headers, config) {
+ ProcessErrors(scope, data, status, null,
+ { hdr: 'Error!', msg: 'Call to ' + group.related.current_update + ' failed. GET status: ' + status });
+ });
+ }
+ else {
+ Alert('Update Not Found', 'An Inventory update does not appear to be running for group: ' + name + '. Click the Refresh ' +
+ 'button to view the latet status.', 'alert-info');
+ }
+ }
+
// Respond to refresh button
scope.refresh = function() {
scope['groupSearchSpin'] = true;
diff --git a/awx/ui/static/js/lists/InventorySummary.js b/awx/ui/static/js/lists/InventorySummary.js
index 0e56255aa0..374245cd91 100644
--- a/awx/ui/static/js/lists/InventorySummary.js
+++ b/awx/ui/static/js/lists/InventorySummary.js
@@ -139,6 +139,13 @@ angular.module('InventorySummaryDefinition', [])
"class": 'btn-xs btn-success',
ngClick: 'updateGroup(\{\{ group.id \}\})',
awToolTip: 'Perform an update on this group'
+ },
+ cancel: {
+ label: 'Cancel',
+ icon: 'icon-minus-sign',
+ ngClick: "cancelUpdate(\{\{ group.id \}\}, '\{\{ group.name \}\}')",
+ "class": 'btn-danger btn-xs delete-btn',
+ awToolTip: 'Cancel a running update process'
}
}
});