mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 22:37:41 -02:30
Project base path now displayed on Project detail page. Project path (the subdir under base path) is now selected from a drop-down. Using /api/v1/config to determine base path and drop-down values. Added help text pop-overs that should eliminate confussion around how to setup project directory structure.
This commit is contained in:
@@ -54,7 +54,8 @@ angular.module('ansible', [
|
|||||||
'HostsHelper',
|
'HostsHelper',
|
||||||
'ParseHelper',
|
'ParseHelper',
|
||||||
'ChildrenHelper',
|
'ChildrenHelper',
|
||||||
'EventsHelper'
|
'EventsHelper',
|
||||||
|
'ProjectPathHelper'
|
||||||
])
|
])
|
||||||
.config(['$routeProvider', function($routeProvider) {
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
$routeProvider.
|
$routeProvider.
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ 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)
|
GetBasePath, ReturnToCaller, GetProjectPath)
|
||||||
{
|
{
|
||||||
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.
|
||||||
@@ -165,9 +165,11 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
var defaultUrl = GetBasePath('projects');
|
var defaultUrl = GetBasePath('projects');
|
||||||
var scope = generator.inject(form, {mode: 'add', related: false});
|
var scope = generator.inject(form, {mode: 'add', related: false});
|
||||||
var id = $routeParams.id;
|
var id = $routeParams.id;
|
||||||
|
var master = {};
|
||||||
|
|
||||||
generator.reset();
|
generator.reset();
|
||||||
|
|
||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
|
GetProjectPath({ scope: scope, master: master });
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function() {
|
scope.formSave = function() {
|
||||||
@@ -190,19 +192,22 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function() {
|
scope.formReset = function() {
|
||||||
$rootScope.flashMessage = null;
|
$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',
|
ProjectsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
||||||
'ReturnToCaller'
|
'ReturnToCaller', 'GetProjectPath'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
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)
|
RelatedPaginateInit, Prompt, ClearScope, GetBasePath, ReturnToCaller, GetProjectPath)
|
||||||
{
|
{
|
||||||
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.
|
||||||
@@ -218,6 +223,9 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
var master = {};
|
var master = {};
|
||||||
var id = $routeParams.id;
|
var id = $routeParams.id;
|
||||||
var relatedSets = {};
|
var relatedSets = {};
|
||||||
|
|
||||||
|
scope.project_local_paths = [];
|
||||||
|
scope.base_dir = '';
|
||||||
|
|
||||||
// After the project is loaded, retrieve each related set
|
// After the project is loaded, retrieve each related set
|
||||||
if (scope.projectLoadedRemove) {
|
if (scope.projectLoadedRemove) {
|
||||||
@@ -227,6 +235,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
for (var set in relatedSets) {
|
for (var set in relatedSets) {
|
||||||
scope.search(relatedSets[set].iterator);
|
scope.search(relatedSets[set].iterator);
|
||||||
}
|
}
|
||||||
|
GetProjectPath({ scope: scope, master: master });
|
||||||
});
|
});
|
||||||
|
|
||||||
// Retrieve detail record and prepopulate the form
|
// Retrieve detail record and prepopulate the form
|
||||||
@@ -276,7 +285,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
|
|
||||||
// Reset the form
|
// Reset the form
|
||||||
scope.formReset = function() {
|
scope.formReset = function() {
|
||||||
form.reset();
|
generator.reset();
|
||||||
for (var fld in master) {
|
for (var fld in master) {
|
||||||
scope[fld] = master[fld];
|
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',
|
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'
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -30,11 +30,29 @@ angular.module('ProjectFormDefinition', [])
|
|||||||
addRequired: false,
|
addRequired: false,
|
||||||
editRequired: false
|
editRequired: false
|
||||||
},
|
},
|
||||||
|
base_dir: {
|
||||||
|
label: 'Project Base Path',
|
||||||
|
type: 'textarea',
|
||||||
|
"class": 'span6',
|
||||||
|
showonly: true,
|
||||||
|
awPopOver: '<p>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.</p>' +
|
||||||
|
'<p>Use PROJECTS_ROOT in your environment settings file to determine the base path value.</p>',
|
||||||
|
dataTitle: 'Project Base Path',
|
||||||
|
dataPlacement: 'right'
|
||||||
|
},
|
||||||
local_path: {
|
local_path: {
|
||||||
label: 'Local Path',
|
label: 'Project Path',
|
||||||
type: 'text',
|
type: 'select',
|
||||||
|
id: 'local-path-select',
|
||||||
|
ngOptions: 'path for path in project_local_paths',
|
||||||
addRequired: true,
|
addRequired: true,
|
||||||
editRequired: true
|
editRequired: true,
|
||||||
|
awPopOver: '<p>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.</p>' +
|
||||||
|
'<p>Use PROJECTS_ROOT in your environment settings file to determine the base path value.</p>',
|
||||||
|
dataTitle: 'Project Path',
|
||||||
|
dataPlacement: 'right'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
37
ansibleworks/ui/static/js/helpers/ProjectPath.js
Normal file
37
ansibleworks/ui/static/js/helpers/ProjectPath.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/*********************************************
|
||||||
|
* Copyright (c) 2013 AnsibleWorks, Inc.
|
||||||
|
*
|
||||||
|
* ProjectPathHelper
|
||||||
|
*
|
||||||
|
* Use GetProjectPath({ scope: <scope>, master: <master obj> }) to
|
||||||
|
* load scope.project_local_paths (array of options for drop-down) and
|
||||||
|
* scope.base_dir (readonly field).
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
angular.module('ProjectPathHelper', ['RestServices', 'Utilities'])
|
||||||
|
.factory('GetProjectPath', ['Alert', 'Rest', 'GetBasePath','ProcessErrors',
|
||||||
|
function(Alert, Rest, GetBasePath, ProcessErrors) {
|
||||||
|
return function(params) {
|
||||||
|
|
||||||
|
var scope = params.scope;
|
||||||
|
var master = params.master;
|
||||||
|
|
||||||
|
Rest.setUrl( GetBasePath('config') );
|
||||||
|
Rest.get()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
var opts = [];
|
||||||
|
for (var i=0; i < data.project_local_paths.length; i++) {
|
||||||
|
opts.push(data.project_local_paths[i]);
|
||||||
|
}
|
||||||
|
scope.project_local_paths = opts;
|
||||||
|
scope.base_dir = data.project_base_dir;
|
||||||
|
master.base_dir = scope.base_dir; // Keep in master object so that it doesn't get
|
||||||
|
// wiped out on form reset.
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, null,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to access API config. GET status: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}]);
|
||||||
@@ -165,7 +165,7 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
|||||||
html += (field.placeholder) ? this.attr(field,'placeholder') : "";
|
html += (field.placeholder) ? this.attr(field,'placeholder') : "";
|
||||||
html += (options.mode == 'edit' && field.editRequired) ? "required " : "";
|
html += (options.mode == 'edit' && field.editRequired) ? "required " : "";
|
||||||
html += (options.mode == 'add' && field.addRequired) ? "required " : "";
|
html += (options.mode == 'add' && field.addRequired) ? "required " : "";
|
||||||
html += (field.readonly) ? "readonly " : "";
|
html += (field.readonly || field.showonly) ? "readonly " : "";
|
||||||
html += (field.awPassMatch) ? "awpassmatch=\"" + field.associated + "\" " : "";
|
html += (field.awPassMatch) ? "awpassmatch=\"" + field.associated + "\" " : "";
|
||||||
html += (field.capitalize) ? "capitalize " : "";
|
html += (field.capitalize) ? "capitalize " : "";
|
||||||
html += (field.ask) ? "ng-disabled=\"" + fld + "_ask\" " : "";
|
html += (field.ask) ? "ng-disabled=\"" + fld + "_ask\" " : "";
|
||||||
@@ -230,7 +230,7 @@ angular.module('FormGenerator', ['GeneratorHelpers'])
|
|||||||
html += (field.placeholder) ? this.attr(field,'placeholder') : "";
|
html += (field.placeholder) ? this.attr(field,'placeholder') : "";
|
||||||
html += (options.mode == 'edit' && field.editRequired) ? "required " : "";
|
html += (options.mode == 'edit' && field.editRequired) ? "required " : "";
|
||||||
html += (options.mode == 'add' && field.addRequired) ? "required " : "";
|
html += (options.mode == 'add' && field.addRequired) ? "required " : "";
|
||||||
html += (field.readonly) ? "readonly " : "";
|
html += (field.readonly || field.showonly) ? "readonly " : "";
|
||||||
html += "></textarea><br />\n";
|
html += "></textarea><br />\n";
|
||||||
// Add error messages
|
// Add error messages
|
||||||
if ( (options.mode == 'add' && field.addRequired) || (options.mode == 'edit' && field.editRequired) ) {
|
if ( (options.mode == 'add' && field.addRequired) || (options.mode == 'edit' && field.editRequired) ) {
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
<script src="{{ STATIC_URL }}js/helpers/Parse.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/Parse.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/Events.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/Events.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/Children.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/Children.js"></script>
|
||||||
|
<script src="{{ STATIC_URL }}js/helpers/ProjectPath.js"></script>
|
||||||
<script src="{{ STATIC_URL }}lib/ansible/directives.js"></script>
|
<script src="{{ STATIC_URL }}lib/ansible/directives.js"></script>
|
||||||
<script src="{{ STATIC_URL }}lib/ansible/filters.js"></script>
|
<script src="{{ STATIC_URL }}lib/ansible/filters.js"></script>
|
||||||
<script src="{{ STATIC_URL }}lib/ansible/api-loader.js"></script>
|
<script src="{{ STATIC_URL }}lib/ansible/api-loader.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user