mirror of
https://github.com/ansible/awx.git
synced 2026-01-25 00:11:23 -03:30
implement model-based copy for inventories
This commit is contained in:
parent
a02eda1bea
commit
e9ce9621f2
@ -100,6 +100,15 @@ export default ['i18n', function(i18n) {
|
||||
dataPlacement: 'top',
|
||||
ngShow: '!inventory.pending_deletion && inventory.summary_fields.user_capabilities.edit'
|
||||
},
|
||||
copy: {
|
||||
label: i18n._('Copy'),
|
||||
ngClick: 'copyInventory(inventory)',
|
||||
"class": 'btn-danger btn-xs',
|
||||
awToolTip: i18n._('Copy inventory'),
|
||||
dataPlacement: 'top',
|
||||
// requires future api rbac changes
|
||||
//ngShow: 'project.summary_fields.user_capabilities.copy'
|
||||
},
|
||||
view: {
|
||||
label: i18n._('View'),
|
||||
ngClick: 'editInventory(inventory)',
|
||||
|
||||
@ -73,6 +73,18 @@ function InventoriesList($scope,
|
||||
inventory.linkToDetails = (inventory.kind && inventory.kind === 'smart') ? `inventories.editSmartInventory({smartinventory_id:${inventory.id}})` : `inventories.edit({inventory_id:${inventory.id}})`;
|
||||
}
|
||||
|
||||
$scope.copyInventory = inventory => {
|
||||
Wait('start');
|
||||
new Inventory('get', inventory.id)
|
||||
.then(model => model.copy())
|
||||
.then(copy => $scope.editInventory(copy))
|
||||
.catch(({ data, status }) => {
|
||||
const params = { hdr: 'Error!', msg: `Call to copy failed. Return status: ${status}` };
|
||||
ProcessErrors($scope, data, status, null, params);
|
||||
})
|
||||
.finally(() => Wait('stop'));
|
||||
};
|
||||
|
||||
$scope.editInventory = function (inventory) {
|
||||
if(inventory.kind && inventory.kind === 'smart') {
|
||||
$state.go('inventories.editSmartInventory', {smartinventory_id: inventory.id});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user