mirror of
https://github.com/ansible/awx.git
synced 2026-03-26 21:35:01 -02:30
AC-351 Latest changes.
This commit is contained in:
@@ -44,7 +44,7 @@ angular.module('ansible', [
|
|||||||
'LookUpHelper',
|
'LookUpHelper',
|
||||||
'JobTemplatesListDefinition',
|
'JobTemplatesListDefinition',
|
||||||
'JobTemplateFormDefinition',
|
'JobTemplateFormDefinition',
|
||||||
'JobTemplateHelper',
|
'JobSubmissionHelper',
|
||||||
'ProjectsListDefinition',
|
'ProjectsListDefinition',
|
||||||
'ProjectFormDefinition',
|
'ProjectFormDefinition',
|
||||||
'PermissionFormDefinition',
|
'PermissionFormDefinition',
|
||||||
@@ -65,8 +65,7 @@ angular.module('ansible', [
|
|||||||
'SelectionHelper',
|
'SelectionHelper',
|
||||||
'LicenseFormDefinition',
|
'LicenseFormDefinition',
|
||||||
'License',
|
'License',
|
||||||
'HostGroupsFormDefinition',
|
'HostGroupsFormDefinition'
|
||||||
'SCMUpdateHelper'
|
|
||||||
])
|
])
|
||||||
.config(['$routeProvider', function($routeProvider) {
|
.config(['$routeProvider', function($routeProvider) {
|
||||||
$routeProvider.
|
$routeProvider.
|
||||||
|
|||||||
@@ -64,14 +64,14 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.scmUpdate = function(project_id) {
|
scope.SCMUpdate = function(project_id) {
|
||||||
for (var i=0; i < scope.projects.length; i++) {
|
for (var i=0; i < scope.projects.length; i++) {
|
||||||
if (scope.projects[i].id == project_id) {
|
if (scope.projects[i].id == project_id) {
|
||||||
if (scope.projects[i].scm_type == "") {
|
if (scope.projects[i].scm_type == "") {
|
||||||
Alert('Missing SCM Setup', 'Before running an SCM update, edit the project and provide the SCM access information.', 'alert-info');
|
Alert('Missing SCM Setup', 'Before running an SCM update, edit the project and provide the SCM access information.', 'alert-info');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SCMUpdate({ scope: scope, project: scope.projects[i]});
|
SCMUpdate({ scope: scope, project_id: project_id });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -281,7 +281,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
|
|
||||||
master['scm_type'] = scope['scm_type'];
|
master['scm_type'] = scope['scm_type'];
|
||||||
setAskCheckboxes();
|
setAskCheckboxes();
|
||||||
|
|
||||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
RelatedSearchInit({ scope: scope, form: form, relatedSets: relatedSets });
|
||||||
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
RelatedPaginateInit({ scope: scope, relatedSets: relatedSets });
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*********************************************
|
/*********************************************
|
||||||
* Copyright (c) 2013 AnsibleWorks, Inc.
|
* Copyright (c) 2013 AnsibleWorks, Inc.
|
||||||
*
|
*
|
||||||
* JobTemplateHelper
|
* JobSubmission.js
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
angular.module('JobTemplateHelper', [ 'RestServices', 'Utilities', 'CredentialFormDefinition', 'CredentialsListDefinition',
|
angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'CredentialFormDefinition', 'CredentialsListDefinition',
|
||||||
'LookUpHelper', 'JobTemplateFormDefinition' ])
|
'LookUpHelper', 'JobTemplateFormDefinition', 'ProjectFormDefinition' ])
|
||||||
|
|
||||||
.factory('PromptPasswords',['CredentialForm', '$compile', 'Rest', '$location', 'ProcessErrors', 'GetBasePath',
|
.factory('PromptPasswords',['CredentialForm', '$compile', 'Rest', '$location', 'ProcessErrors', 'GetBasePath', 'Alert',
|
||||||
function(JobTemplateForm, $compile, Rest, $location, ProcessErrors, GetBasePath) {
|
function(JobTemplateForm, $compile, Rest, $location, ProcessErrors, GetBasePath, Alert) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
var scope = params.scope;
|
var scope = params.scope;
|
||||||
var passwords = params.passwords;
|
var passwords = params.passwords;
|
||||||
var start_url = params.start_url;
|
var start_url = params.start_url;
|
||||||
var form = JobTemplateForm;
|
var form = params.form;
|
||||||
var html = '';
|
var html = '';
|
||||||
var field, element, dialogScope, fld;
|
var field, element, dialogScope, fld;
|
||||||
var base = $location.path().replace(/^\//,'').split('/')[0];
|
var base = $location.path().replace(/^\//,'').split('/')[0];
|
||||||
@@ -40,7 +40,9 @@ angular.module('JobTemplateHelper', [ 'RestServices', 'Utilities', 'CredentialFo
|
|||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.destroy()
|
Rest.destroy()
|
||||||
.success ( function(data, status, headers, config) {
|
.success ( function(data, status, headers, config) {
|
||||||
navigate(true);
|
if (form.name == 'credential') {
|
||||||
|
navigate(true);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
@@ -51,7 +53,9 @@ angular.module('JobTemplateHelper', [ 'RestServices', 'Utilities', 'CredentialFo
|
|||||||
scope.cancelJob = function() {
|
scope.cancelJob = function() {
|
||||||
// User clicked cancel button
|
// User clicked cancel button
|
||||||
$('#password-modal').modal('hide');
|
$('#password-modal').modal('hide');
|
||||||
cancelJob();
|
if (form.name == 'credential') {
|
||||||
|
cancelJob();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.startJob = function() {
|
scope.startJob = function() {
|
||||||
@@ -64,84 +68,95 @@ angular.module('JobTemplateHelper', [ 'RestServices', 'Utilities', 'CredentialFo
|
|||||||
value_supplied = true;
|
value_supplied = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (value_supplied) {
|
if (passwords.length == 0 || value_supplied) {
|
||||||
Rest.setUrl(start_url);
|
Rest.setUrl(start_url);
|
||||||
Rest.post(pswd)
|
Rest.post(pswd)
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
navigate(false);
|
if (form.name == 'credential') {
|
||||||
|
navigate(false);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, null,
|
ProcessErrors(scope, data, status, null,
|
||||||
{ hdr: 'Error!', msg: 'Failed to start job. POST returned status: ' + status });
|
{ hdr: 'Error!', msg: 'POST to ' + start_url + ' failed with status: ' + status });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// No passwords provided, so we can't start the job. Rather than leave the job in a 'new'
|
Alert('No Passwords', 'Required password(s) not provided. The request was not submitted.', 'alert-info');
|
||||||
// state, let's delete it.
|
if (form.name == 'credential') {
|
||||||
scope.cancelJob();
|
// No passwords provided, so we can't start the job. Rather than leave the job in a 'new'
|
||||||
|
// state, let's delete it.
|
||||||
|
scope.cancelJob();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (passwords.length > 0) {
|
||||||
html += html += "<form class=\"form-horizontal\" name=\"password_form\" novalidate>\n";
|
// We need to prompt for passwords
|
||||||
for (var i=0; i < passwords.length; i++) {
|
html += html += "<form class=\"form-horizontal\" name=\"password_form\" novalidate>\n";
|
||||||
// Add the password field
|
for (var i=0; i < passwords.length; i++) {
|
||||||
field = form.fields[passwords[i]];
|
// Add the password field
|
||||||
fld = passwords[i];
|
field = form.fields[passwords[i]];
|
||||||
scope[fld] = '';
|
fld = passwords[i];
|
||||||
html += "<div class=\"control-group\">\n";
|
scope[fld] = '';
|
||||||
html += "<label class=\"control-label\" for=\"" + fld + '">' + field.label + '</label>' + "\n";
|
html += "<div class=\"form-group\">\n";
|
||||||
html += "<div class=\"controls\">\n";
|
html += "<label class=\"control-label col-lg-3\" for=\"" + fld + '">' + field.label + '</label>' + "\n";
|
||||||
html += "<input type=\"password\" ";
|
html += "<div class=\"col-lg-9\">\n";
|
||||||
html += "ng-model=\"" + fld + '" ';
|
html += "<input type=\"password\" ";
|
||||||
html += 'name="' + fld + '" ';
|
html += "ng-model=\"" + fld + '" ';
|
||||||
html += "class=\"password-field\" ";
|
html += 'name="' + fld + '" ';
|
||||||
html += "required ";
|
html += "class=\"password-field form-control\" ";
|
||||||
html += "/>";
|
html += "required ";
|
||||||
html += "<br />\n";
|
html += "/>";
|
||||||
// Add error messages
|
html += "<br />\n";
|
||||||
html += "<span class=\"error\" ng-show=\"password_form." + fld + ".$dirty && " +
|
// Add error messages
|
||||||
"password_form." + fld + ".$error.required\">A value is required!</span>\n";
|
html += "<span class=\"error\" ng-show=\"password_form." + fld + ".$dirty && " +
|
||||||
html += "<span class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></span>\n";
|
"password_form." + fld + ".$error.required\">A value is required!</span>\n";
|
||||||
html += "</div>\n";
|
html += "<span class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></span>\n";
|
||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
|
html += "</div>\n";
|
||||||
// Add the related confirm field
|
|
||||||
fld = field.associated;
|
// Add the related confirm field
|
||||||
field = form.fields[field.associated];
|
fld = field.associated;
|
||||||
scope[fld] = '';
|
field = form.fields[field.associated];
|
||||||
html += "<div class=\"control-group\">\n";
|
scope[fld] = '';
|
||||||
html += "<label class=\"control-label\" for=\"" + fld + '">' + field.label + '</label>' + "\n";
|
html += "<div class=\"form-group\">\n";
|
||||||
html += "<div class=\"controls\">\n";
|
html += "<label class=\"control-label col-lg-3\" for=\"" + fld + '">' + field.label + '</label>' + "\n";
|
||||||
html += "<input type=\"password\" ";
|
html += "<div class=\"col-lg-9\">\n";
|
||||||
html += "ng-model=\"" + fld + '" ';
|
html += "<input type=\"password\" ";
|
||||||
html += 'name="' + fld + '" ';
|
html += "ng-model=\"" + fld + '" ';
|
||||||
html += "required ";
|
html += 'name="' + fld + '" ';
|
||||||
html += (field.awPassMatch) ? "awpassmatch=\"" + field.associated + "\" " : "";
|
html += "class=\"form-control\" ";
|
||||||
html += "/>";
|
html += "required ";
|
||||||
html += "<br />\n";
|
html += (field.awPassMatch) ? "awpassmatch=\"" + field.associated + "\" " : "";
|
||||||
// Add error messages
|
html += "/>";
|
||||||
html += "<span class=\"error\" ng-show=\"password_form." + fld + ".$dirty && " +
|
html += "<br />\n";
|
||||||
"password_form." + fld + ".$error.required\">A value is required!</span>\n";
|
// Add error messages
|
||||||
if (field.awPassMatch) {
|
html += "<span class=\"error\" ng-show=\"password_form." + fld + ".$dirty && " +
|
||||||
html += "<span class=\"error\" ng-show=\"password_form." + fld +
|
"password_form." + fld + ".$error.required\">A value is required!</span>\n";
|
||||||
".$error.awpassmatch\">Must match Password value</span>\n";
|
if (field.awPassMatch) {
|
||||||
|
html += "<span class=\"error\" ng-show=\"password_form." + fld +
|
||||||
|
".$error.awpassmatch\">Must match Password value</span>\n";
|
||||||
|
}
|
||||||
|
html += "<span class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></span>\n";
|
||||||
|
html += "</div>\n";
|
||||||
|
html += "</div>\n";
|
||||||
}
|
}
|
||||||
html += "<span class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></span>\n";
|
html += "</form>\n";
|
||||||
html += "</div>\n";
|
element = angular.element(document.getElementById('password-body'));
|
||||||
html += "</div>\n";
|
element.html(html);
|
||||||
|
$compile(element.contents())(scope);
|
||||||
|
$('#password-modal').modal({ });
|
||||||
}
|
}
|
||||||
html += "</form>\n";
|
else {
|
||||||
element = angular.element(document.getElementById('password-body'));
|
scope.startJob();
|
||||||
element.html(html);
|
|
||||||
$compile(element.contents())(scope);
|
|
||||||
$('#password-modal').modal({ });
|
|
||||||
}
|
}
|
||||||
}])
|
}
|
||||||
|
}])
|
||||||
|
|
||||||
.factory('SubmitJob',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'CredentialList',
|
.factory('SubmitJob',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'CredentialList',
|
||||||
'LookUpInit', 'JobTemplateForm', 'ProcessErrors',
|
'LookUpInit', 'CredentialForm', 'ProcessErrors',
|
||||||
function(PromptPasswords, $compile, Rest, $location, GetBasePath, CredentialList, LookUpInit, JobTemplateForm,
|
function(PromptPasswords, $compile, Rest, $location, GetBasePath, CredentialList, LookUpInit, CredentialForm,
|
||||||
ProcessErrors) {
|
ProcessErrors) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
var scope = params.scope;
|
var scope = params.scope;
|
||||||
@@ -179,7 +194,8 @@ angular.module('JobTemplateHelper', [ 'RestServices', 'Utilities', 'CredentialFo
|
|||||||
PromptPasswords({
|
PromptPasswords({
|
||||||
scope: scope,
|
scope: scope,
|
||||||
passwords: data.passwords_needed_to_start,
|
passwords: data.passwords_needed_to_start,
|
||||||
start_url: data.related.start
|
start_url: data.related.start,
|
||||||
|
form: CredentialForm
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -248,6 +264,38 @@ angular.module('JobTemplateHelper', [ 'RestServices', 'Utilities', 'CredentialFo
|
|||||||
{ hdr: 'Error!', msg: 'Failed to get job template details. GET returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to get job template details. GET returned status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
}])
|
||||||
|
|
||||||
|
// Sumbit SCM Update request
|
||||||
|
.factory('SCMUpdate',['PromptPasswords', '$compile', 'Rest', '$location', 'GetBasePath', 'ProcessErrors', 'Alert',
|
||||||
|
'ProjectsForm',
|
||||||
|
function(PromptPasswords, $compile, Rest, $location, GetBasePath, ProcessErrors, Alert, ProjectsForm) {
|
||||||
|
return function(params) {
|
||||||
|
var scope = params.scope;
|
||||||
|
var project_id = params.project_id;
|
||||||
|
var url = GetBasePath('projects') + project_id + '/update/';
|
||||||
|
// Check to see if we have permission to perform the update and if any passwords are needed
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.get()
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
if (data.can_update) {
|
||||||
|
PromptPasswords({
|
||||||
|
scope: scope,
|
||||||
|
passwords: data.passwords_needed_to_update,
|
||||||
|
start_url: url,
|
||||||
|
form: ProjectsForm
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Alert('Permission Denied', 'You do not have access to update this project. Please contact your system administrator.',
|
||||||
|
'alert-danger');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, null,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to get job template details. GET returned status: ' + status });
|
||||||
|
});
|
||||||
|
};
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*********************************************
|
|
||||||
* Copyright (c) 2013 AnsibleWorks, Inc.
|
|
||||||
*
|
|
||||||
* SCMUpdate.js
|
|
||||||
*
|
|
||||||
* Use to kick off an update the project
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
angular.module('SCMUpdateHelper', ['RestServices', 'Utilities'])
|
|
||||||
.factory('SCMUpdate', ['Alert', 'Rest', 'GetBasePath','ProcessErrors',
|
|
||||||
function(Alert, Rest, GetBasePath, ProcessErrors) {
|
|
||||||
return function(params) {
|
|
||||||
|
|
||||||
var scope = params.scope;
|
|
||||||
var project = params.project;
|
|
||||||
|
|
||||||
Rest.setUrl(project.related.update);
|
|
||||||
Rest.get()
|
|
||||||
.success( function(data, status, headers, config) {
|
|
||||||
console.log(data);
|
|
||||||
})
|
|
||||||
.error( function(data, status, headers, config) {
|
|
||||||
ProcessErrors(scope, data, status, null,
|
|
||||||
{ hdr: 'Error!', msg: 'Failed to access ' + project.related.update + '. GET status: ' + status });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}]);
|
|
||||||
@@ -22,7 +22,9 @@ angular.module('ProjectsListDefinition', [])
|
|||||||
fields: {
|
fields: {
|
||||||
name: {
|
name: {
|
||||||
key: true,
|
key: true,
|
||||||
label: 'Name'
|
label: 'Name',
|
||||||
|
badgeIcon: "\{\{ 'icon-failures-' + project.last_update_failed \}\}",
|
||||||
|
badgePlacement: 'left'
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
label: 'Description'
|
label: 'Description'
|
||||||
@@ -54,7 +56,7 @@ angular.module('ProjectsListDefinition', [])
|
|||||||
label: 'Update',
|
label: 'Update',
|
||||||
icon: 'icon-cloud-download',
|
icon: 'icon-cloud-download',
|
||||||
"class": 'btn-xs btn-success',
|
"class": 'btn-xs btn-success',
|
||||||
ngClick: 'scmUpdate(\{\{ project.id \}\})',
|
ngClick: 'SCMUpdate(\{\{ project.id \}\})',
|
||||||
awToolTip: 'Perform an SCM update on this project'
|
awToolTip: 'Perform an SCM update on this project'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -321,8 +321,8 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
html += (field.ngChange) ? Attr(field,'ngChange') : "";
|
html += (field.ngChange) ? Attr(field,'ngChange') : "";
|
||||||
html += (field.id) ? Attr(field,'id') : "";
|
html += (field.id) ? Attr(field,'id') : "";
|
||||||
html += (field['class']) ? Attr(field,'class') : "";
|
html += (field['class']) ? Attr(field,'class') : "";
|
||||||
html += Attr(field,'trueValue');
|
html += (field.trueValue !== undefined) ? Attr(field,'trueValue') : "";
|
||||||
html += Attr(field,'falseValue');
|
html += (field.falseValue !== undefined) ? Attr(field,'falseValue') : "";
|
||||||
html += (field.checked) ? "checked " : "";
|
html += (field.checked) ? "checked " : "";
|
||||||
html += (field.readonly) ? "disabled " : "";
|
html += (field.readonly) ? "disabled " : "";
|
||||||
html += " > " + field.label + "\n";
|
html += " > " + field.label + "\n";
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
<script src="{{ STATIC_URL }}js/helpers/paginate.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/paginate.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/inventory.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/inventory.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/teams.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/teams.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/JobTemplate.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/JobSubmission.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/Lookup.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/Lookup.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/Groups.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/Groups.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/Hosts.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/Hosts.js"></script>
|
||||||
@@ -100,8 +100,7 @@
|
|||||||
<script src="{{ STATIC_URL }}js/helpers/md5.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/md5.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/Access.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/Access.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/Selection.js"></script>
|
<script src="{{ STATIC_URL }}js/helpers/Selection.js"></script>
|
||||||
<script src="{{ STATIC_URL }}js/helpers/SCMUpdate.js"></script>
|
|
||||||
|
|
||||||
<script src="{{ STATIC_URL }}lib/less/less-1.4.1.min.js"></script>
|
<script src="{{ STATIC_URL }}lib/less/less-1.4.1.min.js"></script>
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user