mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 19:37:38 -02:30
Pre-populate organization galaxy credential field with the default galaxy credential
This commit is contained in:
@@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
export default ['$scope', '$rootScope', '$location', '$stateParams', 'OrganizationForm',
|
export default ['$scope', '$rootScope', '$location', '$stateParams', 'OrganizationForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'Wait', 'CreateSelect2',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'Wait', 'CreateSelect2',
|
||||||
'$state','InstanceGroupsService', 'ConfigData', 'MultiCredentialService',
|
'$state','InstanceGroupsService', 'ConfigData', 'MultiCredentialService', 'defaultGalaxyCredential',
|
||||||
function($scope, $rootScope, $location, $stateParams, OrganizationForm,
|
function($scope, $rootScope, $location, $stateParams, OrganizationForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, GetBasePath, Wait, CreateSelect2,
|
GenerateForm, Rest, Alert, ProcessErrors, GetBasePath, Wait, CreateSelect2,
|
||||||
$state, InstanceGroupsService, ConfigData, MultiCredentialService) {
|
$state, InstanceGroupsService, ConfigData, MultiCredentialService, defaultGalaxyCredential) {
|
||||||
|
|
||||||
Rest.setUrl(GetBasePath('organizations'));
|
Rest.setUrl(GetBasePath('organizations'));
|
||||||
Rest.options()
|
Rest.options()
|
||||||
@@ -38,6 +38,8 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Organizati
|
|||||||
|
|
||||||
// apply form definition's default field values
|
// apply form definition's default field values
|
||||||
GenerateForm.applyDefaults(form, $scope);
|
GenerateForm.applyDefaults(form, $scope);
|
||||||
|
|
||||||
|
$scope.credentials = defaultGalaxyCredential || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ export default ['templateUrl', '$window', function(templateUrl, $window) {
|
|||||||
credentialList.well = false;
|
credentialList.well = false;
|
||||||
credentialList.multiSelect = true;
|
credentialList.multiSelect = true;
|
||||||
credentialList.multiSelectPreview = {
|
credentialList.multiSelectPreview = {
|
||||||
selectedRows: 'igTags',
|
selectedRows: 'credTags',
|
||||||
availableRows: 'credentials'
|
availableRows: 'credentials'
|
||||||
};
|
};
|
||||||
credentialList.fields.name.ngClick = "linkoutCredential(credential)";
|
credentialList.fields.name.ngClick = "linkoutCredential(credential)";
|
||||||
@@ -70,10 +70,10 @@ export default ['templateUrl', '$window', function(templateUrl, $window) {
|
|||||||
if ($scope.galaxyCredentials) {
|
if ($scope.galaxyCredentials) {
|
||||||
$scope.galaxyCredentials = $scope.galaxyCredentials.map( (item) => {
|
$scope.galaxyCredentials = $scope.galaxyCredentials.map( (item) => {
|
||||||
item.isSelected = true;
|
item.isSelected = true;
|
||||||
if (!$scope.igTags) {
|
if (!$scope.credTags) {
|
||||||
$scope.igTags = [];
|
$scope.credTags = [];
|
||||||
}
|
}
|
||||||
$scope.igTags.push(item);
|
$scope.credTags.push(item);
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ export default ['templateUrl', '$window', function(templateUrl, $window) {
|
|||||||
|
|
||||||
$scope.$watch('credentials', function(){
|
$scope.$watch('credentials', function(){
|
||||||
angular.forEach($scope.credentials, function(credentialRow) {
|
angular.forEach($scope.credentials, function(credentialRow) {
|
||||||
angular.forEach($scope.igTags, function(selectedCredential){
|
angular.forEach($scope.credTags, function(selectedCredential){
|
||||||
if(selectedCredential.id === credentialRow.id) {
|
if(selectedCredential.id === credentialRow.id) {
|
||||||
credentialRow.isSelected = true;
|
credentialRow.isSelected = true;
|
||||||
}
|
}
|
||||||
@@ -97,12 +97,12 @@ export default ['templateUrl', '$window', function(templateUrl, $window) {
|
|||||||
$scope.$on("selectedOrDeselected", function(e, value) {
|
$scope.$on("selectedOrDeselected", function(e, value) {
|
||||||
let item = value.value;
|
let item = value.value;
|
||||||
if (value.isSelected) {
|
if (value.isSelected) {
|
||||||
if(!$scope.igTags) {
|
if(!$scope.credTags) {
|
||||||
$scope.igTags = [];
|
$scope.credTags = [];
|
||||||
}
|
}
|
||||||
$scope.igTags.push(item);
|
$scope.credTags.push(item);
|
||||||
} else {
|
} 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.saveForm = function() {
|
||||||
$scope.galaxyCredentials = $scope.igTags;
|
$scope.galaxyCredentials = $scope.credTags;
|
||||||
$scope.destroyModal();
|
$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: {
|
edit: {
|
||||||
ConfigData: ['ConfigService', 'ProcessErrors', (ConfigService, ProcessErrors) => {
|
ConfigData: ['ConfigService', 'ProcessErrors', (ConfigService, ProcessErrors) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user