mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02: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:
@@ -62,6 +62,13 @@
|
|||||||
return Rest.options()
|
return Rest.options()
|
||||||
.success(this.success.bind(this))
|
.success(this.success.bind(this))
|
||||||
.error(this.error.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: {
|
fieldActions: {
|
||||||
|
|
||||||
columnClass: 'col-md-2 col-sm-3 col-xs-4',
|
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: {
|
edit: {
|
||||||
label: i18n._('Edit'),
|
label: i18n._('Edit'),
|
||||||
ngClick: 'editInventory(inventory)',
|
ngClick: 'editInventory(inventory)',
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
function InventoriesList($scope,
|
function InventoriesList($scope,
|
||||||
$filter, Rest, InventoryList, Prompt,
|
$filter, Rest, InventoryList, Prompt,
|
||||||
ProcessErrors, GetBasePath, Wait, $state,
|
ProcessErrors, GetBasePath, Wait, $state,
|
||||||
Dataset, InventoryUpdate, canAdd) {
|
Dataset, canAdd) {
|
||||||
|
|
||||||
let list = InventoryList,
|
let list = InventoryList,
|
||||||
defaultUrl = GetBasePath('inventory');
|
defaultUrl = GetBasePath('inventory');
|
||||||
@@ -107,18 +107,10 @@ function InventoriesList($scope,
|
|||||||
actionText: 'DELETE'
|
actionText: 'DELETE'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.syncInventory = function(inventory) {
|
|
||||||
InventoryUpdate({
|
|
||||||
scope: $scope,
|
|
||||||
url: inventory.related.update_inventory_sources,
|
|
||||||
updateAllSources: true
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ['$scope',
|
export default ['$scope',
|
||||||
'$filter', 'Rest', 'InventoryList', 'Prompt',
|
'$filter', 'Rest', 'InventoryList', 'Prompt',
|
||||||
'ProcessErrors', 'GetBasePath', 'Wait',
|
'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 hostGroupsAssociateRoute from './host-groups/host-groups-associate/host-groups-associate.route';
|
||||||
import inventorySourcesCredentialRoute from './sources/lookup/sources-lookup-credential.route';
|
import inventorySourcesCredentialRoute from './sources/lookup/sources-lookup-credential.route';
|
||||||
import inventorySourcesInventoryScriptRoute from './sources/lookup/sources-lookup-inventory-script.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 SmartInventory from './smart-inventory/main';
|
||||||
import StandardInventory from './standard/main';
|
import StandardInventory from './standard/main';
|
||||||
|
|
||||||
@@ -202,6 +203,14 @@ angular.module('inventory', [
|
|||||||
editSourceCredential.name = 'inventories.edit.inventory_sources.edit.credential';
|
editSourceCredential.name = 'inventories.edit.inventory_sources.edit.credential';
|
||||||
editSourceCredential.url = '/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);
|
let editSourceInventoryScript = _.cloneDeep(inventorySourcesInventoryScriptRoute);
|
||||||
editSourceInventoryScript.name = 'inventories.edit.inventory_sources.edit.inventory_script';
|
editSourceInventoryScript.name = 'inventories.edit.inventory_sources.edit.inventory_script';
|
||||||
editSourceInventoryScript.url = '/inventory_script';
|
editSourceInventoryScript.url = '/inventory_script';
|
||||||
@@ -271,7 +280,9 @@ angular.module('inventory', [
|
|||||||
stateExtender.buildDefinition(addSourceCredential),
|
stateExtender.buildDefinition(addSourceCredential),
|
||||||
stateExtender.buildDefinition(addSourceInventoryScript),
|
stateExtender.buildDefinition(addSourceInventoryScript),
|
||||||
stateExtender.buildDefinition(editSourceCredential),
|
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() {
|
function initSourceSelect() {
|
||||||
$scope.source = _.find($scope.source_type_options, { value: inventorySourceData.source });
|
$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({
|
CreateSelect2({
|
||||||
element: '#inventory_source_source',
|
element: '#inventory_source_source',
|
||||||
|
|||||||
@@ -8,12 +8,13 @@
|
|||||||
'InventoryUpdate', 'CancelSourceUpdate',
|
'InventoryUpdate', 'CancelSourceUpdate',
|
||||||
'ViewUpdateStatus', 'rbacUiControlService', 'GetBasePath',
|
'ViewUpdateStatus', 'rbacUiControlService', 'GetBasePath',
|
||||||
'GetSyncStatusMsg', 'Dataset', 'Find', 'QuerySet',
|
'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,
|
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){
|
Wait, SourcesService, inventorySourceOptions, canAdd, hasSyncableSources){
|
||||||
|
|
||||||
let list = SourcesListDefinition;
|
let list = SourcesListDefinition;
|
||||||
var inventory_source;
|
var inventory_source;
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
$scope.inventory_id = $stateParams.inventory_id;
|
$scope.inventory_id = $stateParams.inventory_id;
|
||||||
$scope.canAdhoc = inventoryData.summary_fields.user_capabilities.adhoc;
|
$scope.canAdhoc = inventoryData.summary_fields.user_capabilities.adhoc;
|
||||||
$scope.canAdd = canAdd;
|
$scope.canAdd = canAdd;
|
||||||
|
$scope.showSyncAll = hasSyncableSources;
|
||||||
|
|
||||||
// Search init
|
// Search init
|
||||||
$scope.list = list;
|
$scope.list = list;
|
||||||
@@ -121,8 +123,8 @@
|
|||||||
Wait('start');
|
Wait('start');
|
||||||
SourcesService.delete(inventory_source.id).then(() => {
|
SourcesService.delete(inventory_source.id).then(() => {
|
||||||
$('#prompt-modal').modal('hide');
|
$('#prompt-modal').modal('hide');
|
||||||
if (parseInt($state.params.source_id) === inventory_source) {
|
if (parseInt($state.params.inventory_source_id) === inventory_source.id) {
|
||||||
$state.go("sources", null, {reload: true});
|
$state.go("inventories.edit.inventory_sources", {inventory_id: $scope.inventory_id}, {reload: true});
|
||||||
} else {
|
} else {
|
||||||
$state.go($state.current.name, null, {reload: true});
|
$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});
|
$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() {
|
.catch(function() {
|
||||||
return false;
|
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',
|
actionClass: 'btn List-buttonDefault',
|
||||||
buttonContent: 'REFRESH'
|
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: {
|
create: {
|
||||||
mode: 'all',
|
mode: 'all',
|
||||||
ngClick: "createSource()",
|
ngClick: "createSource()",
|
||||||
|
|||||||
Reference in New Issue
Block a user