1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 22:21:13 +03:00

Added inv source add/edit cred and inv script lookup states

This commit is contained in:
Michael Abashian 2017-05-15 16:14:38 -04:00
parent 537e046815
commit 46c19c26aa
3 changed files with 138 additions and 1 deletions

View File

@ -45,6 +45,8 @@ import nestedHostsAdd from './groups/nested-hosts/nested-hosts-add.route';
import nestedHostsEdit from './groups/nested-hosts/nested-hosts-edit.route';
import ansibleFactsRoute from './ansible_facts/ansible_facts.route';
import insightsRoute from './insights/insights.route';
import inventorySourcesCredentialRoute from './sources/lookup/sources-lookup-credential.route';
import inventorySourcesInventoryScriptRoute from './sources/lookup/sources-lookup-inventory-script.route';
export default
angular.module('inventory', [
@ -147,6 +149,22 @@ angular.module('inventory', [
let nestedHostsInsights = _.cloneDeep(insightsRoute);
nestedHostsInsights.name = 'inventories.edit.groups.edit.nested_hosts.edit.insights';
let addSourceCredential = _.cloneDeep(inventorySourcesCredentialRoute);
addSourceCredential.name = 'inventories.edit.inventory_sources.add.credential';
addSourceCredential.url = '/credential';
let addSourceInventoryScript = _.cloneDeep(inventorySourcesInventoryScriptRoute);
addSourceInventoryScript.name = 'inventories.edit.inventory_sources.add.inventory_script';
addSourceInventoryScript.url = '/inventory_script';
let editSourceCredential = _.cloneDeep(inventorySourcesCredentialRoute);
editSourceCredential.name = 'inventories.edit.inventory_sources.edit.credential';
editSourceCredential.url = '/credential';
let editSourceInventoryScript = _.cloneDeep(inventorySourcesInventoryScriptRoute);
editSourceInventoryScript.name = 'inventories.edit.inventory_sources.edit.inventory_script';
editSourceInventoryScript.url = '/inventory_script';
return Promise.all([
basicInventoryAdd,
basicInventoryEdit,
@ -185,7 +203,11 @@ angular.module('inventory', [
stateExtender.buildDefinition(inventorySourceListRoute),
stateExtender.buildDefinition(inventorySourceAddRoute),
stateExtender.buildDefinition(inventorySourceEditRoute),
stateExtender.buildDefinition(inventoryCompletedJobsRoute)
stateExtender.buildDefinition(inventoryCompletedJobsRoute),
stateExtender.buildDefinition(addSourceCredential),
stateExtender.buildDefinition(addSourceInventoryScript),
stateExtender.buildDefinition(editSourceCredential),
stateExtender.buildDefinition(editSourceInventoryScript)
])
};
});

View File

@ -0,0 +1,50 @@
export default {
params: {
credential_search: {
value: {
page_size:"5",
order_by:"name",
role_level:"use_role",
},
dynamic:true,
squash:""
}
},
data: {
basePath:"credentials",
formChildState:true
},
ncyBreadcrumb: {
skip: true
},
views: {
'modal': {
templateProvider: function(ListDefinition, generateList) {
let list_html = generateList.build({
mode: 'lookup',
list: ListDefinition,
input_type: 'radio'
});
return `<lookup-modal>${list_html}</lookup-modal>`;
}
}
},
resolve: {
ListDefinition: ['CredentialList', function(list) {
return list;
}],
Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath',
(list, qs, $stateParams, GetBasePath) => {
return qs.search(GetBasePath('credentials'), $stateParams[`${list.iterator}_search`]);
}
]
},
onExit: function($state) {
if ($state.transition) {
$('#form-modal').modal('hide');
$('.modal-backdrop').remove();
$('body').removeClass('modal-open');
}
}
};

View File

@ -0,0 +1,65 @@
export default {
params: {
inventory_script_search: {
value: {
page_size: "5",
order_by: "name",
role_level: "admin_role",
},
dynamic: true,
squash: ""
}
},
data: {
basePath: "inventory_scripts",
formChildState: true
},
ncyBreadcrumb: {
skip: true
},
views: {
'modal': {
templateProvider: function(ListDefinition, generateList) {
let list_html = generateList.build({
mode: 'lookup',
list: ListDefinition,
input_type: 'radio'
});
return `<lookup-modal>${list_html}</lookup-modal>`;
}
}
},
resolve: {
ListDefinition: ['InventoryScriptsList', function(list) {
return list;
}],
OrganizationId: ['ListDefinition', 'InventoryManageService', '$stateParams', '$rootScope',
function(list, InventoryManageService, $stateParams, $rootScope){
if($rootScope.$$childTail &&
$rootScope.$$childTail.$resolve &&
$rootScope.$$childTail.$resolve.hasOwnProperty('inventoryData')){
return $rootScope.$$childTail.$resolve.inventoryData.summary_fields.organization.id;
}
else {
return InventoryManageService.getInventory($stateParams.inventory_id).then(res => res.data.summary_fields.organization.id);
}
}],
Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath', '$interpolate', '$rootScope', '$state', 'OrganizationId',
(list, qs, $stateParams, GetBasePath, $interpolate, $rootScope, $state, OrganizationId) => {
$stateParams[`${list.iterator}_search`].role_level = "admin_role";
$stateParams[`${list.iterator}_search`].organization = OrganizationId;
return qs.search(GetBasePath('inventory_scripts'), $stateParams[`${list.iterator}_search`]);
}
]
},
onExit: function($state) {
if ($state.transition) {
$('#form-modal').modal('hide');
$('.modal-backdrop').remove();
$('body').removeClass('modal-open');
}
}
};