mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 13:57:39 -02:30
implement model-based copy for inventories
This commit is contained in:
@@ -100,6 +100,15 @@ export default ['i18n', function(i18n) {
|
|||||||
dataPlacement: 'top',
|
dataPlacement: 'top',
|
||||||
ngShow: '!inventory.pending_deletion && inventory.summary_fields.user_capabilities.edit'
|
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: {
|
view: {
|
||||||
label: i18n._('View'),
|
label: i18n._('View'),
|
||||||
ngClick: 'editInventory(inventory)',
|
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}})`;
|
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) {
|
$scope.editInventory = function (inventory) {
|
||||||
if(inventory.kind && inventory.kind === 'smart') {
|
if(inventory.kind && inventory.kind === 'smart') {
|
||||||
$state.go('inventories.editSmartInventory', {smartinventory_id: inventory.id});
|
$state.go('inventories.editSmartInventory', {smartinventory_id: inventory.id});
|
||||||
|
|||||||
Reference in New Issue
Block a user