mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
Merge pull request #540 from mabashian/6370-delete-inv-src
Delete inv source hosts before inv source
This commit is contained in:
@@ -9,12 +9,12 @@
|
|||||||
'ViewUpdateStatus', 'rbacUiControlService', 'GetBasePath',
|
'ViewUpdateStatus', 'rbacUiControlService', 'GetBasePath',
|
||||||
'GetSyncStatusMsg', 'Dataset', 'Find', 'QuerySet',
|
'GetSyncStatusMsg', 'Dataset', 'Find', 'QuerySet',
|
||||||
'inventoryData', '$filter', 'Prompt', 'Wait', 'SourcesService', 'inventorySourceOptions',
|
'inventoryData', '$filter', 'Prompt', 'Wait', 'SourcesService', 'inventorySourceOptions',
|
||||||
'canAdd', 'hasSyncableSources', 'i18n',
|
'canAdd', 'hasSyncableSources', 'i18n', 'ProcessErrors',
|
||||||
function($scope, $rootScope, $state, $stateParams, SourcesListDefinition,
|
function($scope, $rootScope, $state, $stateParams, SourcesListDefinition,
|
||||||
InventoryUpdate, CancelSourceUpdate,
|
InventoryUpdate, CancelSourceUpdate,
|
||||||
ViewUpdateStatus, rbacUiControlService, GetBasePath, GetSyncStatusMsg,
|
ViewUpdateStatus, rbacUiControlService, GetBasePath, GetSyncStatusMsg,
|
||||||
Dataset, Find, qs, inventoryData, $filter, Prompt,
|
Dataset, Find, qs, inventoryData, $filter, Prompt,
|
||||||
Wait, SourcesService, inventorySourceOptions, canAdd, hasSyncableSources, i18n){
|
Wait, SourcesService, inventorySourceOptions, canAdd, hasSyncableSources, i18n, ProcessErrors){
|
||||||
|
|
||||||
let list = SourcesListDefinition;
|
let list = SourcesListDefinition;
|
||||||
var inventory_source;
|
var inventory_source;
|
||||||
@@ -121,20 +121,42 @@
|
|||||||
var action = function(){
|
var action = function(){
|
||||||
delete $rootScope.promptActionBtnClass;
|
delete $rootScope.promptActionBtnClass;
|
||||||
Wait('start');
|
Wait('start');
|
||||||
SourcesService.delete(inventory_source.id).then(() => {
|
SourcesService.deleteHosts(inventory_source.id).then(() => {
|
||||||
$('#prompt-modal').modal('hide');
|
SourcesService.delete(inventory_source.id).then(() => {
|
||||||
let reloadListStateParams = null;
|
$('#prompt-modal').modal('hide');
|
||||||
|
let reloadListStateParams = null;
|
||||||
|
|
||||||
if($scope.inventory_sources.length === 1 && $state.params.inventory_source_search && !_.isEmpty($state.params.inventory_source_search.page) && $state.params.inventory_source_search.page !== '1') {
|
if($scope.inventory_sources.length === 1 && $state.params.inventory_source_search && !_.isEmpty($state.params.inventory_source_search.page) && $state.params.inventory_source_search.page !== '1') {
|
||||||
reloadListStateParams = _.cloneDeep($state.params);
|
reloadListStateParams = _.cloneDeep($state.params);
|
||||||
reloadListStateParams.inventory_source_search.page = (parseInt(reloadListStateParams.inventory_source_search.page)-1).toString();
|
reloadListStateParams.inventory_source_search.page = (parseInt(reloadListStateParams.inventory_source_search.page)-1).toString();
|
||||||
}
|
}
|
||||||
if (parseInt($state.params.inventory_source_id) === inventory_source.id) {
|
if (parseInt($state.params.inventory_source_id) === inventory_source.id) {
|
||||||
$state.go('^', reloadListStateParams, {reload: true});
|
$state.go('^', reloadListStateParams, {reload: true});
|
||||||
} else {
|
} else {
|
||||||
$state.go('.', reloadListStateParams, {reload: true});
|
$state.go('.', reloadListStateParams, {reload: true});
|
||||||
}
|
}
|
||||||
|
Wait('stop');
|
||||||
|
})
|
||||||
|
.catch(({data, status}) => {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
|
Wait('stop');
|
||||||
|
ProcessErrors($scope, data, status, null,
|
||||||
|
{
|
||||||
|
hdr: i18n._('Error!'),
|
||||||
|
msg: i18n._('There was an error deleting inventory source. Returned status: ') +
|
||||||
|
status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(({data, status}) => {
|
||||||
|
$('#prompt-modal').modal('hide');
|
||||||
Wait('stop');
|
Wait('stop');
|
||||||
|
ProcessErrors($scope, data, status, null,
|
||||||
|
{
|
||||||
|
hdr: i18n._('Error!'),
|
||||||
|
msg: i18n._('There was an error deleting inventory source hosts. Returned status: ') +
|
||||||
|
status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// Prompt depends on having $rootScope.promptActionBtnClass available...
|
// Prompt depends on having $rootScope.promptActionBtnClass available...
|
||||||
|
|||||||
@@ -132,6 +132,15 @@ export default
|
|||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
deleteHosts(id) {
|
||||||
|
Wait('start');
|
||||||
|
this.url = GetBasePath('inventory_sources') + id + '/hosts/';
|
||||||
|
Rest.setUrl(this.url);
|
||||||
|
return Rest.destroy()
|
||||||
|
.success(this.success.bind(this))
|
||||||
|
.error(this.error.bind(this))
|
||||||
|
.finally(Wait('stop'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
|
|||||||
Reference in New Issue
Block a user