mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 15:08:03 -03:30
AC-698 when job template does not include a credential, user is prompted for one on launch. The prompt was broken. Fixed. Also made it so that working spinner starts the second you click Update. Tested working spinner initiate and fade out for job, project and inventory submissions.
This commit is contained in:
parent
2f90ce511f
commit
99726266e9
@ -298,7 +298,6 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
// Save
|
||||
scope.formSave = function() {
|
||||
generator.clearApiErrors();
|
||||
Wait('start');
|
||||
var data = {};
|
||||
for (var fld in form.fields) {
|
||||
if (form.fields[fld].type == 'checkbox_group') {
|
||||
@ -321,6 +320,7 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
}
|
||||
|
||||
var url = (base == 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.post(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
@ -335,6 +335,7 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
(base == 'projects') ? ReturnToCaller() : ReturnToCaller(1);
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, ProjectsForm,
|
||||
{ hdr: 'Error!', msg: 'Failed to add organization to project. POST returned status: ' + status });
|
||||
});
|
||||
|
||||
@ -102,9 +102,7 @@ angular.module('CredentialsHelper', ['Utilities'])
|
||||
var mode = params.mode; // add or edit
|
||||
var form = CredentialForm;
|
||||
var data = {}
|
||||
|
||||
Wait('start');
|
||||
|
||||
|
||||
for (var fld in form.fields) {
|
||||
if (fld !== 'access_key' && fld !== 'secret_key' && fld !== 'ssh_username' &&
|
||||
fld !== 'ssh_password') {
|
||||
@ -149,6 +147,7 @@ angular.module('CredentialsHelper', ['Utilities'])
|
||||
'user, select a User. To allow a team of users to access this credential, select a Team.', 'alert-danger');
|
||||
}
|
||||
else {
|
||||
Wait('start');
|
||||
if (mode == 'add') {
|
||||
var url = (!Empty(data.team)) ? GetBasePath('teams') + data.team + '/credentials/' :
|
||||
GetBasePath('users') + data.user + '/credentials/';
|
||||
|
||||
@ -328,10 +328,10 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
|
||||
.factory('InventoryStatus', [ '$rootScope', '$routeParams', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventorySummary',
|
||||
'GenerateList', 'ClearScope', 'SearchInit', 'PaginateInit', 'Refresh', 'InventoryUpdate', 'GroupsEdit', 'HelpDialog',
|
||||
'InventorySummaryHelp', 'BuildTree', 'ClickNode', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus',
|
||||
'InventorySummaryHelp', 'BuildTree', 'ClickNode', 'HostsStatusMsg', 'UpdateStatusMsg', 'ViewUpdateStatus', 'Wait',
|
||||
function($rootScope, $routeParams, Rest, Alert, ProcessErrors, GetBasePath, FormatDate, InventorySummary, GenerateList, ClearScope,
|
||||
SearchInit, PaginateInit, Refresh, InventoryUpdate, GroupsEdit, HelpDialog, InventorySummaryHelp, BuildTree, ClickNode,
|
||||
HostsStatusMsg, UpdateStatusMsg, ViewUpdateStatus) {
|
||||
HostsStatusMsg, UpdateStatusMsg, ViewUpdateStatus, Wait) {
|
||||
return function(params) {
|
||||
//Build a summary of a given inventory
|
||||
|
||||
@ -544,6 +544,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
scope.sourcePasswordLabel = 'Password';
|
||||
scope.sourcePasswordConfirmLabel = 'Confirm Password';
|
||||
}*/
|
||||
Wait('start');
|
||||
Rest.setUrl(scope.groups[i].related.inventory_source);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
@ -556,6 +557,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
|
||||
});
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + scope.groups[i].related.inventory_source +
|
||||
' POST returned status: ' + status });
|
||||
|
||||
@ -103,6 +103,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
}
|
||||
|
||||
if (passwords && passwords.length > 0) {
|
||||
Wait('stop');
|
||||
// Prompt for passwords
|
||||
html += "<form class=\"form-horizontal\" name=\"password_form\" novalidate>\n";
|
||||
html += (extra_html) ? extra_html : "";
|
||||
@ -195,9 +196,9 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
}])
|
||||
|
||||
.factory('SubmitJob',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'CredentialList',
|
||||
'LookUpInit', 'CredentialForm', 'ProcessErrors',
|
||||
'LookUpInit', 'CredentialForm', 'ProcessErrors', 'JobTemplateForm', 'Wait',
|
||||
function(PromptPasswords, $compile, Rest, $location, GetBasePath, CredentialList, LookUpInit, CredentialForm,
|
||||
ProcessErrors) {
|
||||
ProcessErrors, JobTemplateForm, Wait) {
|
||||
return function(params) {
|
||||
var scope = params.scope;
|
||||
var id = params.id;
|
||||
@ -213,6 +214,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
var dt = new Date().toISOString();
|
||||
var url = (data.related.jobs) ? data.related.jobs : data.related.job_template + 'jobs/';
|
||||
var name = (template_name) ? template_name : data.name;
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.post({
|
||||
name: name + ' ' + dt, // job name required and unique
|
||||
@ -228,6 +230,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
extra_vars: data.extra_vars
|
||||
})
|
||||
.success( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
scope.job_id = data.id;
|
||||
if (data.passwords_needed_to_start.length > 0) {
|
||||
// Passwords needed. Prompt for passwords, then start job.
|
||||
@ -240,9 +243,11 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
}
|
||||
else {
|
||||
// No passwords needed, start the job!
|
||||
Wait('start');
|
||||
Rest.setUrl(data.related.start);
|
||||
Rest.post()
|
||||
.success( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||
if (base == 'jobs') {
|
||||
scope.refresh();
|
||||
@ -252,21 +257,25 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to start job. POST returned status: ' + status });
|
||||
});
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to create job. POST returned status: ' + status });
|
||||
});
|
||||
};
|
||||
|
||||
// Get the job or job_template record
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
// Create a job record
|
||||
scope.credential = '';
|
||||
if (data.credential == '' || data.credential == null) {
|
||||
@ -300,6 +309,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to get job template details. GET returned status: ' + status });
|
||||
});
|
||||
@ -308,8 +318,8 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
|
||||
// Sumbit SCM Update request
|
||||
.factory('ProjectUpdate',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert',
|
||||
'ProjectsForm',
|
||||
function(PromptPasswords, $compile, Rest, $location, GetBasePath, ProcessErrors, Alert, ProjectsForm) {
|
||||
'ProjectsForm', 'Wait',
|
||||
function(PromptPasswords, $compile, Rest, $location, GetBasePath, ProcessErrors, Alert, ProjectsForm, Wait) {
|
||||
return function(params) {
|
||||
var scope = params.scope;
|
||||
var project_id = params.project_id;
|
||||
@ -340,9 +350,11 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
});
|
||||
|
||||
// Check to see if we have permission to perform the update and if any passwords are needed
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
if (data.can_update) {
|
||||
var extra_html = '';
|
||||
for (var i=0; i < scope.projects.length; i++) {
|
||||
@ -381,6 +393,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to get project update details: ' + url + ' GET status: ' + status });
|
||||
});
|
||||
@ -390,8 +403,8 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
|
||||
// Sumbit Inventory Update request
|
||||
.factory('InventoryUpdate',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert',
|
||||
'GroupForm', 'BuildTree',
|
||||
function(PromptPasswords, $compile, Rest, $location, GetBasePath, ProcessErrors, Alert, GroupForm, BuildTree) {
|
||||
'GroupForm', 'BuildTree', 'Wait',
|
||||
function(PromptPasswords, $compile, Rest, $location, GetBasePath, ProcessErrors, Alert, GroupForm, BuildTree, Wait) {
|
||||
return function(params) {
|
||||
|
||||
var scope = params.scope;
|
||||
@ -442,6 +455,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
});
|
||||
|
||||
// Check to see if we have permission to perform the update and if any passwords are needed
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
@ -451,11 +465,13 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
||||
scope.$emit('InventorySubmit', data.passwords_needed_to_update);
|
||||
}
|
||||
else {
|
||||
Wait('stop');
|
||||
Alert('Permission Denied', 'You do not have access to run the update. Please contact your system administrator.',
|
||||
'alert-danger');
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
Wait('stop');
|
||||
ProcessErrors(scope, data, status, null,
|
||||
{ hdr: 'Error!', msg: 'Failed to get inventory_source details. ' + url + 'GET status: ' + status });
|
||||
});
|
||||
|
||||
@ -378,8 +378,7 @@ angular.module('Utilities',['RestServices', 'Utilities'])
|
||||
}).fadeIn(400);
|
||||
}
|
||||
else if (directive == 'stop' && $rootScope.waiting){
|
||||
$rootScope.waiting = false;
|
||||
$('.spinny, .overlay').fadeOut(500);
|
||||
$('.spinny, .overlay').fadeOut(800, function(){ $rootScope.waiting = false; });
|
||||
}
|
||||
}
|
||||
}])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user