diff --git a/lib/ui/static/css/ansible-ui.css b/lib/ui/static/css/ansible-ui.css index 8700722dbb..8781f49ddc 100644 --- a/lib/ui/static/css/ansible-ui.css +++ b/lib/ui/static/css/ansible-ui.css @@ -233,6 +233,7 @@ padding: 0; } + /* Display list actions next to search widget */ .search-widget { display: inline-block; } @@ -243,3 +244,8 @@ margin-left: 15px; margin-top: 3px; } + /* Display list actions */ + + .well { + padding-bottom: 0; + } \ No newline at end of file diff --git a/lib/ui/static/js/controllers/JobTemplates.js b/lib/ui/static/js/controllers/JobTemplates.js index 27d0ff775b..f7a086f47f 100644 --- a/lib/ui/static/js/controllers/JobTemplates.js +++ b/lib/ui/static/js/controllers/JobTemplates.js @@ -341,59 +341,61 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route var id = $routeParams.id; var relatedSets = {}; - function getPlaybooks() { - var url = GetBasePath('projects') + scope.project + '/playbooks/'; - Rest.setUrl(url); - Rest.get() - .success( function(data, status, headers, config) { - var opts = []; - for (var i=0; i < data.length; i++) { - opts.push({ label: data[i], value: data[i] }); - } - scope.playbook_options = opts; - }) - .error( function(data, status, headers, config) { - ProcessErrors(scope, data, status, form, - { hdr: 'Error!', msg: 'Failed to get playbook list for ' + url +'. GET returned status: ' + status }); - }); + + function getPlaybooks(project) { + if (project !== null && project !== '' && project !== undefined) { + var url = GetBasePath('projects') + project + '/playbooks/'; + Rest.setUrl(url); + Rest.get() + .success( function(data, status, headers, config) { + scope.playbook_options = []; + for (var i=0; i < data.length; i++) { + scope.playbook_options.push(data[i]); + } + }) + .error( function(data, status, headers, config) { + ProcessErrors(scope, data, status, form, + { hdr: 'Error!', msg: 'Failed to get playbook list for ' + url +'. GET returned status: ' + status }); + }); + } } - // Update playbook select whenever project value changes - var selectPlaybook = function(oldValue, newValue) { - if (oldValue != newValue && scope.project) { - getPlaybooks(); - } - }; - - // Register a watcher on project_name + // Register a watcher on project_name. Refresh the playbook list on change. if (scope.selectPlaybookUnregister) { scope.selectPlaybookUnregister(); } - scope.selectPlaybookUnregister = scope.$watch('project_name', selectPlaybook); + scope.selectPlaybookUnregister = scope.$watch('project_name', function(oldValue, newValue) { + if (oldValue !== newValue && newValue !== '' && newValue !== null && newValue !== undefined) { + scope.playbook = null; + getPlaybooks(scope.project); + } + }); - // Retrieve each related set + // Retrieve each related set and populate the playbook list if (scope.jobTemplateLoadedRemove) { scope.jobTemplateLoadedRemove(); } scope.jobTemplateLoadedRemove = scope.$on('jobTemplateLoaded', function() { for (var set in relatedSets) { scope.search(relatedSets[set].iterator); - } - getPlaybooks(); + } + getPlaybooks(scope.project); }); + // Our job type options scope.job_type_options = [{ value: 'run', label: 'Run' }, { value: 'check', label: 'Check' }]; - + scope.playbook_options = null; + scope.playbook = null; + // Retrieve detail record and prepopulate the form Rest.setUrl(defaultUrl + ':id/'); Rest.get({ params: {id: id} }) .success( function(data, status, headers, config) { LoadBreadCrumbs({ path: '/job_templates/' + id, title: data.name }); for (var fld in form.fields) { - if (data[fld] !== null && data[fld] !== undefined) { - + if (data[fld] !== null && data[fld] !== undefined) { if (form.fields[fld].type == 'select') { - if (scope[fld + '_options']) { + if (scope[fld + '_options'] && scope[fld + '_options'].length > 0) { for (var i=0; i < scope[fld + '_options'].length; i++) { if (data[fld] == scope[fld + '_options'][i].value) { scope[fld] = scope[fld + '_options'][i]; @@ -401,7 +403,7 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route } } else { - scope[fld] = { label: data[fld], value: data[fld] }; + scope[fld] = data[fld]; } } else { @@ -416,7 +418,7 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField]; } } - + scope.url = data.url; var related = data.related; for (var set in form.related) { if (related[set]) { @@ -463,7 +465,7 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route Rest.setUrl(defaultUrl + $routeParams.id); var data = {} for (var fld in form.fields) { - if (form.fields[fld].type == 'select') { + if (form.fields[fld].type == 'select' && fld != 'playbook') { data[fld] = scope[fld].value; } else { diff --git a/lib/ui/static/js/forms/Credentials.js b/lib/ui/static/js/forms/Credentials.js index 41971ff7da..0e50e762a6 100644 --- a/lib/ui/static/js/forms/Credentials.js +++ b/lib/ui/static/js/forms/Credentials.js @@ -125,7 +125,7 @@ angular.module('CredentialFormDefinition', []) save: { label: 'Save', icon: 'icon-ok', - class: 'btn btn-success', + class: 'btn-success', ngClick: 'formSave()', //$scope.function to call on click, optional ngDisabled: true //Disable when $pristine or $invalid, optional }, @@ -133,7 +133,6 @@ angular.module('CredentialFormDefinition', []) ngClick: 'formReset()', label: 'Reset', icon: 'icon-remove', - class: 'btn', ngDisabled: true //Disabled when $pristine } }, diff --git a/lib/ui/static/js/forms/Groups.js b/lib/ui/static/js/forms/Groups.js index 7ab1070aae..28258a6887 100644 --- a/lib/ui/static/js/forms/Groups.js +++ b/lib/ui/static/js/forms/Groups.js @@ -49,7 +49,6 @@ angular.module('GroupFormDefinition', []) ngClick: 'formReset()', label: 'Reset', icon: 'icon-remove', - class: 'btn', ngDisabled: true //Disabled when $pristine } }, diff --git a/lib/ui/static/js/forms/Hosts.js b/lib/ui/static/js/forms/Hosts.js index f303a1e08e..40acbe5b7d 100644 --- a/lib/ui/static/js/forms/Hosts.js +++ b/lib/ui/static/js/forms/Hosts.js @@ -48,7 +48,7 @@ angular.module('HostFormDefinition', []) save: { label: 'Save', icon: 'icon-ok', - class: 'btn btn-success', + class: 'btn-success', ngClick: 'formSave()', //$scope.function to call on click, optional ngDisabled: true //Disable when $pristine or $invalid, optional }, @@ -56,7 +56,6 @@ angular.module('HostFormDefinition', []) ngClick: 'formReset()', label: 'Reset', icon: 'icon-remove', - class: 'btn', ngDisabled: true //Disabled when $pristine } }, diff --git a/lib/ui/static/js/forms/Inventories.js b/lib/ui/static/js/forms/Inventories.js index f9e55f7a38..da00856d09 100644 --- a/lib/ui/static/js/forms/Inventories.js +++ b/lib/ui/static/js/forms/Inventories.js @@ -44,7 +44,7 @@ angular.module('InventoryFormDefinition', []) save: { label: 'Save', icon: 'icon-ok', - class: 'btn btn-success', + class: 'btn-success', ngClick: 'formSave()', //$scope.function to call on click, optional ngDisabled: true //Disable when $pristine or $invalid, optional }, @@ -52,7 +52,6 @@ angular.module('InventoryFormDefinition', []) ngClick: 'formReset()', label: 'Reset', icon: 'icon-remove', - class: 'btn', ngDisabled: true //Disabled when $pristine } }, diff --git a/lib/ui/static/js/forms/JobTemplates.js b/lib/ui/static/js/forms/JobTemplates.js index 2c4f9a9576..27227daf2f 100644 --- a/lib/ui/static/js/forms/JobTemplates.js +++ b/lib/ui/static/js/forms/JobTemplates.js @@ -31,6 +31,7 @@ angular.module('JobTemplateFormDefinition', []) job_type: { label: 'Job Type', type: 'select', + ngOptions: 'type.label for type in job_type_options', default: 'run', addRequired: true, editRequired: true @@ -56,6 +57,7 @@ angular.module('JobTemplateFormDefinition', []) playbook: { label: 'Playbook', type:'select', + ngOptions: 'book for book in playbook_options', id: 'playbook-select', addRequired: true, editRequired: true @@ -98,7 +100,8 @@ angular.module('JobTemplateFormDefinition', []) extra_vars: { label: 'Extra Variables', type: 'textarea', - rows: 10, + rows: 6, + class: 'span4', addRequired: false, editRequired: false } @@ -108,7 +111,7 @@ angular.module('JobTemplateFormDefinition', []) save: { label: 'Save', icon: 'icon-ok', - class: 'btn btn-success', + class: 'btn-success', ngClick: 'formSave()', //$scope.function to call on click, optional ngDisabled: true //Disable when $pristine or $invalid, optional }, @@ -116,7 +119,6 @@ angular.module('JobTemplateFormDefinition', []) ngClick: 'formReset()', label: 'Reset', icon: 'icon-remove', - class: 'btn', ngDisabled: true //Disabled when $pristine } }, diff --git a/lib/ui/static/js/forms/Organizations.js b/lib/ui/static/js/forms/Organizations.js index e9fc0a97ce..407f1e8ec4 100644 --- a/lib/ui/static/js/forms/Organizations.js +++ b/lib/ui/static/js/forms/Organizations.js @@ -35,7 +35,7 @@ angular.module('OrganizationFormDefinition', []) save: { label: 'Save', icon: 'icon-ok', - class: 'btn btn-success', + class: 'btn-success', ngClick: 'formSave()', //$scope.function to call on click, optional ngDisabled: true //Disable when $pristine or $invalid, optional }, @@ -43,7 +43,6 @@ angular.module('OrganizationFormDefinition', []) ngClick: 'formReset()', label: 'Reset', icon: 'icon-remove', - class: 'btn', ngDisabled: true //Disabled when $pristine } }, diff --git a/lib/ui/static/js/forms/Teams.js b/lib/ui/static/js/forms/Teams.js index 3bb2208ce7..d053635cb9 100644 --- a/lib/ui/static/js/forms/Teams.js +++ b/lib/ui/static/js/forms/Teams.js @@ -44,7 +44,7 @@ angular.module('TeamFormDefinition', []) save: { label: 'Save', icon: 'icon-ok', - class: 'btn btn-success', + class: 'btn-success', ngClick: 'formSave()', //$scope.function to call on click, optional ngDisabled: true //Disable when $pristine or $invalid, optional }, @@ -52,7 +52,6 @@ angular.module('TeamFormDefinition', []) ngClick: 'formReset()', label: 'Reset', icon: 'icon-remove', - class: 'btn', ngDisabled: true //Disabled when $pristine } }, diff --git a/lib/ui/static/js/forms/Users.js b/lib/ui/static/js/forms/Users.js index bebe4027c8..7549665995 100644 --- a/lib/ui/static/js/forms/Users.js +++ b/lib/ui/static/js/forms/Users.js @@ -71,7 +71,7 @@ angular.module('UserFormDefinition', []) save: { label: 'Save', icon: 'icon-ok', - class: 'btn btn-success', + class: 'btn-success', ngClick: 'formSave()', //$scope.function to call on click, optional ngDisabled: true //Disable when $pristine or $invalid, optional }, @@ -79,7 +79,6 @@ angular.module('UserFormDefinition', []) ngClick: 'formReset()', label: 'Reset', icon: 'icon-remove', - class: 'btn', ngDisabled: true //Disabled when $pristine } }, diff --git a/lib/ui/static/js/lists/Credentials.js b/lib/ui/static/js/lists/Credentials.js index a0980fc58e..ff3f227990 100644 --- a/lib/ui/static/js/lists/Credentials.js +++ b/lib/ui/static/js/lists/Credentials.js @@ -14,7 +14,7 @@ angular.module('CredentialsListDefinition', []) iterator: 'credential', selectTitle: 'Add Credentials', editTitle: 'Credentials', - selectInstructions: 'Check the Select checkbox next to each user to be added, and click Finished when done. Use the green button to create a new user.', + selectInstructions: 'Click on a row to select it, and click Finished when done. Use the green button to create a new row.', fields: { name: { diff --git a/lib/ui/static/js/lists/JobTemplates.js b/lib/ui/static/js/lists/JobTemplates.js index 1c30d4d498..304a04b611 100644 --- a/lib/ui/static/js/lists/JobTemplates.js +++ b/lib/ui/static/js/lists/JobTemplates.js @@ -14,7 +14,7 @@ angular.module('JobTemplatesListDefinition', []) iterator: 'job_template', selectTitle: 'Add Job Template', editTitle: 'Job Templates', - selectInstructions: 'Check the Select checkbox next to each template to be added, and click Finished when done. Use the green button to create a new template.', + selectInstructions: 'Click on a row to select it, and click Finished when done. Use the green button to create a new row.', fields: { name: { diff --git a/lib/ui/static/js/lists/Teams.js b/lib/ui/static/js/lists/Teams.js index 6fe15044af..c998c4d8a9 100644 --- a/lib/ui/static/js/lists/Teams.js +++ b/lib/ui/static/js/lists/Teams.js @@ -14,7 +14,7 @@ angular.module('TeamsListDefinition', []) iterator: 'team', selectTitle: 'Add Team', editTitle: 'Teams', - selectInstructions: 'Check the Select checkbox next to each team to be added, and click Finished when done. Use the green button to create a new team.', + selectInstructions: 'Click on a row to select it, and click Finished when done. Use the green button to create a new row.', fields: { name: { diff --git a/lib/ui/static/lib/ansible/form-generator.js b/lib/ui/static/lib/ansible/form-generator.js index 1e83589617..67e81300a2 100644 --- a/lib/ui/static/lib/ansible/form-generator.js +++ b/lib/ui/static/lib/ansible/form-generator.js @@ -22,6 +22,9 @@ angular.module('FormGenerator', ['GeneratorHelpers']) case 'ngClick': result = "ng-click=\"" + obj[key] + "\" "; break; + case 'ngOptions': + result = "ng-options=\"" + obj[key] + "\" "; + break; case 'ngChange': result = "ng-change=\"" + obj[key] + "\" "; break; @@ -239,9 +242,10 @@ angular.module('FormGenerator', ['GeneratorHelpers']) html += "' + "\n"; html += "