mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
AC-458, AC-503 Added ability to cancel inventory update. Cleaned up issues with SCM update cancel.
This commit is contained in:
@@ -162,7 +162,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
scope.$emit('Cancel_Update', url);
|
scope.$emit('Cancel_Update', url);
|
||||||
}
|
}
|
||||||
else {
|
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');
|
' view the latest status.', 'alert-info');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -173,12 +173,12 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
});
|
});
|
||||||
|
|
||||||
scope.cancelUpdate = function(id, name) {
|
scope.cancelUpdate = function(id, name) {
|
||||||
// Start the update process
|
// Start the cancel process
|
||||||
var project;
|
var project;
|
||||||
var found = false;
|
var found = false;
|
||||||
for (var i=0; i < projects.length; i++) {
|
for (var i=0; i < scope.projects.length; i++) {
|
||||||
if (projects[i].id == id) {
|
if (scope.projects[i].id == id) {
|
||||||
project = projects[i];
|
project = scope.projects[i];
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
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');
|
'button to view the latet status.', 'alert-info');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,6 +314,74 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
|||||||
$('#tree-view').jstree('select_node', node);
|
$('#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
|
// Respond to refresh button
|
||||||
scope.refresh = function() {
|
scope.refresh = function() {
|
||||||
scope['groupSearchSpin'] = true;
|
scope['groupSearchSpin'] = true;
|
||||||
|
|||||||
@@ -139,6 +139,13 @@ angular.module('InventorySummaryDefinition', [])
|
|||||||
"class": 'btn-xs btn-success',
|
"class": 'btn-xs btn-success',
|
||||||
ngClick: 'updateGroup(\{\{ group.id \}\})',
|
ngClick: 'updateGroup(\{\{ group.id \}\})',
|
||||||
awToolTip: 'Perform an update on this group'
|
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'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user