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:
Chris Houseknecht
2013-11-20 18:07:39 +00:00
parent 2f90ce511f
commit 99726266e9
5 changed files with 31 additions and 14 deletions

View File

@@ -298,7 +298,6 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
// Save // Save
scope.formSave = function() { scope.formSave = function() {
generator.clearApiErrors(); generator.clearApiErrors();
Wait('start');
var data = {}; var data = {};
for (var fld in form.fields) { for (var fld in form.fields) {
if (form.fields[fld].type == 'checkbox_group') { 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; var url = (base == 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.post(data) Rest.post(data)
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
@@ -335,6 +335,7 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
(base == 'projects') ? ReturnToCaller() : ReturnToCaller(1); (base == 'projects') ? ReturnToCaller() : ReturnToCaller(1);
}) })
.error( function(data, status, headers, config) { .error( function(data, status, headers, config) {
Wait('stop');
ProcessErrors(scope, data, status, ProjectsForm, ProcessErrors(scope, data, status, ProjectsForm,
{ hdr: 'Error!', msg: 'Failed to add organization to project. POST returned status: ' + status }); { hdr: 'Error!', msg: 'Failed to add organization to project. POST returned status: ' + status });
}); });

View File

@@ -103,8 +103,6 @@ angular.module('CredentialsHelper', ['Utilities'])
var form = CredentialForm; var form = CredentialForm;
var data = {} var data = {}
Wait('start');
for (var fld in form.fields) { for (var fld in form.fields) {
if (fld !== 'access_key' && fld !== 'secret_key' && fld !== 'ssh_username' && if (fld !== 'access_key' && fld !== 'secret_key' && fld !== 'ssh_username' &&
fld !== 'ssh_password') { 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'); 'user, select a User. To allow a team of users to access this credential, select a Team.', 'alert-danger');
} }
else { else {
Wait('start');
if (mode == 'add') { if (mode == 'add') {
var url = (!Empty(data.team)) ? GetBasePath('teams') + data.team + '/credentials/' : var url = (!Empty(data.team)) ? GetBasePath('teams') + data.team + '/credentials/' :
GetBasePath('users') + data.user + '/credentials/'; GetBasePath('users') + data.user + '/credentials/';

View File

@@ -328,10 +328,10 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
.factory('InventoryStatus', [ '$rootScope', '$routeParams', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventorySummary', .factory('InventoryStatus', [ '$rootScope', '$routeParams', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'FormatDate', 'InventorySummary',
'GenerateList', 'ClearScope', 'SearchInit', 'PaginateInit', 'Refresh', 'InventoryUpdate', 'GroupsEdit', 'HelpDialog', '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, function($rootScope, $routeParams, Rest, Alert, ProcessErrors, GetBasePath, FormatDate, InventorySummary, GenerateList, ClearScope,
SearchInit, PaginateInit, Refresh, InventoryUpdate, GroupsEdit, HelpDialog, InventorySummaryHelp, BuildTree, ClickNode, SearchInit, PaginateInit, Refresh, InventoryUpdate, GroupsEdit, HelpDialog, InventorySummaryHelp, BuildTree, ClickNode,
HostsStatusMsg, UpdateStatusMsg, ViewUpdateStatus) { HostsStatusMsg, UpdateStatusMsg, ViewUpdateStatus, Wait) {
return function(params) { return function(params) {
//Build a summary of a given inventory //Build a summary of a given inventory
@@ -544,6 +544,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
scope.sourcePasswordLabel = 'Password'; scope.sourcePasswordLabel = 'Password';
scope.sourcePasswordConfirmLabel = 'Confirm Password'; scope.sourcePasswordConfirmLabel = 'Confirm Password';
}*/ }*/
Wait('start');
Rest.setUrl(scope.groups[i].related.inventory_source); Rest.setUrl(scope.groups[i].related.inventory_source);
Rest.get() Rest.get()
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
@@ -556,6 +557,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
}); });
}) })
.error( function(data, status, headers, config) { .error( function(data, status, headers, config) {
Wait('stop');
ProcessErrors(scope, data, status, form, ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + scope.groups[i].related.inventory_source + { hdr: 'Error!', msg: 'Failed to retrieve inventory source: ' + scope.groups[i].related.inventory_source +
' POST returned status: ' + status }); ' POST returned status: ' + status });

View File

@@ -103,6 +103,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
} }
if (passwords && passwords.length > 0) { if (passwords && passwords.length > 0) {
Wait('stop');
// Prompt for passwords // Prompt for 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 : "";
@@ -195,9 +196,9 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
}]) }])
.factory('SubmitJob',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'CredentialList', .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, function(PromptPasswords, $compile, Rest, $location, GetBasePath, CredentialList, LookUpInit, CredentialForm,
ProcessErrors) { ProcessErrors, JobTemplateForm, Wait) {
return function(params) { return function(params) {
var scope = params.scope; var scope = params.scope;
var id = params.id; var id = params.id;
@@ -213,6 +214,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
var dt = new Date().toISOString(); var dt = new Date().toISOString();
var url = (data.related.jobs) ? data.related.jobs : data.related.job_template + 'jobs/'; var url = (data.related.jobs) ? data.related.jobs : data.related.job_template + 'jobs/';
var name = (template_name) ? template_name : data.name; var name = (template_name) ? template_name : data.name;
Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.post({ Rest.post({
name: name + ' ' + dt, // job name required and unique name: name + ' ' + dt, // job name required and unique
@@ -228,6 +230,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
extra_vars: data.extra_vars extra_vars: data.extra_vars
}) })
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
Wait('stop');
scope.job_id = data.id; scope.job_id = data.id;
if (data.passwords_needed_to_start.length > 0) { if (data.passwords_needed_to_start.length > 0) {
// Passwords needed. Prompt for passwords, then start job. // Passwords needed. Prompt for passwords, then start job.
@@ -240,9 +243,11 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
} }
else { else {
// No passwords needed, start the job! // No passwords needed, start the job!
Wait('start');
Rest.setUrl(data.related.start); Rest.setUrl(data.related.start);
Rest.post() Rest.post()
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
Wait('stop');
var base = $location.path().replace(/^\//,'').split('/')[0]; var base = $location.path().replace(/^\//,'').split('/')[0];
if (base == 'jobs') { if (base == 'jobs') {
scope.refresh(); scope.refresh();
@@ -252,21 +257,25 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
} }
}) })
.error( function(data, status, headers, config) { .error( function(data, status, headers, config) {
Wait('stop');
ProcessErrors(scope, data, status, null, ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Failed to start job. POST returned status: ' + status }); { hdr: 'Error!', msg: 'Failed to start job. POST returned status: ' + status });
}); });
} }
}) })
.error( function(data, status, headers, config) { .error( function(data, status, headers, config) {
Wait('stop');
ProcessErrors(scope, data, status, null, ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Failed to create job. POST returned status: ' + status }); { hdr: 'Error!', msg: 'Failed to create job. POST returned status: ' + status });
}); });
}; };
// Get the job or job_template record // Get the job or job_template record
Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
Wait('stop');
// Create a job record // Create a job record
scope.credential = ''; scope.credential = '';
if (data.credential == '' || data.credential == null) { if (data.credential == '' || data.credential == null) {
@@ -300,6 +309,7 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
} }
}) })
.error( function(data, status, headers, config) { .error( function(data, status, headers, config) {
Wait('stop');
ProcessErrors(scope, data, status, null, ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Failed to get job template details. GET returned status: ' + status }); { 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 // Sumbit SCM Update request
.factory('ProjectUpdate',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert', .factory('ProjectUpdate',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert',
'ProjectsForm', 'ProjectsForm', 'Wait',
function(PromptPasswords, $compile, Rest, $location, GetBasePath, ProcessErrors, Alert, ProjectsForm) { function(PromptPasswords, $compile, Rest, $location, GetBasePath, ProcessErrors, Alert, ProjectsForm, Wait) {
return function(params) { return function(params) {
var scope = params.scope; var scope = params.scope;
var project_id = params.project_id; 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 // Check to see if we have permission to perform the update and if any passwords are needed
Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
Wait('stop');
if (data.can_update) { if (data.can_update) {
var extra_html = ''; var extra_html = '';
for (var i=0; i < scope.projects.length; i++) { 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) { .error( function(data, status, headers, config) {
Wait('stop');
ProcessErrors(scope, data, status, null, ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Failed to get project update details: ' + url + ' GET status: ' + status }); { 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 // Sumbit Inventory Update request
.factory('InventoryUpdate',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert', .factory('InventoryUpdate',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert',
'GroupForm', 'BuildTree', 'GroupForm', 'BuildTree', 'Wait',
function(PromptPasswords, $compile, Rest, $location, GetBasePath, ProcessErrors, Alert, GroupForm, BuildTree) { function(PromptPasswords, $compile, Rest, $location, GetBasePath, ProcessErrors, Alert, GroupForm, BuildTree, Wait) {
return function(params) { return function(params) {
var scope = params.scope; 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 // Check to see if we have permission to perform the update and if any passwords are needed
Wait('start');
Rest.setUrl(url); Rest.setUrl(url);
Rest.get() Rest.get()
.success( function(data, status, headers, config) { .success( function(data, status, headers, config) {
@@ -451,11 +465,13 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
scope.$emit('InventorySubmit', data.passwords_needed_to_update); scope.$emit('InventorySubmit', data.passwords_needed_to_update);
} }
else { else {
Wait('stop');
Alert('Permission Denied', 'You do not have access to run the update. Please contact your system administrator.', Alert('Permission Denied', 'You do not have access to run the update. Please contact your system administrator.',
'alert-danger'); 'alert-danger');
} }
}) })
.error( function(data, status, headers, config) { .error( function(data, status, headers, config) {
Wait('stop');
ProcessErrors(scope, data, status, null, ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Failed to get inventory_source details. ' + url + 'GET status: ' + status }); { hdr: 'Error!', msg: 'Failed to get inventory_source details. ' + url + 'GET status: ' + status });
}); });

View File

@@ -378,8 +378,7 @@ angular.module('Utilities',['RestServices', 'Utilities'])
}).fadeIn(400); }).fadeIn(400);
} }
else if (directive == 'stop' && $rootScope.waiting){ else if (directive == 'stop' && $rootScope.waiting){
$rootScope.waiting = false; $('.spinny, .overlay').fadeOut(800, function(){ $rootScope.waiting = false; });
$('.spinny, .overlay').fadeOut(500);
} }
} }
}]) }])