mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 01:21:21 +03:00
AC-1083 more better handling of missing machine credentials when submitting a job.
This commit is contained in:
parent
1e50f0cc24
commit
c7d489026e
@ -101,7 +101,6 @@ function CredentialsList($scope, $rootScope, $location, $log, $routeParams, Rest
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.deleteCredential = function (id, name) {
|
$scope.deleteCredential = function (id, name) {
|
||||||
|
|
||||||
var action = function () {
|
var action = function () {
|
||||||
$('#prompt-modal').on('hidden.bs.modal', function () {
|
$('#prompt-modal').on('hidden.bs.modal', function () {
|
||||||
Wait('start');
|
Wait('start');
|
||||||
@ -121,7 +120,7 @@ function CredentialsList($scope, $rootScope, $location, $log, $routeParams, Rest
|
|||||||
|
|
||||||
Prompt({
|
Prompt({
|
||||||
hdr: 'Delete',
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: "<div class=\"alert alert-info\">Delete credential " + name + "?</div>",
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -87,7 +87,7 @@ function OrganizationsList($routeParams, $scope, $rootScope, $location, $log, Re
|
|||||||
|
|
||||||
Prompt({
|
Prompt({
|
||||||
hdr: 'Delete',
|
hdr: 'Delete',
|
||||||
body: 'Are you sure you want to delete ' + name + '?',
|
body: "<div class\"alert alert-info\">Delete organization " + name + "?</div>",
|
||||||
action: action
|
action: action
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -30,8 +30,8 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential
|
|||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.factory('PromptForCredential', ['Wait', 'GetBasePath', 'LookUpInit', 'JobTemplateForm', 'CredentialList',
|
.factory('PromptForCredential', ['$location', 'Wait', 'GetBasePath', 'LookUpInit', 'JobTemplateForm', 'CredentialList', 'Rest', 'Prompt', 'ProcessErrors',
|
||||||
function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList, Rest, Prompt, ProcessErrors) {
|
||||||
return function(params) {
|
return function(params) {
|
||||||
|
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
@ -41,22 +41,59 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
Wait('stop');
|
Wait('stop');
|
||||||
scope.credential = '';
|
scope.credential = '';
|
||||||
|
|
||||||
selectionMade = function () {
|
if (scope.removeShowLookupDialog) {
|
||||||
scope.$emit(callback, scope.credential);
|
scope.removeShowLookupDialog();
|
||||||
};
|
}
|
||||||
|
scope.removeShowLookupDialog = scope.$on('ShowLookupDialog', function() {
|
||||||
|
selectionMade = function () {
|
||||||
|
scope.$emit(callback, scope.credential);
|
||||||
|
};
|
||||||
|
|
||||||
LookUpInit({
|
LookUpInit({
|
||||||
url: GetBasePath('credentials') + '?kind=ssh',
|
url: GetBasePath('credentials') + '?kind=ssh',
|
||||||
scope: scope,
|
scope: scope,
|
||||||
form: JobTemplateForm(),
|
form: JobTemplateForm(),
|
||||||
current_item: null,
|
current_item: null,
|
||||||
list: CredentialList,
|
list: CredentialList,
|
||||||
field: 'credential',
|
field: 'credential',
|
||||||
hdr: 'Credential Required',
|
hdr: 'Credential Required',
|
||||||
instructions: "Launching this job requires a machine credential. Please select your machine credential now or Cancel to quit.",
|
instructions: "Launching this job requires a machine credential. Please select your machine credential now or Cancel to quit.",
|
||||||
postAction: selectionMade
|
postAction: selectionMade
|
||||||
|
});
|
||||||
|
scope.lookUpCredential();
|
||||||
});
|
});
|
||||||
scope.lookUpCredential();
|
|
||||||
|
if (scope.removeAlertNoCredentials) {
|
||||||
|
scope.removeAlertNoCredentials();
|
||||||
|
}
|
||||||
|
scope.removeAlertNoCredentials = scope.$on('AlertNoCredentials', function() {
|
||||||
|
var action = function () {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
$location.url('/credentials/add');
|
||||||
|
};
|
||||||
|
|
||||||
|
Prompt({
|
||||||
|
hdr: 'Machine Credential Required',
|
||||||
|
body: "<div class=\"alert alert-info\">There are no machine credentials defined in Tower. Launching this job requires a machine credential. " +
|
||||||
|
"Create one now?",
|
||||||
|
action: action
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Rest.setUrl(GetBasePath('credentials') + '?kind=ssh');
|
||||||
|
Rest.get()
|
||||||
|
.success(function(data) {
|
||||||
|
if (data.results.length > 0) {
|
||||||
|
scope.$emit('ShowLookupDialog');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope.$emit('AlertNoCredentials');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.error(function(data,status) {
|
||||||
|
ProcessErrors(scope, data, status, null, { hdr: 'Error!',
|
||||||
|
msg: 'Checking for machine credentials failed. GET returned: ' + status });
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
|
||||||
@ -76,10 +113,11 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
|
|
||||||
function promptPassword() {
|
function promptPassword() {
|
||||||
var e, fld, field;
|
var e, fld, field;
|
||||||
|
console.log(passwords);
|
||||||
password = passwords.pop();
|
password = passwords.pop();
|
||||||
|
|
||||||
// Prompt for password
|
// Prompt for password
|
||||||
|
html = "";
|
||||||
html += "<form name=\"password_form\" novalidate>\n";
|
html += "<form name=\"password_form\" novalidate>\n";
|
||||||
field = form.fields[password];
|
field = form.fields[password];
|
||||||
fld = password;
|
fld = password;
|
||||||
@ -123,7 +161,7 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
html += "</div>\n";
|
html += "</div>\n";
|
||||||
}
|
}
|
||||||
html += "</form>\n";
|
html += "</form>\n";
|
||||||
$('#password-body').empty().html(html);
|
$('#password-body').html(html);
|
||||||
e = angular.element(document.getElementById('password-modal'));
|
e = angular.element(document.getElementById('password-modal'));
|
||||||
$compile(e)(scope);
|
$compile(e)(scope);
|
||||||
$('#password-modal').modal();
|
$('#password-modal').modal();
|
||||||
@ -134,9 +172,13 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
|
|
||||||
scope.passwordAccept = function() {
|
scope.passwordAccept = function() {
|
||||||
$('#password-modal').modal('hide');
|
$('#password-modal').modal('hide');
|
||||||
|
$('#password-modal').off('shown.bs.modal');
|
||||||
|
$('#password-body').empty();
|
||||||
acceptedPasswords[password] = scope[password];
|
acceptedPasswords[password] = scope[password];
|
||||||
if (passwords.length > 0) {
|
if (passwords.length > 0) {
|
||||||
promptPassword();
|
setTimeout(function() {
|
||||||
|
promptPassword();
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parent_scope.$emit(callback, acceptedPasswords);
|
parent_scope.$emit(callback, acceptedPasswords);
|
||||||
@ -146,11 +188,12 @@ function(Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialList) {
|
|||||||
|
|
||||||
scope.passwordCancel = function() {
|
scope.passwordCancel = function() {
|
||||||
$('#password-modal').modal('hide');
|
$('#password-modal').modal('hide');
|
||||||
|
$('#password-modal').off('shown.bs.modal');
|
||||||
|
$('#password-body').empty();
|
||||||
Alert('Missing Password', 'Required password(s) not provided. Your request will not be submitted.', 'alert-info');
|
Alert('Missing Password', 'Required password(s) not provided. Your request will not be submitted.', 'alert-info');
|
||||||
parent_scope.$emit('PasswordsCanceled');
|
parent_scope.$emit('PasswordsCanceled');
|
||||||
scope.$destroy();
|
scope.$destroy();
|
||||||
};
|
};
|
||||||
|
|
||||||
promptPassword();
|
promptPassword();
|
||||||
};
|
};
|
||||||
}])
|
}])
|
||||||
|
@ -856,12 +856,12 @@ input[type="checkbox"].checkbox-no-label {
|
|||||||
.list-actions {
|
.list-actions {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
.list-wrapper {
|
/*.list-wrapper {
|
||||||
background-color: @well;
|
background-color: @well;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
border: 1px solid @well-border;
|
border: 1px solid @well-border;
|
||||||
}
|
}*/
|
||||||
.ui-accordion-content {
|
.ui-accordion-content {
|
||||||
padding-left: 15px;
|
padding-left: 15px;
|
||||||
padding-right: 15px;
|
padding-right: 15px;
|
||||||
|
@ -75,14 +75,14 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
|||||||
* alert-info...). Pass an optional function(){}, if you want a specific action to occur when user
|
* alert-info...). Pass an optional function(){}, if you want a specific action to occur when user
|
||||||
* clicks 'OK' button. Set secondAlert to true, when a second dialog is needed.
|
* clicks 'OK' button. Set secondAlert to true, when a second dialog is needed.
|
||||||
*/
|
*/
|
||||||
.factory('Alert', ['$rootScope', '$compile', function ($rootScope, $compile) {
|
.factory('Alert', ['$rootScope', '$compile', '$sce', function ($rootScope, $compile, $sce) {
|
||||||
return function (hdr, msg, cls, action, secondAlert, disableButtons) {
|
return function (hdr, msg, cls, action, secondAlert, disableButtons) {
|
||||||
var scope = $rootScope.$new(), alertClass, e;
|
var scope = $rootScope.$new(), alertClass, e;
|
||||||
if (secondAlert) {
|
if (secondAlert) {
|
||||||
e = angular.element(document.getElementById('alert-modal2'));
|
e = angular.element(document.getElementById('alert-modal2'));
|
||||||
$compile(e)(scope);
|
$compile(e)(scope);
|
||||||
scope.alertHeader2 = hdr;
|
scope.alertHeader2 = hdr;
|
||||||
scope.alertBody2 = msg;
|
scope.alertBody2 = $sce.trustAsHtml(msg);
|
||||||
alertClass = (cls) ? cls : 'alert-danger'; //default alert class is alert-danger
|
alertClass = (cls) ? cls : 'alert-danger'; //default alert class is alert-danger
|
||||||
$('#alert2-modal-msg').attr({ "class": "alert " + alertClass });
|
$('#alert2-modal-msg').attr({ "class": "alert " + alertClass });
|
||||||
$('#alert-modal2').modal({
|
$('#alert-modal2').modal({
|
||||||
@ -106,7 +106,7 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
|
|||||||
e = angular.element(document.getElementById('alert-modal'));
|
e = angular.element(document.getElementById('alert-modal'));
|
||||||
$compile(e)(scope);
|
$compile(e)(scope);
|
||||||
scope.alertHeader = hdr;
|
scope.alertHeader = hdr;
|
||||||
scope.alertBody = msg;
|
scope.alertBody = $sce.trustAsHtml(msg);
|
||||||
alertClass = (cls) ? cls : 'alert-danger'; //default alert class is alert-danger
|
alertClass = (cls) ? cls : 'alert-danger'; //default alert class is alert-danger
|
||||||
$('#alert-modal-msg').attr({ "class": "alert " + alertClass });
|
$('#alert-modal-msg').attr({ "class": "alert " + alertClass });
|
||||||
$('#alert-modal').modal({
|
$('#alert-modal').modal({
|
||||||
|
@ -282,7 +282,7 @@ angular.module('ListGenerator', ['GeneratorHelpers'])
|
|||||||
// table header row
|
// table header row
|
||||||
html += "<div class=\"list-table-container\">\n";
|
html += "<div class=\"list-table-container\">\n";
|
||||||
html += "<table id=\"" + list.name + "_table\" ";
|
html += "<table id=\"" + list.name + "_table\" ";
|
||||||
html += "class=\"table";
|
html += "class=\"table table-condensed";
|
||||||
html += (list['class']) ? " " + list['class'] : "";
|
html += (list['class']) ? " " + list['class'] : "";
|
||||||
html += (options.mode !== 'summary' && options.mode !== 'edit' && (options.mode === 'lookup' || options.id)) ?
|
html += (options.mode !== 'summary' && options.mode !== 'edit' && (options.mode === 'lookup' || options.id)) ?
|
||||||
' table-hover-inverse' : '';
|
' table-hover-inverse' : '';
|
||||||
|
@ -17,22 +17,23 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('PromptDialog', ['Utilities'])
|
angular.module('PromptDialog', ['Utilities'])
|
||||||
.factory('Prompt', [
|
.factory('Prompt', ['$sce',
|
||||||
function () {
|
function ($sce) {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
|
|
||||||
var dialog = angular.element(document.getElementById('prompt-modal')),
|
var dialog = angular.element(document.getElementById('prompt-modal')),
|
||||||
scope = dialog.scope(), cls;
|
scope = dialog.scope(), cls;
|
||||||
|
|
||||||
scope.promptHeader = params.hdr;
|
scope.promptHeader = params.hdr;
|
||||||
scope.promptBody = params.body;
|
scope.promptBody = $sce.trustAsHtml(params.body);
|
||||||
scope.promptAction = params.action;
|
scope.promptAction = params.action;
|
||||||
|
|
||||||
cls = (params['class'] === null || params['class'] === undefined) ? 'btn-danger' : params['class'];
|
cls = (params['class'] === null || params['class'] === undefined) ? 'btn-danger' : params['class'];
|
||||||
|
|
||||||
$('#prompt_action_btn').removeClass(cls).addClass(cls);
|
$('#prompt_action_btn').removeClass(cls).addClass(cls);
|
||||||
|
|
||||||
$(dialog).modal({
|
$('#prompt-modal').off('hidden.bs.modal');
|
||||||
|
$('#prompt-modal').modal({
|
||||||
backdrop: 'static',
|
backdrop: 'static',
|
||||||
keyboard: true,
|
keyboard: true,
|
||||||
show: true
|
show: true
|
||||||
|
Loading…
Reference in New Issue
Block a user