mirror of
https://github.com/ansible/awx.git
synced 2024-11-02 09:51:09 +03:00
Merge pull request #6459 from mabashian/inventory-source-fixes
Reduced options requests on inventory source form
This commit is contained in:
commit
ebebb7149f
@ -55,6 +55,13 @@
|
||||
rootGroupsUrl: function(id){
|
||||
var url = GetBasePath('inventory') + id+ '/root_groups';
|
||||
return url;
|
||||
},
|
||||
inventorySourcesOptions: function(inventoryId) {
|
||||
this.url = GetBasePath('inventory') + inventoryId + '/inventory_sources';
|
||||
Rest.setUrl(this.url);
|
||||
return Rest.options()
|
||||
.success(this.success.bind(this))
|
||||
.error(this.error.bind(this));
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
@ -7,12 +7,12 @@
|
||||
export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition',
|
||||
'ParseTypeChange', 'GenerateForm', 'inventoryData', 'GroupManageService',
|
||||
'GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions',
|
||||
'rbacUiControlService', 'ToJSON', 'SourcesService', 'canAdd', 'Empty',
|
||||
'Wait', 'Rest', 'Alert', 'ProcessErrors',
|
||||
'rbacUiControlService', 'ToJSON', 'SourcesService', 'Empty',
|
||||
'Wait', 'Rest', 'Alert', 'ProcessErrors', 'inventorySourcesOptions',
|
||||
function($state, $stateParams, $scope, SourcesFormDefinition, ParseTypeChange,
|
||||
GenerateForm, inventoryData, GroupManageService, GetChoices,
|
||||
GetBasePath, CreateSelect2, GetSourceTypeOptions, rbacUiControlService,
|
||||
ToJSON, SourcesService, canAdd, Empty, Wait, Rest, Alert, ProcessErrors) {
|
||||
ToJSON, SourcesService, Empty, Wait, Rest, Alert, ProcessErrors, inventorySourcesOptions) {
|
||||
|
||||
let form = SourcesFormDefinition;
|
||||
init();
|
||||
@ -20,7 +20,7 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition',
|
||||
function init() {
|
||||
// apply form definition's default field values
|
||||
GenerateForm.applyDefaults(form, $scope);
|
||||
$scope.canAdd = canAdd;
|
||||
$scope.canAdd = inventorySourcesOptions.actions.POST;
|
||||
$scope.envParseType = 'yaml';
|
||||
initSources();
|
||||
}
|
||||
@ -213,61 +213,61 @@ export default ['$state', '$stateParams', '$scope', 'SourcesFormDefinition',
|
||||
function initSources(){
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'source_regions',
|
||||
variable: 'rax_regions',
|
||||
choice_name: 'rax_region_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'source_regions',
|
||||
variable: 'ec2_regions',
|
||||
choice_name: 'ec2_region_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'source_regions',
|
||||
variable: 'gce_regions',
|
||||
choice_name: 'gce_region_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'source_regions',
|
||||
variable: 'azure_regions',
|
||||
choice_name: 'azure_region_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
// Load options for group_by
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'group_by',
|
||||
variable: 'ec2_group_by',
|
||||
choice_name: 'ec2_group_by_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'verbosity',
|
||||
variable: 'verbosity_options',
|
||||
callback: 'choicesReadyVerbosity'
|
||||
callback: 'choicesReadyVerbosity',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
GetSourceTypeOptions({
|
||||
scope: $scope,
|
||||
variable: 'source_type_options',
|
||||
variable: 'source_type_options'
|
||||
//callback: 'sourceTypeOptionsReady' this callback is hard-coded into GetSourceTypeOptions(), included for ref
|
||||
});
|
||||
}
|
||||
|
@ -20,13 +20,10 @@ export default {
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
canAdd: ['rbacUiControlService', 'GetBasePath', '$stateParams', function(rbacUiControlService, GetBasePath, $stateParams) {
|
||||
return rbacUiControlService.canAdd(GetBasePath('inventory') + $stateParams.inventory_id + "/inventory_sources")
|
||||
inventorySourcesOptions: ['InventoryManageService', '$stateParams', function(InventoryManageService, $stateParams) {
|
||||
return InventoryManageService.inventorySourcesOptions($stateParams.inventory_id)
|
||||
.then(function(res) {
|
||||
return res.canAdd;
|
||||
})
|
||||
.catch(function() {
|
||||
return false;
|
||||
return res.data;
|
||||
});
|
||||
}]
|
||||
}
|
||||
|
@ -7,18 +7,18 @@
|
||||
export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
|
||||
'rbacUiControlService', 'ToJSON', 'ParseTypeChange', 'GroupManageService',
|
||||
'GetChoices', 'GetBasePath', 'CreateSelect2', 'GetSourceTypeOptions',
|
||||
'inventorySourceData', 'SourcesService', 'inventoryData', 'canAdd', 'Empty',
|
||||
'inventorySourceData', 'SourcesService', 'inventoryData', 'inventorySourcesOptions', 'Empty',
|
||||
'Wait', 'Rest', 'Alert', 'ProcessErrors',
|
||||
function($state, $stateParams, $scope, ParseVariableString,
|
||||
rbacUiControlService, ToJSON,ParseTypeChange, GroupManageService,
|
||||
GetChoices, GetBasePath, CreateSelect2, GetSourceTypeOptions,
|
||||
inventorySourceData, SourcesService, inventoryData, canAdd, Empty,
|
||||
inventorySourceData, SourcesService, inventoryData, inventorySourcesOptions, Empty,
|
||||
Wait, Rest, Alert, ProcessErrors) {
|
||||
|
||||
init();
|
||||
|
||||
function init() {
|
||||
$scope.canAdd = canAdd;
|
||||
$scope.canAdd = inventorySourcesOptions.actions.POST;
|
||||
// instantiate expected $scope values from inventorySourceData
|
||||
_.assign($scope,
|
||||
{credential: inventorySourceData.credential},
|
||||
@ -316,43 +316,43 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'source_regions',
|
||||
variable: 'rax_regions',
|
||||
choice_name: 'rax_region_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'source_regions',
|
||||
variable: 'ec2_regions',
|
||||
choice_name: 'ec2_region_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'source_regions',
|
||||
variable: 'gce_regions',
|
||||
choice_name: 'gce_region_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'source_regions',
|
||||
variable: 'azure_regions',
|
||||
choice_name: 'azure_region_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'group_by',
|
||||
variable: 'ec2_group_by',
|
||||
choice_name: 'ec2_group_by_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
callback: 'choicesReadyGroup',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
}
|
||||
|
||||
@ -385,10 +385,10 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
|
||||
|
||||
GetChoices({
|
||||
scope: $scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'verbosity',
|
||||
variable: 'verbosity_options',
|
||||
callback: 'choicesReadyVerbosity'
|
||||
callback: 'choicesReadyVerbosity',
|
||||
options: inventorySourcesOptions
|
||||
});
|
||||
|
||||
// region / source options callback
|
||||
|
@ -23,13 +23,10 @@ export default {
|
||||
inventorySourceData: ['$stateParams', 'SourcesService', function($stateParams, SourcesService) {
|
||||
return SourcesService.get({id: $stateParams.inventory_source_id }).then(res => res.data.results[0]);
|
||||
}],
|
||||
canAdd: ['rbacUiControlService', 'GetBasePath', '$stateParams', function(rbacUiControlService, GetBasePath, $stateParams) {
|
||||
return rbacUiControlService.canAdd(GetBasePath('inventory') + $stateParams.inventory_id + "/inventory_sources")
|
||||
inventorySourcesOptions: ['InventoryManageService', '$stateParams', function(InventoryManageService, $stateParams) {
|
||||
return InventoryManageService.inventorySourcesOptions($stateParams.inventory_id)
|
||||
.then(function(res) {
|
||||
return res.canAdd;
|
||||
})
|
||||
.catch(function() {
|
||||
return false;
|
||||
return res.data;
|
||||
});
|
||||
}]
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ return {
|
||||
sourceField: 'name',
|
||||
ngClick: 'lookupProject()',
|
||||
awRequiredWhen: {
|
||||
reqExpression: "projectRequired",
|
||||
reqExpression: "source && source.value === 'scm'",
|
||||
init: "false"
|
||||
},
|
||||
ngDisabled: '!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd)',
|
||||
@ -107,7 +107,7 @@ return {
|
||||
ngDisabled: "!(inventory_source_obj.summary_fields.user_capabilities.edit || canAdd) || disableInventoryFileBecausePermissionDenied",
|
||||
id: 'inventory-file-select',
|
||||
awRequiredWhen: {
|
||||
reqExpression: "inventoryfilerequired",
|
||||
reqExpression: "source && source.value === 'scm'",
|
||||
init: "true"
|
||||
},
|
||||
column: 1,
|
||||
|
Loading…
Reference in New Issue
Block a user