mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 21:21:21 -03:30
AC-715 Fixed issues with bad API requests when user types in value and lookup is built with predetermined search parameters. Fixed project lookup failure while user is typing.
This commit is contained in:
parent
a0fd9c5f18
commit
8dafc10541
@ -95,7 +95,7 @@ JobTemplatesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$rout
|
||||
function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, JobTemplateForm,
|
||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope,
|
||||
GetBasePath, InventoryList, CredentialList, ProjectList, LookUpInit,
|
||||
md5Setup, ParseTypeChange, Wait)
|
||||
md5Setup, ParseTypeChange, Wait, Empty)
|
||||
{
|
||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||
//scope.
|
||||
@ -187,7 +187,7 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
|
||||
// Detect and alert user to potential SCM status issues
|
||||
var checkSCMStatus = function(oldValue, newValue) {
|
||||
if (oldValue !== newValue) {
|
||||
if (oldValue !== newValue && !Empty(scope.project)) {
|
||||
Rest.setUrl(GetBasePath('projects') + scope.project + '/');
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
@ -304,14 +304,14 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP
|
||||
JobTemplatesAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobTemplateForm',
|
||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope',
|
||||
'GetBasePath', 'InventoryList', 'CredentialList', 'ProjectList', 'LookUpInit',
|
||||
'md5Setup', 'ParseTypeChange', 'Wait'];
|
||||
'md5Setup', 'ParseTypeChange', 'Wait', 'Empty' ];
|
||||
|
||||
|
||||
function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, JobTemplateForm,
|
||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
|
||||
RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList, CredentialList,
|
||||
ProjectList, LookUpInit, PromptPasswords, GetBasePath, md5Setup, ParseTypeChange,
|
||||
JobStatusToolTip, FormatDate, Wait, Stream)
|
||||
JobStatusToolTip, FormatDate, Wait, Stream, Empty)
|
||||
{
|
||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||
//scope.
|
||||
@ -366,34 +366,36 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
|
||||
|
||||
// Detect and alert user to potential SCM status issues
|
||||
var checkSCMStatus = function() {
|
||||
Rest.setUrl(GetBasePath('projects') + scope.project + '/');
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
var msg;
|
||||
switch(data.status) {
|
||||
case 'failed':
|
||||
msg = "The selected project has a <em>failed</em> status. Review the project's SCM settings" +
|
||||
" and run an update before adding it to a template.";
|
||||
break;
|
||||
case 'never updated':
|
||||
msg = 'The selected project has a <em>never updated</em> status. You will need to run a successful' +
|
||||
' update in order to selected a playbook. Without a valid playbook you will not be able ' +
|
||||
' to save this template.';
|
||||
break;
|
||||
case 'missing':
|
||||
msg = 'The selected project has a status of <em>missing</em>. Please check the server and make sure ' +
|
||||
' the directory exists and file permissions are set correctly.';
|
||||
break;
|
||||
}
|
||||
if (!Empty(scope.project)) {
|
||||
Rest.setUrl(GetBasePath('projects') + scope.project + '/');
|
||||
Rest.get()
|
||||
.success( function(data, status, headers, config) {
|
||||
var msg;
|
||||
switch(data.status) {
|
||||
case 'failed':
|
||||
msg = "The selected project has a <em>failed</em> status. Review the project's SCM settings" +
|
||||
" and run an update before adding it to a template.";
|
||||
break;
|
||||
case 'never updated':
|
||||
msg = 'The selected project has a <em>never updated</em> status. You will need to run a successful' +
|
||||
' update in order to selected a playbook. Without a valid playbook you will not be able ' +
|
||||
' to save this template.';
|
||||
break;
|
||||
case 'missing':
|
||||
msg = 'The selected project has a status of <em>missing</em>. Please check the server and make sure ' +
|
||||
' the directory exists and file permissions are set correctly.';
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg) {
|
||||
Alert('Waning', msg, 'alert-info');
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to get project ' + scope.project +'. GET returned status: ' + status });
|
||||
});
|
||||
if (msg) {
|
||||
Alert('Waning', msg, 'alert-info');
|
||||
}
|
||||
})
|
||||
.error( function(data, status, headers, config) {
|
||||
ProcessErrors(scope, data, status, form,
|
||||
{ hdr: 'Error!', msg: 'Failed to get project ' + scope.project +'. GET returned status: ' + status });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -683,5 +685,5 @@ JobTemplatesEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$
|
||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
|
||||
'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'InventoryList', 'CredentialList',
|
||||
'ProjectList', 'LookUpInit', 'PromptPasswords', 'GetBasePath', 'md5Setup', 'ParseTypeChange',
|
||||
'JobStatusToolTip', 'FormatDate', 'Wait', 'Stream'
|
||||
'JobStatusToolTip', 'FormatDate', 'Wait', 'Stream', 'Empty'
|
||||
];
|
||||
|
||||
@ -38,8 +38,10 @@ angular.module('LookUpHelper', [ 'RestServices', 'Utilities', 'SearchHelper', 'P
|
||||
var name = list.iterator.charAt(0).toUpperCase() + list.iterator.substring(1);
|
||||
var hdr = (params.hdr) ? params.hdr : 'Select ' + name;
|
||||
|
||||
$('input[name="' + form.fields[field].sourceModel + '_' + form.fields[field].sourceField + '"]').attr('data-url',defaultUrl +
|
||||
'?' + form.fields[field].sourceField + '__' + 'iexact=:value');
|
||||
var watchUrl = (/\/$/.test(defaultUrl)) ? defaultUrl + '?' : defaultUrl + '&';
|
||||
watchUrl += form.fields[field].sourceField + '__' + 'iexact=:value';
|
||||
|
||||
$('input[name="' + form.fields[field].sourceModel + '_' + form.fields[field].sourceField + '"]').attr('data-url', watchUrl);
|
||||
$('input[name="' + form.fields[field].sourceModel + '_' + form.fields[field].sourceField + '"]').attr('data-source',field);
|
||||
|
||||
scope['lookUp' + name] = function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user