mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 20:30:46 -03:30
Merge pull request #6494 from mabashian/6346-sync-all-behavior
Moved Sync All Inv Sources to the inventory sources list
This commit is contained in:
commit
fee8a54f30
@ -62,6 +62,13 @@
|
||||
return Rest.options()
|
||||
.success(this.success.bind(this))
|
||||
.error(this.error.bind(this));
|
||||
},
|
||||
updateInventorySourcesGet: function(inventoryId) {
|
||||
this.url = GetBasePath('inventory') + inventoryId + '/update_inventory_sources';
|
||||
Rest.setUrl(this.url);
|
||||
return Rest.get()
|
||||
.success(this.success.bind(this))
|
||||
.error(this.error.bind(this));
|
||||
}
|
||||
};
|
||||
}];
|
||||
|
||||
@ -91,16 +91,7 @@ export default ['i18n', function(i18n) {
|
||||
},
|
||||
|
||||
fieldActions: {
|
||||
|
||||
columnClass: 'col-md-2 col-sm-3 col-xs-4',
|
||||
|
||||
inventory_update: {
|
||||
mode: 'all',
|
||||
ngClick: 'syncInventory(inventory)',
|
||||
awToolTip: i18n._('Sync all inventory sources'),
|
||||
ngShow: "inventory.kind === '' && inventory.has_inventory_sources",
|
||||
dataPlacement: "top",
|
||||
},
|
||||
edit: {
|
||||
label: i18n._('Edit'),
|
||||
ngClick: 'editInventory(inventory)',
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
function InventoriesList($scope,
|
||||
$filter, Rest, InventoryList, Prompt,
|
||||
ProcessErrors, GetBasePath, Wait, $state,
|
||||
Dataset, InventoryUpdate, canAdd) {
|
||||
Dataset, canAdd) {
|
||||
|
||||
let list = InventoryList,
|
||||
defaultUrl = GetBasePath('inventory');
|
||||
@ -107,18 +107,10 @@ function InventoriesList($scope,
|
||||
actionText: 'DELETE'
|
||||
});
|
||||
};
|
||||
|
||||
$scope.syncInventory = function(inventory) {
|
||||
InventoryUpdate({
|
||||
scope: $scope,
|
||||
url: inventory.related.update_inventory_sources,
|
||||
updateAllSources: true
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default ['$scope',
|
||||
'$filter', 'Rest', 'InventoryList', 'Prompt',
|
||||
'ProcessErrors', 'GetBasePath', 'Wait',
|
||||
'$state', 'Dataset', 'InventoryUpdate', 'canAdd', InventoriesList
|
||||
'$state', 'Dataset', 'canAdd', InventoriesList
|
||||
];
|
||||
|
||||
@ -49,6 +49,7 @@ import hostGroupsRoute from './host-groups/host-groups.route';
|
||||
import hostGroupsAssociateRoute from './host-groups/host-groups-associate/host-groups-associate.route';
|
||||
import inventorySourcesCredentialRoute from './sources/lookup/sources-lookup-credential.route';
|
||||
import inventorySourcesInventoryScriptRoute from './sources/lookup/sources-lookup-inventory-script.route';
|
||||
import inventorySourcesProjectRoute from './sources/lookup/sources-lookup-project.route';
|
||||
import SmartInventory from './smart-inventory/main';
|
||||
import StandardInventory from './standard/main';
|
||||
|
||||
@ -202,6 +203,14 @@ angular.module('inventory', [
|
||||
editSourceCredential.name = 'inventories.edit.inventory_sources.edit.credential';
|
||||
editSourceCredential.url = '/credential';
|
||||
|
||||
let addSourceProject = _.cloneDeep(inventorySourcesProjectRoute);
|
||||
addSourceProject.name = 'inventories.edit.inventory_sources.add.project';
|
||||
addSourceProject.url = '/project';
|
||||
|
||||
let editSourceProject = _.cloneDeep(inventorySourcesProjectRoute);
|
||||
editSourceProject.name = 'inventories.edit.inventory_sources.edit.project';
|
||||
editSourceProject.url = '/project';
|
||||
|
||||
let editSourceInventoryScript = _.cloneDeep(inventorySourcesInventoryScriptRoute);
|
||||
editSourceInventoryScript.name = 'inventories.edit.inventory_sources.edit.inventory_script';
|
||||
editSourceInventoryScript.url = '/inventory_script';
|
||||
@ -271,7 +280,9 @@ angular.module('inventory', [
|
||||
stateExtender.buildDefinition(addSourceCredential),
|
||||
stateExtender.buildDefinition(addSourceInventoryScript),
|
||||
stateExtender.buildDefinition(editSourceCredential),
|
||||
stateExtender.buildDefinition(editSourceInventoryScript)
|
||||
stateExtender.buildDefinition(editSourceInventoryScript),
|
||||
stateExtender.buildDefinition(addSourceProject),
|
||||
stateExtender.buildDefinition(editSourceProject)
|
||||
])
|
||||
};
|
||||
});
|
||||
|
||||
@ -256,7 +256,7 @@ export default ['$state', '$stateParams', '$scope', 'ParseVariableString',
|
||||
|
||||
function initSourceSelect() {
|
||||
$scope.source = _.find($scope.source_type_options, { value: inventorySourceData.source });
|
||||
var source = $scope.source.value;
|
||||
var source = $scope.source && $scope.source.value ? $scope.source.value : null;
|
||||
|
||||
CreateSelect2({
|
||||
element: '#inventory_source_source',
|
||||
|
||||
@ -8,12 +8,13 @@
|
||||
'InventoryUpdate', 'CancelSourceUpdate',
|
||||
'ViewUpdateStatus', 'rbacUiControlService', 'GetBasePath',
|
||||
'GetSyncStatusMsg', 'Dataset', 'Find', 'QuerySet',
|
||||
'inventoryData', '$filter', 'Prompt', 'Wait', 'SourcesService', 'inventorySourceOptions', 'canAdd',
|
||||
'inventoryData', '$filter', 'Prompt', 'Wait', 'SourcesService', 'inventorySourceOptions',
|
||||
'canAdd', 'hasSyncableSources',
|
||||
function($scope, $rootScope, $state, $stateParams, SourcesListDefinition,
|
||||
InventoryUpdate, CancelSourceUpdate,
|
||||
ViewUpdateStatus, rbacUiControlService, GetBasePath, GetSyncStatusMsg,
|
||||
Dataset, Find, qs, inventoryData, $filter, Prompt,
|
||||
Wait, SourcesService, inventorySourceOptions, canAdd){
|
||||
Wait, SourcesService, inventorySourceOptions, canAdd, hasSyncableSources){
|
||||
|
||||
let list = SourcesListDefinition;
|
||||
var inventory_source;
|
||||
@ -24,6 +25,7 @@
|
||||
$scope.inventory_id = $stateParams.inventory_id;
|
||||
$scope.canAdhoc = inventoryData.summary_fields.user_capabilities.adhoc;
|
||||
$scope.canAdd = canAdd;
|
||||
$scope.showSyncAll = hasSyncableSources;
|
||||
|
||||
// Search init
|
||||
$scope.list = list;
|
||||
@ -121,8 +123,8 @@
|
||||
Wait('start');
|
||||
SourcesService.delete(inventory_source.id).then(() => {
|
||||
$('#prompt-modal').modal('hide');
|
||||
if (parseInt($state.params.source_id) === inventory_source) {
|
||||
$state.go("sources", null, {reload: true});
|
||||
if (parseInt($state.params.inventory_source_id) === inventory_source.id) {
|
||||
$state.go("inventories.edit.inventory_sources", {inventory_id: $scope.inventory_id}, {reload: true});
|
||||
} else {
|
||||
$state.go($state.current.name, null, {reload: true});
|
||||
}
|
||||
@ -161,4 +163,12 @@
|
||||
$state.go('inventories.edit.inventory_sources.edit.schedules', {inventory_source_id: id}, {reload: true});
|
||||
};
|
||||
|
||||
$scope.syncAllSources = function() {
|
||||
InventoryUpdate({
|
||||
scope: $scope,
|
||||
url: inventoryData.related.update_inventory_sources,
|
||||
updateAllSources: true
|
||||
});
|
||||
};
|
||||
|
||||
}];
|
||||
|
||||
@ -69,6 +69,24 @@ export default {
|
||||
.catch(function() {
|
||||
return false;
|
||||
});
|
||||
}],
|
||||
hasSyncableSources: ['InventoryManageService', '$stateParams', function(InventoryManageService, $stateParams) {
|
||||
return InventoryManageService.updateInventorySourcesGet($stateParams.inventory_id)
|
||||
.then(function(res) {
|
||||
let canUpdateFound = false;
|
||||
if(res.data && res.data.length > 0) {
|
||||
res.data.forEach(function(source) {
|
||||
if(source.can_update) {
|
||||
canUpdateFound = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return canUpdateFound;
|
||||
})
|
||||
.catch(function() {
|
||||
return false;
|
||||
});
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
@ -0,0 +1,50 @@
|
||||
export default {
|
||||
params: {
|
||||
project_search: {
|
||||
value: {
|
||||
page_size:"5",
|
||||
order_by:"name",
|
||||
role_level:"use_role",
|
||||
},
|
||||
dynamic:true,
|
||||
squash:""
|
||||
}
|
||||
},
|
||||
data: {
|
||||
basePath:"projects",
|
||||
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: ['ProjectList', function(list) {
|
||||
return list;
|
||||
}],
|
||||
Dataset: ['ListDefinition', 'QuerySet', '$stateParams', 'GetBasePath',
|
||||
(list, qs, $stateParams, GetBasePath) => {
|
||||
return qs.search(GetBasePath('projects'), $stateParams[`${list.iterator}_search`]);
|
||||
}
|
||||
]
|
||||
},
|
||||
onExit: function($state) {
|
||||
if ($state.transition) {
|
||||
$('#form-modal').modal('hide');
|
||||
$('.modal-backdrop').remove();
|
||||
$('body').removeClass('modal-open');
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -52,6 +52,15 @@ export default {
|
||||
actionClass: 'btn List-buttonDefault',
|
||||
buttonContent: 'REFRESH'
|
||||
},
|
||||
sync_all: {
|
||||
mode: 'all',
|
||||
awToolTip: "Sync all inventory sources",
|
||||
ngClick: "syncAllSources()",
|
||||
ngShow: "showSyncAll",
|
||||
actionClass: 'btn List-buttonDefault',
|
||||
buttonContent: 'SYNC ALL',
|
||||
dataPlacement: "top"
|
||||
},
|
||||
create: {
|
||||
mode: 'all',
|
||||
ngClick: "createSource()",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user