Credential now working on Project detail and Group detail pages.

This commit is contained in:
Chris Houseknecht
2013-11-01 23:34:24 +00:00
committed by Chris Church
parent 19155baf5f
commit a5bb145f70
3 changed files with 140 additions and 148 deletions

View File

@@ -230,7 +230,8 @@ ProjectsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routePar
function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm, function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList) GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList,
CredentialList, GetChoices)
{ {
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope. //scope.
@@ -248,21 +249,47 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
LoadBreadCrumbs(); LoadBreadCrumbs();
GetProjectPath({ scope: scope, master: master }); GetProjectPath({ scope: scope, master: master });
scope.scm_type = null; //scope.scm_type = null;
master.scm_type = null; //master.scm_type = null;
scope.scm_type_options = [
{ label: 'Git', value: 'git' }, if (scope.removeChoicesReady) {
{ label: 'SVN', value: 'svn' }, scope.removeChoicesReady();
{ label: 'Mercurial', value: 'hg'}]; }
scope.removeChoicesReady = scope.$on('choicesReady', function() {
console.log('setting type');
var found = false;
for (var i=0; i < scope.scm_type_options.length; i++) {
if (scope.scm_type_options[i].value == '') {
scope['scm_type'] = scope.scm_type_options[i];
found = true;
break;
}
}
});
// Load the list of options for Kind
GetChoices({
scope: scope,
url: defaultUrl,
field: 'scm_type',
variable: 'scm_type_options',
callback: 'choicesReady'
});
LookUpInit({ LookUpInit({
scope: scope, scope: scope,
form: form, form: form,
current_item: null,
list: OrganizationList, list: OrganizationList,
field: 'organization' field: 'organization'
}); });
LookUpInit({
scope: scope,
form: form,
list: CredentialList,
field: 'credential'
});
// Save // Save
scope.formSave = function() { scope.formSave = function() {
generator.clearApiErrors(); generator.clearApiErrors();
@@ -278,7 +305,7 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
data[fld] = scope[fld]; data[fld] = scope[fld];
} }
} }
} }
if (scope.scm_type) { if (scope.scm_type) {
data.scm_type = scope.scm_type.value; data.scm_type = scope.scm_type.value;
delete data.local_path; delete data.local_path;
@@ -337,14 +364,14 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
ProjectsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm', ProjectsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm',
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
'ReturnToCaller', 'GetProjectPath', 'LookUpInit', 'OrganizationList' 'ReturnToCaller', 'GetProjectPath', 'LookUpInit', 'OrganizationList', 'CredentialList', 'GetChoices'
]; ];
function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm, function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit,
RelatedPaginateInit, Prompt, ClearScope, GetBasePath, ReturnToCaller, GetProjectPath, RelatedPaginateInit, Prompt, ClearScope, GetBasePath, ReturnToCaller, GetProjectPath,
Authorization) Authorization, CredentialList, LookUpInit, GetChoices)
{ {
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope. //scope.
@@ -361,11 +388,6 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
var id = $routeParams.id; var id = $routeParams.id;
var relatedSets = {}; var relatedSets = {};
scope.scm_type_options = [
{ label: 'Git', value: 'git' },
{ label: 'SVN', value: 'svn' },
{ label: 'Mercurial', value: 'hg'}];
scope.project_local_paths = []; scope.project_local_paths = [];
scope.base_dir = ''; scope.base_dir = '';
@@ -401,66 +423,95 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
scope.project_local_paths = opts; scope.project_local_paths = opts;
scope.base_dir = 'You do not have access to view this property'; scope.base_dir = 'You do not have access to view this property';
} }
LookUpInit({
scope: scope,
form: form,
list: CredentialList,
field: 'credential'
});
scope.auth_required = (scope.scm_type && (scope.scm_username || scope.scm_password || scope.scm_key_data)) ? true : false; scope.auth_required = (scope.scm_type && (scope.scm_username || scope.scm_password || scope.scm_key_data)) ? true : false;
master.auth_required = scope.auth_required; master.auth_required = scope.auth_required;
}); });
// Retrieve detail record and prepopulate the form if (scope.removeChoicesReady) {
Rest.setUrl(defaultUrl); scope.removeChoicesReady();
Rest.get({ params: {id: id} }) }
.success( function(data, status, headers, config) { scope.removeChoicesReady = scope.$on('choicesReady', function() {
LoadBreadCrumbs({ path: '/projects/' + id, title: data.name }); // Retrieve detail record and prepopulate the form
for (var fld in form.fields) { Rest.setUrl(defaultUrl);
if (form.fields[fld].type == 'checkbox_group') { Rest.get({ params: {id: id} })
for (var i=0; i < form.fields[fld].fields.length; i++) { .success( function(data, status, headers, config) {
scope[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name]; LoadBreadCrumbs({ path: '/projects/' + id, title: data.name });
master[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name]; for (var fld in form.fields) {
} if (form.fields[fld].type == 'checkbox_group') {
} for (var i=0; i < form.fields[fld].fields.length; i++) {
else { scope[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
if (data[fld]) { master[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
scope[fld] = data[fld]; }
master[fld] = data[fld];
}
}
}
var related = data.related;
for (var set in form.related) {
if (related[set]) {
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
}
}
if (data.scm_type !== "") {
for (var i=0; i < scope.scm_type_options.length; i++) {
if (scope.scm_type_options[i].value == data.scm_type) {
scope.scm_type = scope.scm_type_options[i];
break;
} }
} else {
scope.pathRequired = false; if (data[fld]) {
} scope[fld] = data[fld];
else { master[fld] = data[fld];
scope.pathRequired = true; }
} }
if (fld !== 'organization' && form.fields[fld].sourceModel &&
data.summary_fields && data.summary_fields[form.fields[fld].sourceModel]) {
scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
}
}
var related = data.related;
for (var set in form.related) {
if (related[set]) {
relatedSets[set] = { url: related[set], iterator: form.related[set].iterator };
}
}
if (data.scm_type !== "") {
for (var i=0; i < scope.scm_type_options.length; i++) {
if (scope.scm_type_options[i].value == data.scm_type) {
scope.scm_type = scope.scm_type_options[i];
break;
}
}
scope.pathRequired = false;
}
else {
scope.pathRequired = true;
}
master['scm_type'] = scope['scm_type'];
master['auth_required'] = scope['auth_required'];
scope.scmBranchLabel = (scope.scm_type && scope.scm_type.value && scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch';
setAskCheckboxes();
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
scope.$emit('projectLoaded');
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to retrieve project: ' + id + '. GET status: ' + status });
});
});
// Load the list of options for Kind
GetChoices({
scope: scope,
url: defaultUrl,
field: 'scm_type',
variable: 'scm_type_options',
callback: 'choicesReady'
});
master['scm_type'] = scope['scm_type'];
master['auth_required'] = scope['auth_required'];
scope.scmBranchLabel = (scope.scm_type && scope.scm_type.value && scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch';
setAskCheckboxes();
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
scope.$emit('projectLoaded');
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, form,
{ hdr: 'Error!', msg: 'Failed to retrieve project: ' + id + '. GET status: ' + status });
});
// Save changes to the parent // Save changes to the parent
scope.formSave = function() { scope.formSave = function() {
generator.clearApiErrors(); generator.clearApiErrors();
@@ -590,5 +641,5 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
ProjectsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm', ProjectsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm',
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit',
'RelatedPaginateInit', 'Prompt', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'RelatedPaginateInit', 'Prompt', 'ClearScope', 'GetBasePath', 'ReturnToCaller',
'GetProjectPath', 'Authorization' 'GetProjectPath', 'Authorization', 'CredentialList', 'LookUpInit', 'GetChoices'
]; ];

View File

@@ -52,9 +52,8 @@ angular.module('ProjectFormDefinition', [])
type: 'select', type: 'select',
ngOptions: 'type.label for type in scm_type_options', ngOptions: 'type.label for type in scm_type_options',
ngChange: 'scmChange()', ngChange: 'scmChange()',
defaultOption: 'Manual', addRequired: true,
addRequired: false, editRequired: true
editRequired: false
}, },
missing_path_alert: { missing_path_alert: {
type: 'alertblock', type: 'alertblock',
@@ -71,7 +70,7 @@ angular.module('ProjectFormDefinition', [])
type: 'textarea', type: 'textarea',
"class": 'col-lg-6', "class": 'col-lg-6',
showonly: true, showonly: true,
ngShow: "scm_type == '' || scm_type == null", ngShow: "scm_type.value == ''",
awPopOver: '<p>Base path used for locating playbooks. Directories found inside this path will be listed in the playbook directory drop-down. ' + awPopOver: '<p>Base path used for locating playbooks. Directories found inside this path will be listed in the playbook directory drop-down. ' +
'Together the base path and selected playbook directory provide the full path used to locate playbooks.</p>' + 'Together the base path and selected playbook directory provide the full path used to locate playbooks.</p>' +
'<p>Use PROJECTS_ROOT in your environment settings file to determine the base path value.</p>', '<p>Use PROJECTS_ROOT in your environment settings file to determine the base path value.</p>',
@@ -85,7 +84,7 @@ angular.module('ProjectFormDefinition', [])
id: 'local-path-select', id: 'local-path-select',
ngOptions: 'path for path in project_local_paths', ngOptions: 'path for path in project_local_paths',
awRequiredWhen: { variable: "pathRequired", init: "true" }, awRequiredWhen: { variable: "pathRequired", init: "true" },
ngShow: "scm_type == '' || scm_type == null", ngShow: "scm_type.value == ''",
awPopOver: '<p>Select from the list of directories found in the base path.' + awPopOver: '<p>Select from the list of directories found in the base path.' +
'Together the base path and the playbook directory provide the full path used to locate playbooks.</p>' + 'Together the base path and the playbook directory provide the full path used to locate playbooks.</p>' +
'<p>Use PROJECTS_ROOT in your environment settings file to determine the base path value.</p>', '<p>Use PROJECTS_ROOT in your environment settings file to determine the base path value.</p>',
@@ -96,7 +95,7 @@ angular.module('ProjectFormDefinition', [])
scm_url: { scm_url: {
label: 'SCM URL', label: 'SCM URL',
type: 'text', type: 'text',
ngShow: "scm_type !== '' && scm_type !== null", ngShow: "scm_type.value !== ''",
awRequiredWhen: { variable: "scm_type", init: "true" }, awRequiredWhen: { variable: "scm_type", init: "true" },
helpCollapse: [ helpCollapse: [
{ hdr: 'GIT URLs', { hdr: 'GIT URLs',
@@ -124,86 +123,20 @@ angular.module('ProjectFormDefinition', [])
scm_branch: { scm_branch: {
labelBind: "scmBranchLabel", labelBind: "scmBranchLabel",
type: 'text', type: 'text',
ngShow: "scm_type !== '' && scm_type !== null", ngShow: "scm_type.value !== ''",
addRequired: false, addRequired: false,
editRequired: false editRequired: false
}, },
credential: { // FIXME: Lookup doesn't work yet! credential: {
label: 'SCM Credential', label: 'SCM Credential',
type: 'lookup', type: 'lookup',
ngShow: "scm_type.value !== ''",
sourceModel: 'credential', sourceModel: 'credential',
sourceField: 'name', sourceField: 'name',
ngClick: 'lookUpCredential()', ngClick: 'lookUpCredential()',
addRequired: false, addRequired: false,
editRequired: false, editRequired: false,
}, },
/*auth_required: {
label: 'Authorization required?',
type: 'checkbox',
ngShow: "scm_type !== '' && scm_type !== null",
addRequired: false,
editRequired: false,
ngChange: 'authChange()'
},
scm_username: {
label: 'SCM Username',
type: 'text',
ngShow: "scm_type !== '' && scm_type !== null && auth_required",
addRequired: false,
editRequired: false
},
"scm_password": {
label: 'SCM Password',
type: 'password',
ngShow: "scm_type !== '' && scm_type !== null && auth_required",
addRequired: false,
editRequired: false,
ngChange: "clearPWConfirm('scm_password_confirm')",
ask: true,
clear: true,
associated: 'scm_password_confirm',
autocomplete: false
},
"scm_password_confirm": {
label: 'Confirm SCM Password',
type: 'password',
ngShow: "scm_type !== '' && scm_type !== null && auth_required",
addRequired: false,
editRequired: false,
awPassMatch: true,
associated: 'scm_password',
autocomplete: false
},
"scm_key_data": {
label: 'SCM Private Key',
type: 'textarea',
ngShow: "scm_type !== '' && scm_type !== null && auth_required",
xtraWide: true,
addRequired: false,
editRequired: false,
'class': 'ssh-key-field',
rows: 10
},
"scm_key_unlock": {
label: 'SCM Key Password',
type: 'password',
ngShow: "scm_type !== '' && scm_type !== null && scm_key_data && auth_required",
addRequired: false,
editRequired: false,
ngChange: "clearPWConfirm('scm_key_unlock_confirm')",
associated: 'scm_key_unlock_confirm',
ask: true,
clear: true
},
"scm_key_unlock_confirm": {
label: 'Confirm SCM Key Password',
type: 'password',
ngShow: "scm_type !== '' && scm_type !== null && scm_key_data && auth_required",
addRequired: false,
editRequired: false,
awPassMatch: true,
associated: 'scm_key_unlock'
},*/
checkbox_group: { checkbox_group: {
label: 'SCM Options', label: 'SCM Options',
type: 'checkbox_group', type: 'checkbox_group',
@@ -214,7 +147,7 @@ angular.module('ProjectFormDefinition', [])
name: 'scm_clean', name: 'scm_clean',
label: 'Clean', label: 'Clean',
type: 'checkbox', type: 'checkbox',
ngShow: "scm_type !== '' && scm_type !== null", ngShow: "scm_type.value !== ''",
addRequired: false, addRequired: false,
editRequired: false, editRequired: false,
awPopOver: '<p>Remove any local modifications prior to performing an update.</p>', awPopOver: '<p>Remove any local modifications prior to performing an update.</p>',
@@ -227,7 +160,7 @@ angular.module('ProjectFormDefinition', [])
name: 'scm_delete_on_update', name: 'scm_delete_on_update',
label: 'Delete on Update', label: 'Delete on Update',
type: 'checkbox', type: 'checkbox',
ngShow: "scm_type !== '' && scm_type !== null", ngShow: "scm_type.value !== ''",
addRequired: false, addRequired: false,
editRequired: false, editRequired: false,
awPopOver: '<p>Delete the local repository in its entirety prior to performing an update.</p><p>Depending on the size of the ' + awPopOver: '<p>Delete the local repository in its entirety prior to performing an update.</p><p>Depending on the size of the ' +
@@ -241,7 +174,7 @@ angular.module('ProjectFormDefinition', [])
name: 'scm_update_on_launch', name: 'scm_update_on_launch',
label: 'Update on Launch', label: 'Update on Launch',
type: 'checkbox', type: 'checkbox',
ngShow: "scm_type !== '' && scm_type !== null", ngShow: "scm_type.value !== ''",
addRequired: false, addRequired: false,
editRequired: false, editRequired: false,
awPopOver: '<p>Each time a job runs using this project, perform an update to the local repository prior to starting the job.</p>', awPopOver: '<p>Each time a job runs using this project, perform an update to the local repository prior to starting the job.</p>',

View File

@@ -781,6 +781,14 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', '
scope[fld] = data[fld]; scope[fld] = data[fld];
master[fld] = scope[fld]; master[fld] = scope[fld];
} }
if (form.fields[fld].sourceModel && data.summary_fields &&
data.summary_fields[form.fields[fld].sourceModel]) {
scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
master[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField] =
data.summary_fields[form.fields[fld].sourceModel][form.fields[fld].sourceField];
}
} }
LookUpInit({ LookUpInit({