mirror of
https://github.com/ansible/awx.git
synced 2026-01-20 22:18:01 -03:30
Pre-populate organization galaxy credential field with the default galaxy credential
This commit is contained in:
parent
a30ca9c19c
commit
895010c675
@ -6,10 +6,10 @@
|
||||
|
||||
export default ['$scope', '$rootScope', '$location', '$stateParams', 'OrganizationForm',
|
||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'Wait', 'CreateSelect2',
|
||||
'$state','InstanceGroupsService', 'ConfigData', 'MultiCredentialService',
|
||||
'$state','InstanceGroupsService', 'ConfigData', 'MultiCredentialService', 'defaultGalaxyCredential',
|
||||
function($scope, $rootScope, $location, $stateParams, OrganizationForm,
|
||||
GenerateForm, Rest, Alert, ProcessErrors, GetBasePath, Wait, CreateSelect2,
|
||||
$state, InstanceGroupsService, ConfigData, MultiCredentialService) {
|
||||
$state, InstanceGroupsService, ConfigData, MultiCredentialService, defaultGalaxyCredential) {
|
||||
|
||||
Rest.setUrl(GetBasePath('organizations'));
|
||||
Rest.options()
|
||||
@ -38,6 +38,8 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Organizati
|
||||
|
||||
// apply form definition's default field values
|
||||
GenerateForm.applyDefaults(form, $scope);
|
||||
|
||||
$scope.credentials = defaultGalaxyCredential || [];
|
||||
}
|
||||
|
||||
// Save
|
||||
|
||||
@ -49,7 +49,7 @@ export default ['templateUrl', '$window', function(templateUrl, $window) {
|
||||
credentialList.well = false;
|
||||
credentialList.multiSelect = true;
|
||||
credentialList.multiSelectPreview = {
|
||||
selectedRows: 'igTags',
|
||||
selectedRows: 'credTags',
|
||||
availableRows: 'credentials'
|
||||
};
|
||||
credentialList.fields.name.ngClick = "linkoutCredential(credential)";
|
||||
@ -70,10 +70,10 @@ export default ['templateUrl', '$window', function(templateUrl, $window) {
|
||||
if ($scope.galaxyCredentials) {
|
||||
$scope.galaxyCredentials = $scope.galaxyCredentials.map( (item) => {
|
||||
item.isSelected = true;
|
||||
if (!$scope.igTags) {
|
||||
$scope.igTags = [];
|
||||
if (!$scope.credTags) {
|
||||
$scope.credTags = [];
|
||||
}
|
||||
$scope.igTags.push(item);
|
||||
$scope.credTags.push(item);
|
||||
return item;
|
||||
});
|
||||
}
|
||||
@ -83,7 +83,7 @@ export default ['templateUrl', '$window', function(templateUrl, $window) {
|
||||
|
||||
$scope.$watch('credentials', function(){
|
||||
angular.forEach($scope.credentials, function(credentialRow) {
|
||||
angular.forEach($scope.igTags, function(selectedCredential){
|
||||
angular.forEach($scope.credTags, function(selectedCredential){
|
||||
if(selectedCredential.id === credentialRow.id) {
|
||||
credentialRow.isSelected = true;
|
||||
}
|
||||
@ -97,12 +97,12 @@ export default ['templateUrl', '$window', function(templateUrl, $window) {
|
||||
$scope.$on("selectedOrDeselected", function(e, value) {
|
||||
let item = value.value;
|
||||
if (value.isSelected) {
|
||||
if(!$scope.igTags) {
|
||||
$scope.igTags = [];
|
||||
if(!$scope.credTags) {
|
||||
$scope.credTags = [];
|
||||
}
|
||||
$scope.igTags.push(item);
|
||||
$scope.credTags.push(item);
|
||||
} else {
|
||||
_.remove($scope.igTags, { id: item.id });
|
||||
_.remove($scope.credTags, { id: item.id });
|
||||
}
|
||||
});
|
||||
|
||||
@ -115,7 +115,7 @@ export default ['templateUrl', '$window', function(templateUrl, $window) {
|
||||
};
|
||||
|
||||
$scope.saveForm = function() {
|
||||
$scope.galaxyCredentials = $scope.igTags;
|
||||
$scope.galaxyCredentials = $scope.credTags;
|
||||
$scope.destroyModal();
|
||||
};
|
||||
}]
|
||||
|
||||
@ -71,7 +71,29 @@ angular.module('Organizations', [
|
||||
});
|
||||
});
|
||||
|
||||
}]
|
||||
}],
|
||||
defaultGalaxyCredential: ['Rest', 'GetBasePath', 'ProcessErrors',
|
||||
function(Rest, GetBasePath, ProcessErrors){
|
||||
Rest.setUrl(GetBasePath('credentials'));
|
||||
return Rest.get({
|
||||
params: {
|
||||
credential_type__kind: 'galaxy',
|
||||
managed_by_tower: true
|
||||
}
|
||||
})
|
||||
.then(({data}) => {
|
||||
if (data.results.length > 0) {
|
||||
return data.results;
|
||||
}
|
||||
})
|
||||
.catch(({data, status}) => {
|
||||
ProcessErrors(null, data, status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get default Galaxy credential. GET returned ' +
|
||||
'status: ' + status
|
||||
});
|
||||
});
|
||||
}],
|
||||
},
|
||||
edit: {
|
||||
ConfigData: ['ConfigService', 'ProcessErrors', (ConfigService, ProcessErrors) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user