mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 04:10:44 -03:30
AC-458, AC-503 Added ability to cancel inventory update. Cleaned up issues with SCM update cancel.
This commit is contained in:
parent
78c9bbf168
commit
5efc44a833
@ -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 <em>Refresh</em> 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 <em>Refresh</em> ' +
|
||||
'button to view the latet status.', 'alert-info');
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 <em>Refresh</em> 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 <em>Refresh</em> ' +
|
||||
'button to view the latet status.', 'alert-info');
|
||||
}
|
||||
}
|
||||
|
||||
// Respond to refresh button
|
||||
scope.refresh = function() {
|
||||
scope['groupSearchSpin'] = true;
|
||||
|
||||
@ -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'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user