mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 11:25:08 -02:30
fix adhoc command cred lookup when many credential types exist
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
function adhocController($q, $scope, $stateParams,
|
function adhocController($q, $scope, $stateParams,
|
||||||
$state, CheckPasswords, PromptForPasswords, CreateLaunchDialog, CreateSelect2, adhocForm,
|
$state, CheckPasswords, PromptForPasswords, CreateLaunchDialog, CreateSelect2, adhocForm,
|
||||||
GenerateForm, Rest, ProcessErrors, GetBasePath, GetChoices,
|
GenerateForm, Rest, ProcessErrors, GetBasePath, GetChoices,
|
||||||
KindChange, Wait, ParseTypeChange, credentialTypes) {
|
KindChange, Wait, ParseTypeChange, machineCredentialType) {
|
||||||
|
|
||||||
// this is done so that we can access private functions for testing, but
|
// this is done so that we can access private functions for testing, but
|
||||||
// we don't want to populate the "public" scope with these internal
|
// we don't want to populate the "public" scope with these internal
|
||||||
@@ -302,12 +302,9 @@ function adhocController($q, $scope, $stateParams,
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.lookupCredential = function(){
|
$scope.lookupCredential = function(){
|
||||||
let credType = _.filter(credentialTypes, function(credType){
|
|
||||||
return credType.kind === "ssh";
|
|
||||||
});
|
|
||||||
$state.go('.credential', {
|
$state.go('.credential', {
|
||||||
credential_search: {
|
credential_search: {
|
||||||
credential_type: credType[0].id,
|
credential_type: machineCredentialType,
|
||||||
page_size: '5',
|
page_size: '5',
|
||||||
page: '1'
|
page: '1'
|
||||||
}
|
}
|
||||||
@@ -319,5 +316,5 @@ function adhocController($q, $scope, $stateParams,
|
|||||||
export default ['$q', '$scope', '$stateParams',
|
export default ['$q', '$scope', '$stateParams',
|
||||||
'$state', 'CheckPasswords', 'PromptForPasswords', 'CreateLaunchDialog', 'CreateSelect2',
|
'$state', 'CheckPasswords', 'PromptForPasswords', 'CreateLaunchDialog', 'CreateSelect2',
|
||||||
'adhocForm', 'GenerateForm', 'Rest', 'ProcessErrors', 'GetBasePath',
|
'adhocForm', 'GenerateForm', 'Rest', 'ProcessErrors', 'GetBasePath',
|
||||||
'GetChoices', 'KindChange', 'Wait', 'ParseTypeChange', 'credentialTypes',
|
'GetChoices', 'KindChange', 'Wait', 'ParseTypeChange', 'machineCredentialType',
|
||||||
adhocController];
|
adhocController];
|
||||||
|
|||||||
@@ -7,6 +7,23 @@
|
|||||||
import {templateUrl} from '../../../shared/template-url/template-url.factory';
|
import {templateUrl} from '../../../shared/template-url/template-url.factory';
|
||||||
import { N_ } from '../../../i18n';
|
import { N_ } from '../../../i18n';
|
||||||
|
|
||||||
|
function ResolveMachineCredentialType (GetBasePath, Rest, ProcessErrors) {
|
||||||
|
Rest.setUrl(GetBasePath('credential_types') + '?kind=ssh');
|
||||||
|
|
||||||
|
return Rest.get()
|
||||||
|
.then(({ data }) => {
|
||||||
|
return data.results[0].id;
|
||||||
|
})
|
||||||
|
.catch(({ data, status }) => {
|
||||||
|
ProcessErrors(null, data, status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get credential type data: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ResolveMachineCredentialType.$inject = ['GetBasePath', 'Rest', 'ProcessErrors'];
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
url: '/adhoc',
|
url: '/adhoc',
|
||||||
params:{
|
params:{
|
||||||
@@ -28,12 +45,6 @@ export default {
|
|||||||
label: N_("RUN COMMAND")
|
label: N_("RUN COMMAND")
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
credentialTypes: ['CredentialTypeModel', (CredentialType) =>
|
machineCredentialType: ResolveMachineCredentialType,
|
||||||
new CredentialType('get')
|
|
||||||
.then((model) => {
|
|
||||||
const credentialTypeRes = model.get();
|
|
||||||
return credentialTypeRes.results;
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user