mirror of
https://github.com/ansible/awx.git
synced 2026-05-05 16:37:37 -02:30
AC-458 added ability to cancel SCM update process. Started work on prompting for SCM and Inventory passwords during job submission process.
This commit is contained in:
@@ -93,10 +93,6 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
else if (project.related.last_update) {
|
else if (project.related.last_update) {
|
||||||
ProjectStatus({ project_id: id, last_update: project.related.last_update });
|
ProjectStatus({ project_id: id, last_update: project.related.last_update });
|
||||||
}
|
}
|
||||||
// else if (project.status == 'updating') {
|
|
||||||
// Alert('Pending Status', 'An update is currently running. Status details cannot be viewed until the update process ' +
|
|
||||||
// ' completes. Use the refresh button to monitor progress of the update process.', 'alert-info');
|
|
||||||
// }
|
|
||||||
else {
|
else {
|
||||||
Alert('No Updates Available', 'There is no SCM update information available for this project. An update has not yet been ' +
|
Alert('No Updates Available', 'There is no SCM update information available for this project. An update has not yet been ' +
|
||||||
' completed. If you have not already done so, start an update for this project.', 'alert-info');
|
' completed. If you have not already done so, start an update for this project.', 'alert-info');
|
||||||
@@ -115,27 +111,94 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
scope.deleteProject = function(id, name) {
|
scope.deleteProject = function(id, name) {
|
||||||
|
var action = function() {
|
||||||
|
var url = defaultUrl + id + '/';
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.destroy()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
scope.search(list.iterator);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
ProcessErrors(scope, data, status, null,
|
||||||
|
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var action = function() {
|
Prompt({ hdr: 'Delete',
|
||||||
var url = defaultUrl + id + '/';
|
body: 'Are you sure you want to delete ' + name + '?',
|
||||||
Rest.setUrl(url);
|
action: action
|
||||||
Rest.destroy()
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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 SCM update process completed. Use 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) {
|
||||||
|
// Start the update process
|
||||||
|
var project;
|
||||||
|
var found = false;
|
||||||
|
for (var i=0; i < projects.length; i++) {
|
||||||
|
if (projects[i].id == id) {
|
||||||
|
project = projects[i];
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found && project.related.current_update) {
|
||||||
|
Rest.setUrl(project.related.current_update);
|
||||||
|
Rest.get()
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
$('#prompt-modal').modal('hide');
|
scope.$emit('Check_Cancel', data);
|
||||||
scope.search(list.iterator);
|
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
$('#prompt-modal').modal('hide');
|
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
{ hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Call to ' + project.related.current_update + ' failed. GET status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
else {
|
||||||
Prompt({ hdr: 'Delete',
|
Alert('Update Not Found', 'An SCM Update does not appear to be running for project ' + name + '. Click the Refresh ' +
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
'button to view the latet status.', 'alert-info');
|
||||||
action: action
|
}
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
scope.refresh = function() {
|
scope.refresh = function() {
|
||||||
scope['projectSearchSpin'] = true;
|
scope['projectSearchSpin'] = true;
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'CredentialFormDefinition', 'CredentialsListDefinition',
|
angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'CredentialFormDefinition', 'CredentialsListDefinition',
|
||||||
'LookUpHelper', 'ProjectFormDefinition', 'JobSubmissionHelper', 'GroupFormDefinition', 'GroupsHelper' ])
|
'LookUpHelper', 'ProjectFormDefinition', 'JobSubmissionHelper', 'GroupFormDefinition', 'GroupsHelper' ])
|
||||||
|
|
||||||
.factory('PromptPasswords', ['CredentialForm', 'JobTemplateForm', 'ProjectsForm', '$compile', 'Rest', '$location', 'ProcessErrors', 'GetBasePath',
|
.factory('PromptPasswords', ['CredentialForm', 'JobTemplateForm', 'GroupForm', 'ProjectsForm', '$compile', 'Rest', '$location', 'ProcessErrors',
|
||||||
'Alert',
|
'GetBasePath', 'Alert',
|
||||||
function(CredentialForm, JobTemplateForm, ProjectsForm, $compile, Rest, $location, ProcessErrors, GetBasePath, Alert) {
|
function(CredentialForm, JobTemplateForm, ProjectsForm, GroupForm, $compile, Rest, $location, ProcessErrors, GetBasePath, Alert) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
var scope = params.scope;
|
var scope = params.scope;
|
||||||
@@ -98,12 +98,34 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (passwords.length > 0) {
|
if (passwords.length > 0) {
|
||||||
// We need to prompt for passwords
|
// Prompt for passwords
|
||||||
|
console.log(passwords);
|
||||||
html += "<form class=\"form-horizontal\" name=\"password_form\" novalidate>\n";
|
html += "<form class=\"form-horizontal\" name=\"password_form\" novalidate>\n";
|
||||||
html += (extra_html) ? extra_html : "";
|
html += (extra_html) ? extra_html : "";
|
||||||
|
var current_form;
|
||||||
for (var i=0; i < passwords.length; i++) {
|
for (var i=0; i < passwords.length; i++) {
|
||||||
// Add the password field
|
// Add the password field
|
||||||
field = (form.fields[passwords[i]]) ? form.fields[passwords[i]] : ProjectsForm.fields[passwords[i]];
|
if (form.name == 'credential') {
|
||||||
|
// this is a job. we could be prompting for inventory and/or SCM passwords
|
||||||
|
if (form.fields[passwords[i]]) {
|
||||||
|
current_form = form;
|
||||||
|
}
|
||||||
|
else if (ProjectsForm.fields[passwords[i]]) {
|
||||||
|
current_form = ProjectsForm;
|
||||||
|
}
|
||||||
|
else if (GroupForm.fields[passwords[i]]) {
|
||||||
|
current_form = GroupForm;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// No match found. Abandon ship!
|
||||||
|
Alert('Form Not Found', 'Could not locate form for: ' + passwords[i], 'alert-danger');
|
||||||
|
$location('/#/jobs');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
current_form = form;
|
||||||
|
}
|
||||||
|
field = current_form.fields[passwords[i]];
|
||||||
fld = passwords[i];
|
fld = passwords[i];
|
||||||
scope[fld] = '';
|
scope[fld] = '';
|
||||||
html += "<div class=\"form-group\">\n";
|
html += "<div class=\"form-group\">\n";
|
||||||
@@ -127,7 +149,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
|
|
||||||
// Add the related confirm field
|
// Add the related confirm field
|
||||||
fld = field.associated;
|
fld = field.associated;
|
||||||
field = (form.fields[field.associated]) ? form.fields[field.associated] : ProjectsForm.fields[field.associated];
|
field = current_form.fields[field.associated];
|
||||||
scope[fld] = '';
|
scope[fld] = '';
|
||||||
html += "<div class=\"form-group\">\n";
|
html += "<div class=\"form-group\">\n";
|
||||||
html += "<label class=\"control-label col-lg-3 normal-weight\" for=\"" + fld + "\">* ";
|
html += "<label class=\"control-label col-lg-3 normal-weight\" for=\"" + fld + "\">* ";
|
||||||
@@ -219,10 +241,10 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
if (base == 'jobs') {
|
if (base == 'jobs') {
|
||||||
scope.refreshJob();
|
scope.refresh();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$location.path('/jobs');
|
$location.url('/#/jobs');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
@@ -294,6 +316,8 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
}
|
}
|
||||||
scope.removeUpdateSubmitted = scope.$on('UpdateSubmitted', function(e, action) {
|
scope.removeUpdateSubmitted = scope.$on('UpdateSubmitted', function(e, action) {
|
||||||
// Refresh the project list after update request submitted
|
// Refresh the project list after update request submitted
|
||||||
|
Alert('Update Started', 'The request to start the SCM update process was submitted. ' +
|
||||||
|
'The Projects page will refresh every 10 seconds, or refresh manually by clicking the <em>Refresh</em> button.', 'alert-info');
|
||||||
scope.refresh();
|
scope.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -379,7 +403,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
scope.removeUpdateSubmitted = scope.$on('UpdateSubmitted', function(e, action) {
|
scope.removeUpdateSubmitted = scope.$on('UpdateSubmitted', function(e, action) {
|
||||||
if (action == 'started') {
|
if (action == 'started') {
|
||||||
// Refresh the project list after update request submitted
|
// Refresh the project list after update request submitted
|
||||||
Alert('Update Started', 'The request to start the inventory process was submitted. Monitor progress from the inventory summary screen. ' +
|
Alert('Update Started', 'The request to start the inventory update process was submitted. Monitor progress from the inventory summary screen. ' +
|
||||||
'The screen will refresh every 10 seconds, or refresh manually by clicking the <em>Refresh</em> button.', 'alert-info');
|
'The screen will refresh every 10 seconds, or refresh manually by clicking the <em>Refresh</em> button.', 'alert-info');
|
||||||
var node = $('#inventory-node')
|
var node = $('#inventory-node')
|
||||||
var selected = $('#tree-view').jstree('get_selected');
|
var selected = $('#tree-view').jstree('get_selected');
|
||||||
|
|||||||
@@ -82,31 +82,6 @@ angular.module('JobsListDefinition', [])
|
|||||||
},
|
},
|
||||||
|
|
||||||
fieldActions: {
|
fieldActions: {
|
||||||
/*summary: {
|
|
||||||
label: 'Hosts',
|
|
||||||
icon: 'icon-laptop',
|
|
||||||
ngClick: "viewSummary(\{{ job.id \}\}, '\{\{ job.summary_fields.job_template.name \}\}')",
|
|
||||||
"class": 'btn btn-default btn-xs',
|
|
||||||
awToolTip: 'View host summary',
|
|
||||||
ngDisabled: "job.status == 'new'"
|
|
||||||
},
|
|
||||||
events: {
|
|
||||||
label: 'Events',
|
|
||||||
icon: 'icon-list-ul',
|
|
||||||
mode: 'all',
|
|
||||||
ngClick: "viewEvents(\{{ job.id \}\}, '\{\{ job.summary_fields.job_template.name \}\}')",
|
|
||||||
"class": 'btn btn-default btn-xs',
|
|
||||||
awToolTip: 'View events',
|
|
||||||
ngDisabled: "job.status == 'new'"
|
|
||||||
},
|
|
||||||
edit: {
|
|
||||||
label: 'Details',
|
|
||||||
icon: 'icon-zoom-in',
|
|
||||||
ngClick: "editJob(\{\{ job.id \}\}, '\{\{ job.summary_fields.job_template.name \}\}')",
|
|
||||||
"class": 'btn btn-default btn-xs',
|
|
||||||
awToolTip: 'View job details'
|
|
||||||
},*/
|
|
||||||
|
|
||||||
dropdown: {
|
dropdown: {
|
||||||
type: 'DropDown',
|
type: 'DropDown',
|
||||||
label: 'View',
|
label: 'View',
|
||||||
@@ -120,7 +95,6 @@ angular.module('JobsListDefinition', [])
|
|||||||
ngHide: "job.status == 'new'" }
|
ngHide: "job.status == 'new'" }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
rerun: {
|
rerun: {
|
||||||
label: 'Launch',
|
label: 'Launch',
|
||||||
icon: 'icon-rocket',
|
icon: 'icon-rocket',
|
||||||
|
|||||||
@@ -90,12 +90,21 @@ angular.module('ProjectsListDefinition', [])
|
|||||||
ngClick: 'SCMUpdate(\{\{ project.id \}\})',
|
ngClick: 'SCMUpdate(\{\{ project.id \}\})',
|
||||||
awToolTip: 'Perform an SCM update on this project'
|
awToolTip: 'Perform an SCM update on this project'
|
||||||
},
|
},
|
||||||
|
cancel: {
|
||||||
|
label: 'Cancel',
|
||||||
|
icon: 'icon-minus-sign',
|
||||||
|
ngClick: "cancelUpdate(\{\{ project.id \}\}, '\{\{ project.name \}\}')",
|
||||||
|
"class": 'btn-danger btn-xs delete-btn',
|
||||||
|
awToolTip: 'Cancel a running SCM update process',
|
||||||
|
ngShow: "project.status == 'updating'"
|
||||||
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
label: 'Delete',
|
label: 'Delete',
|
||||||
ngClick: "deleteProject(\{\{ project.id \}\},'\{\{ project.name \}\}')",
|
ngClick: "deleteProject(\{\{ project.id \}\},'\{\{ project.name \}\}')",
|
||||||
icon: 'icon-trash',
|
icon: 'icon-trash',
|
||||||
"class": 'btn-xs btn-danger',
|
"class": 'btn-danger btn-xs delete-btn',
|
||||||
awToolTip: 'Permanently remove project from the database'
|
awToolTip: 'Permanently remove project from the database',
|
||||||
|
ngShow: "project.status !== 'updating'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1209,7 +1209,7 @@ tr td button i {
|
|||||||
@media (min-width: 1200px) {
|
@media (min-width: 1200px) {
|
||||||
|
|
||||||
.delete-btn {
|
.delete-btn {
|
||||||
/* Used on job page to make cancel and delete buttons have an equal width */
|
/* Used on job and project page to make cancel and delete buttons have an equal width */
|
||||||
width: 60px;
|
width: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user