1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

Merge pull request #6574 from mabashian/6371-ask-cred-on-launch

ask_credential_on_launch UI changes when launching job
This commit is contained in:
Michael Abashian 2017-06-13 10:56:53 -04:00 committed by GitHub
commit a815690bd4
7 changed files with 36 additions and 53 deletions

View File

@ -111,11 +111,10 @@ export default
}
// include the credential used if the user was prompted to choose a cred
if(scope.ask_credential_on_launch && !Empty(scope.selected_credentials.machine)){
job_launch_data.credential_id = scope.selected_credentials.machine.id;
}
if(scope.ask_extra_credentials_on_launch){
if(scope.ask_credential_on_launch){
if(!Empty(scope.selected_credentials.machine)) {
job_launch_data.credential_id = scope.selected_credentials.machine.id;
}
job_launch_data.extra_credentials = [];
scope.selected_credentials.extra.forEach((extraCredential) => {
job_launch_data.extra_credentials.push(extraCredential.id);

View File

@ -240,30 +240,11 @@ export default
$scope.selected_credentials.machine = angular.copy($scope.defaults.credential);
}
if($scope.ask_extra_credentials_on_launch) {
// Go out and get the credential types
Rest.setUrl(GetBasePath('credential_types'));
Rest.get()
.success(function (credentialTypeData) {
let credential_types = {};
$scope.credentialKindOptions = [];
credentialTypeData.results.forEach((credentialType => {
credential_types[credentialType.id] = credentialType;
if(($scope.ask_credential_on_launch || (!$scope.ask_credential_on_launch && credentialType.id !== 1)) && credentialType.kind.match(/^(cloud|network|ssh)$/)) {
$scope.credentialKindOptions.push({
name: credentialType.name,
value: credentialType.id
});
}
}));
$scope.credential_types = credential_types;
if($scope.has_default_extra_credentials) {
$scope.selected_credentials.extra = angular.copy($scope.defaults.extra_credentials);
}
});
if($scope.has_default_extra_credentials) {
$scope.selected_credentials.extra = angular.copy($scope.defaults.extra_credentials);
}
if( ($scope.submitJobType === 'workflow_job_template' && !$scope.survey_enabled) || ($scope.submitJobRelaunch && !$scope.password_needed) || (!$scope.submitJobRelaunch && $scope.can_start_without_user_input && !$scope.ask_inventory_on_launch && !$scope.ask_credential_on_launch && !$scope.ask_extra_credentials_on_launch && !$scope.has_other_prompts && !$scope.survey_enabled)) {
if( ($scope.submitJobType === 'workflow_job_template' && !$scope.survey_enabled) || ($scope.submitJobRelaunch && !$scope.password_needed) || (!$scope.submitJobRelaunch && $scope.can_start_without_user_input && !$scope.ask_inventory_on_launch && !$scope.ask_credential_on_launch && !$scope.has_other_prompts && !$scope.survey_enabled)) {
// The job can be launched if
// a) It's a relaunch and no passwords are needed
// or
@ -274,11 +255,30 @@ export default
else {
var initiateModal = function() {
// Go out and get the credential types
Rest.setUrl(GetBasePath('credential_types'));
Rest.get()
.success(function (credentialTypeData) {
let credential_types = {};
$scope.credentialTypeOptions = [];
credentialTypeData.results.forEach((credentialType => {
credential_types[credentialType.id] = credentialType;
if(credentialType.kind.match(/^(machine|cloud|network|ssh)$/)) {
$scope.credentialTypeOptions.push({
name: credentialType.name,
value: credentialType.id
});
}
}));
$scope.credential_types = credential_types;
});
// Figure out which step the user needs to start on
if($scope.ask_inventory_on_launch) {
$scope.setStep("inventory", true);
}
else if($scope.ask_credential_on_launch || $scope.ask_extra_credentials_on_launch || $scope.password_needed) {
else if($scope.ask_credential_on_launch || $scope.password_needed) {
$scope.setStep("credential", true);
}
else if($scope.has_other_prompts) {
@ -399,7 +399,7 @@ export default
$scope.getActionButtonText = function() {
if($scope.step === "inventory") {
return ($scope.ask_credential_on_launch || $scope.ask_extra_credentials_on_launch || $scope.password_needed || $scope.has_other_prompts || $scope.survey_enabled) ? "NEXT" : "LAUNCH";
return ($scope.ask_credential_on_launch || $scope.password_needed || $scope.has_other_prompts || $scope.survey_enabled) ? "NEXT" : "LAUNCH";
}
else if($scope.step === "credential") {
return ($scope.has_other_prompts || $scope.survey_enabled) ? "NEXT" : "LAUNCH";
@ -457,7 +457,7 @@ export default
$scope.takeAction = function() {
if($scope.step === "inventory") {
// Check to see if there's another step after this one
if($scope.ask_credential_on_launch || $scope.ask_extra_credentials_on_launch || $scope.password_needed) {
if($scope.ask_credential_on_launch || $scope.password_needed) {
$scope.setStep("credential");
}
else if($scope.has_other_prompts) {

View File

@ -28,7 +28,7 @@ export default [ 'templateUrl', 'CreateDialog', 'Wait', 'CreateSelect2', 'ParseT
if(scope.ask_inventory_on_launch) {
scope.includeInventoryList = true;
}
if(scope.ask_credential_on_launch || scope.ask_extra_credentials_on_launch) {
if(scope.ask_credential_on_launch) {
scope.credentialKind = (scope.ask_credential_on_launch) ? "1" : "5";
scope.includeCredentialList = true;

View File

@ -15,7 +15,7 @@
<div class="JobSubmission-stepsContainer">
<div class="JobSubmission-steps">
<div class="JobSubmission-step" ng-class="{'JobSubmission-step--active': step==='inventory'}" ng-if="ask_inventory_on_launch" ng-click="setStep('inventory')" translate>Inventory</div>
<div class="JobSubmission-step" ng-class="{'JobSubmission-step--active': step==='credential', 'JobSubmission-step--disabled': !credentialTabEnabled}" ng-if="ask_credential_on_launch || ask_extra_credentials_on_launch || password_needed" ng-click="!credentialTabEnabled || setStep('credential')" translate>Credential</div>
<div class="JobSubmission-step" ng-class="{'JobSubmission-step--active': step==='credential', 'JobSubmission-step--disabled': !credentialTabEnabled}" ng-if="ask_credential_on_launch || password_needed" ng-click="!credentialTabEnabled || setStep('credential')" translate>Credential</div>
<div class="JobSubmission-step" ng-class="{'JobSubmission-step--active': step==='otherprompts', 'JobSubmission-step--disabled': !otherPromptsTabEnabled}" ng-if="has_other_prompts" ng-click="!otherPromptsTabEnabled || setStep('otherprompts')" translate>Other Prompts</div>
<div class="JobSubmission-step" ng-class="{'JobSubmission-step--active': step==='survey', 'JobSubmission-step--disabled': !surveyTabEnabled}" ng-if="survey_enabled" ng-click="!surveyTabEnabled || setStep('survey')" translate>Survey</div>
</div>
@ -36,7 +36,7 @@
<job-sub-inv-list ng-if="includeInventoryList" selected-inventory="$parent.selected_inventory"></job-sub-inv-list>
</div>
</div>
<div ng-if="ask_credential_on_launch || ask_extra_credentials_on_launch || password_needed" ng-show="step === 'credential'" class="JobSubmission-form">
<div ng-if="ask_credential_on_launch || password_needed" ng-show="step === 'credential'" class="JobSubmission-form">
<div class="JobSubmission-selectedItemContainer">
<div class="JobSubmission-selectedItem">
<div class="JobSubmission-selectedItemInfo">
@ -52,17 +52,17 @@
<span>{{extraCredential.name}}{{$last ? '' : ',&nbsp;'}}</span>
</span>
<span class="JobSubmission-selectedItemNone" ng-show="!selected_credentials.machine && selected_credentials.extra.length === 0" translate>None selected</span>
<span ng-if="ask_credential_on_launch || ask_extra_credentials_on_launch">
<span ng-if="ask_credential_on_launch">
<a class="JobSubmission-revertLink" href="" ng-show="showRevertCredentials()" ng-click="revertToDefaultCredentials()" translate>REVERT</a>
</span>
</div>
</div>
</div>
<div class="JobSubmission-credentialSubSection" ng-show="ask_extra_credentials_on_launch">
<div class="JobSubmission-credentialSubSection" ng-show="ask_credential_on_launch">
<span class="JobSubmission-label" translate>CREDENTIAL TYPE:</span>
<select ng-model="credentialKind">
<option ng-repeat="option in credentialKindOptions" value="{{option.value}}">{{option.name}}</option>
<option ng-repeat="option in credentialTypeOptions" value="{{option.value}}">{{option.name}}</option>
</select>
</div>
<job-sub-cred-list ng-if="includeCredentialList" selected-credentials="selected_credentials" credential-types="::credential_types" credential-kind="credentialKind"></job-sub-cred-list>

View File

@ -93,10 +93,6 @@ function(NotificationsList, CompletedJobsList, i18n) {
},
project: {
label: i18n._('Project'),
labelAction: {
label: i18n._('RESET'),
ngClick: 'resetProjectToDefault()',
},
type: 'lookup',
list: 'ProjectList',
basePath: 'projects',

View File

@ -178,12 +178,6 @@
sync_playbook_select2();
};
$scope.resetProjectToDefault = function() {
$scope.project_name = 'Default';
$scope.project = null;
selectPlaybook('force_load');
};
// Detect and alert user to potential SCM status issues
checkSCMStatus = function (oldValue, newValue) {
if (oldValue !== newValue && !Empty($scope.project)) {
@ -237,7 +231,7 @@
});
if ($scope.removeSurveySaved) {
$scope.rmoveSurveySaved();
$scope.removeSurveySaved();
}
$scope.removeSurveySaved = $scope.$on('SurveySaved', function() {
Wait('stop');

View File

@ -179,12 +179,6 @@ export default
});
};
$scope.resetProjectToDefault = function() {
$scope.project_name = 'Default';
$scope.project = null;
getPlaybooks();
};
// Detect and alert user to potential SCM status issues
checkSCMStatus = function () {
if (!Empty($scope.project)) {