diff --git a/ansibleworks/ui/static/js/app.js b/ansibleworks/ui/static/js/app.js index 7fdb38ab33..f4d1a1078a 100644 --- a/ansibleworks/ui/static/js/app.js +++ b/ansibleworks/ui/static/js/app.js @@ -54,7 +54,8 @@ angular.module('ansible', [ 'HostsHelper', 'ParseHelper', 'ChildrenHelper', - 'EventsHelper' + 'EventsHelper', + 'ProjectPathHelper' ]) .config(['$routeProvider', function($routeProvider) { $routeProvider. diff --git a/ansibleworks/ui/static/js/controllers/Projects.js b/ansibleworks/ui/static/js/controllers/Projects.js index 4b50f32263..7ca5f3f343 100644 --- a/ansibleworks/ui/static/js/controllers/Projects.js +++ b/ansibleworks/ui/static/js/controllers/Projects.js @@ -153,7 +153,7 @@ ProjectsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routePar function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, - GetBasePath, ReturnToCaller) + GetBasePath, ReturnToCaller, GetProjectPath) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -165,9 +165,11 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam var defaultUrl = GetBasePath('projects'); var scope = generator.inject(form, {mode: 'add', related: false}); var id = $routeParams.id; + var master = {}; + generator.reset(); - LoadBreadCrumbs(); + GetProjectPath({ scope: scope, master: master }); // Save scope.formSave = function() { @@ -190,19 +192,22 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam // Cancel scope.formReset = function() { $rootScope.flashMessage = null; - form.reset(); + generator.reset(); + for (var fld in master) { + scope[fld] = master[fld]; + } }; } ProjectsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', - 'ReturnToCaller' + 'ReturnToCaller', 'GetProjectPath' ]; function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, - RelatedPaginateInit, Prompt, ClearScope, GetBasePath, ReturnToCaller) + RelatedPaginateInit, Prompt, ClearScope, GetBasePath, ReturnToCaller, GetProjectPath) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -218,6 +223,9 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara var master = {}; var id = $routeParams.id; var relatedSets = {}; + + scope.project_local_paths = []; + scope.base_dir = ''; // After the project is loaded, retrieve each related set if (scope.projectLoadedRemove) { @@ -227,6 +235,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara for (var set in relatedSets) { scope.search(relatedSets[set].iterator); } + GetProjectPath({ scope: scope, master: master }); }); // Retrieve detail record and prepopulate the form @@ -276,7 +285,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara // Reset the form scope.formReset = function() { - form.reset(); + generator.reset(); for (var fld in master) { scope[fld] = master[fld]; } @@ -319,5 +328,6 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara ProjectsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', - 'RelatedPaginateInit', 'Prompt', 'ClearScope', 'GetBasePath', 'ReturnToCaller' + 'RelatedPaginateInit', 'Prompt', 'ClearScope', 'GetBasePath', 'ReturnToCaller', + 'GetProjectPath' ]; diff --git a/ansibleworks/ui/static/js/forms/Projects.js b/ansibleworks/ui/static/js/forms/Projects.js index a55d94f2ff..6e8487299e 100644 --- a/ansibleworks/ui/static/js/forms/Projects.js +++ b/ansibleworks/ui/static/js/forms/Projects.js @@ -30,11 +30,29 @@ angular.module('ProjectFormDefinition', []) addRequired: false, editRequired: false }, + base_dir: { + label: 'Project Base Path', + type: 'textarea', + "class": 'span6', + showonly: true, + awPopOver: '
Base path used for locating playbooks. Directories found inside this path will be listed in the Project Path drop-down. ' + + 'Together the base path and selected project path provide the full path used to locate playbooks for this project.
' + + 'Use PROJECTS_ROOT in your environment settings file to determine the base path value.
', + dataTitle: 'Project Base Path', + dataPlacement: 'right' + }, local_path: { - label: 'Local Path', - type: 'text', + label: 'Project Path', + type: 'select', + id: 'local-path-select', + ngOptions: 'path for path in project_local_paths', addRequired: true, - editRequired: true + editRequired: true, + awPopOver: 'Select from the list of directories found in the base path.' + + 'Together the base path and selected project path provide the full path used to locate playbooks for this project.
' + + 'Use PROJECTS_ROOT in your environment settings file to determine the base path value.
', + dataTitle: 'Project Path', + dataPlacement: 'right' } }, diff --git a/ansibleworks/ui/static/js/helpers/ProjectPath.js b/ansibleworks/ui/static/js/helpers/ProjectPath.js new file mode 100644 index 0000000000..f052f2d4d7 --- /dev/null +++ b/ansibleworks/ui/static/js/helpers/ProjectPath.js @@ -0,0 +1,37 @@ +/********************************************* + * Copyright (c) 2013 AnsibleWorks, Inc. + * + * ProjectPathHelper + * + * Use GetProjectPath({ scope: