1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 09:51:09 +03:00

Fixes for AC-715 'adding cloud credentials to job_template' and AC-721 'this.scope not defined'

This commit is contained in:
Chris Houseknecht 2013-11-22 21:28:09 +00:00
parent 9d1bc65233
commit 9171382894
9 changed files with 45 additions and 37 deletions

View File

@ -14,6 +14,7 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res
GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller,
ClearScope, ProcessErrors, GetBasePath, SelectionInit, GetChoices, Wait, Stream)
{
ClearScope('tree-form');
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
var list = CredentialList;
@ -61,7 +62,7 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res
if (scope.removeChoicesReady) {
scope.removeChoicesReady();
}
scope.removeChoicesReady = scope.$on('choicesReady', function() {
scope.removeChoicesReady = scope.$on('choicesReadyCredential', function() {
SearchInit({ scope: scope, set: 'credentials', list: list, url: defaultUrl });
PaginateInit({ scope: scope, list: list, url: defaultUrl });
scope.search(list.iterator);
@ -73,7 +74,7 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res
url: defaultUrl,
field: 'kind',
variable: 'credential_kind_options',
callback: 'choicesReady'
callback: 'choicesReadyCredential'
});
@ -124,6 +125,7 @@ function CredentialsAdd ($scope, $rootScope, $compile, $location, $log, $routePa
GenerateList, SearchInit, PaginateInit, LookUpInit, UserList, TeamList, GetBasePath,
GetChoices, Empty, KindChange, OwnerChange, FormSave, DebugForm)
{
ClearScope('tree-form');
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@ -256,6 +258,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
KindChange, UserList, TeamList, LookUpInit, Empty, OwnerChange, FormSave, Stream
)
{
ClearScope('tree-form');
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@ -324,7 +327,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
if (scope.removeChoicesReady) {
scope.removeChoicesReady();
}
scope.removeChoicesReady = scope.$on('choicesReady', function() {
scope.removeChoicesReady = scope.$on('choicesReadyCredential', function() {
// Retrieve detail record and prepopulate the form
Rest.setUrl(defaultUrl + ':id/');
Rest.get({ params: {id: id} })
@ -392,7 +395,7 @@ function CredentialsEdit ($scope, $rootScope, $compile, $location, $log, $routeP
url: defaultUrl,
field: 'kind',
variable: 'credential_kind_options',
callback: 'choicesReady'
callback: 'choicesReadyCredential'
});
scope.showActivity = function() { Stream(); }

View File

@ -483,6 +483,10 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route
{ hdr: 'Error!', msg: 'Failed to related cloud credential. GET returned status: ' + status });
});
}
else {
// No existing cloud credential
scope.$emit('cloudCredentialReady', null);
}
});
// Retrieve detail record and prepopulate the form

View File

@ -15,8 +15,8 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
ClearScope, ProcessErrors, GetBasePath, SelectionInit, ProjectUpdate, ProjectStatus,
FormatDate, Refresh, Wait, Stream, GetChoices)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
ClearScope('tree-form');
ClearScope('htmlTemplate');
var list = ProjectList;
var defaultUrl = GetBasePath('projects');
@ -84,7 +84,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
if (scope.removeChoicesHere) {
scope.removeChoicesHere();
}
scope.removeChoicesHere = scope.$on('choicesHere', function() {
scope.removeChoicesHere = scope.$on('choicesCompleteProject', function() {
list.fields.scm_type.searchOptions = scope.project_scm_type_options;
list.fields.status.searchOptions = scope.project_status_options;
@ -130,10 +130,10 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
if (scope.removeChoicesReady) {
scope.removeChoicesReady();
}
scope.removeChoicesReady = scope.$on('choicesReady', function() {
scope.removeChoicesReady = scope.$on('choicesReadyProject', function() {
choiceCount++;
if (choiceCount == 2) {
scope.$emit('choicesHere');
scope.$emit('choicesCompleteProject');
}
});
@ -143,7 +143,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
url: defaultUrl,
field: 'status',
variable: 'project_status_options',
callback: 'choicesReady'
callback: 'choicesReadyProject'
});
// Load the list of options for Kind
@ -152,7 +152,7 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
url: defaultUrl,
field: 'scm_type',
variable: 'project_scm_type_options',
callback: 'choicesReady'
callback: 'choicesReadyProject'
});
LoadBreadCrumbs();
@ -329,8 +329,8 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList,
CredentialList, GetChoices, DebugForm, Wait)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
ClearScope('tree-form');
ClearScope('htmlTemplate');
// Inject dynamic view
var form = ProjectsForm;
@ -466,8 +466,8 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
RelatedPaginateInit, Prompt, ClearScope, GetBasePath, ReturnToCaller, GetProjectPath,
Authorization, CredentialList, LookUpInit, GetChoices, Empty, DebugForm, Wait, Stream)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
ClearScope('tree-form');
ClearScope('htmlTemplate');
// Inject dynamic view
var form = ProjectsForm;

View File

@ -103,8 +103,8 @@ angular.module('JobTemplateFormDefinition', [])
sourceModel: 'credential',
sourceField: 'name',
ngClick: 'lookUpCredential()',
addRequired: true,
editRequired: true,
addRequired: false,
editRequired: false,
column: 1,
awPopOver: "<p>Select the credential you want the job to use when accessing the remote hosts. Choose the credential containing " +
" the username and SSH key or password that Ansbile will need to log into the remote hosts.</p>",

View File

@ -719,18 +719,18 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
LookUpInit, CredentialList, Empty, Wait, GetChoices) {
return function(params) {
$('#tree-form').hide().empty();
var group_id = params.group_id;
var inventory_id = params.inventory_id;
var generator = GenerateForm;
var form = GroupForm;
var defaultUrl = GetBasePath('groups') + group_id + '/';
$('#tree-form').hide().empty();
var scope = generator.inject(form,
{ mode: 'edit', modal: false, related: false, id: 'tree-form', breadCrumbs: false });
generator.reset();
var element = angular.element(document.getElementById('tree-form'));
var scope = element.scope();
//var scope = generator.inject(form, { mode: 'edit', modal: false, related: false, id: 'tree-form', breadCrumbs: false });
var master = {};
var relatedSets = {};
@ -892,12 +892,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
if (scope.removeChoicesComplete) {
scope.removeChoicesComplete();
}
scope.removeChoicesComplete = scope.$on('choicesComplete', function() {
generator.inject(form, { mode: 'edit', modal: false, related: false, id: 'tree-form',
breadCrumbs: false, scope: scope });
generator.reset();
scope.removeChoicesComplete = scope.$on('choicesCompleteGroup', function() {
// Retrieve detail record and prepopulate the form
Rest.setUrl(defaultUrl);
Rest.get()
@ -929,10 +924,10 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
if (scope.removeChoicesReady) {
scope.removeChoicesReady();
}
scope.removeChoicesReady = scope.$on('choicesReady', function() {
scope.removeChoicesReady = scope.$on('choicesReadyGroup', function() {
choicesReady++;
if (choicesReady == 2) {
scope.$emit('choicesComplete');
scope.$emit('choicesCompleteGroup');
}
});
@ -943,7 +938,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
field: 'source_regions',
variable: 'rax_regions',
choice_name: 'rax_region_choices',
callback: 'choicesReady'
callback: 'choicesReadyGroup'
});
GetChoices({
@ -952,7 +947,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
field: 'source_regions',
variable: 'ec2_regions',
choice_name: 'ec2_region_choices',
callback: 'choicesReady'
callback: 'choicesReadyGroup'
});
if (!scope.$$phase) {

View File

@ -9,9 +9,12 @@ angular.module('Utilities',['RestServices', 'Utilities'])
.factory('ClearScope', [ function() {
return function(id) {
var element = document.getElementById(id);
if (element) {
var scope = angular.element(element).scope();
scope.$destroy();
}
$('.tooltip').each( function(index) {
// Remove any lingering tooltip and popover <div> elements
@ -378,7 +381,7 @@ angular.module('Utilities',['RestServices', 'Utilities'])
}).fadeIn(400);
}
else if (directive == 'stop' && $rootScope.waiting){
$('.spinny, .overlay').fadeOut(800, function(){ $rootScope.waiting = false; });
$('.spinny, .overlay').fadeOut(400, function(){ $rootScope.waiting = false; });
}
}
}])

View File

@ -25,6 +25,8 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities'])
accordion_count: 0,
scope: null,
has: function(key) {
return (this.form[key] && this.form[key] != null && this.form[key] != undefined) ? true : false;
},

View File

@ -498,7 +498,7 @@ angular.module('GeneratorHelpers', ['GeneratorHelpers'])
html += "<div class=\"input-group-btn dropdown\">\n";
html += "<button type=\"button\" ";
html += "id=\"search_field_ddown\" ";
html += "class=\"btn ";
html += "class=\"btn btn-default ";
html += "dropdown-toggle\" data-toggle=\"dropdown\"";
html += ">\n";
html += "<span ng-bind=\"" + iterator + "SearchFieldLabel" + modifier + "\"></span>\n";

View File

@ -10,6 +10,7 @@
<link rel="stylesheet" href="{{ STATIC_URL }}css/select2.css" />
<link rel="stylesheet" href="{{ STATIC_URL }}css/select2-bootstrap.css" />
{% if settings.USE_MINIFIED_JS %}
<link rel="stylesheet" href="{{ STATIC_URL }}css/awx.min.css" />
{% else %}