mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 04:10:44 -03:30
commit
600089d689
@ -20,7 +20,7 @@ export default ['$scope', 'ListDefinition', 'Dataset', 'Wait', 'Rest', 'ProcessE
|
||||
$('#prompt-modal').modal('hide');
|
||||
Wait('start');
|
||||
Rest.setUrl(url);
|
||||
Rest.post({ "disassociate": true, "id": userId })
|
||||
Rest.post({ "disassociate": true, "id": Number(userId) })
|
||||
.success(function() {
|
||||
Wait('stop');
|
||||
$state.go('.', null, {reload: true});
|
||||
|
||||
@ -5,8 +5,9 @@
|
||||
*************************************************/
|
||||
|
||||
export default [ 'InsightsData', '$scope', 'moment', '$state', 'InventoryData',
|
||||
'InsightsService',
|
||||
function (data, $scope, moment, $state, InventoryData, InsightsService) {
|
||||
'InsightsService', 'CanRemediate',
|
||||
function (data, $scope, moment, $state, InventoryData, InsightsService,
|
||||
CanRemediate) {
|
||||
|
||||
function init() {
|
||||
$scope.reports = (data && data.reports) ? data.reports : [];
|
||||
@ -24,7 +25,7 @@ function (data, $scope, moment, $state, InventoryData, InsightsService) {
|
||||
$scope.insights_credential = (InventoryData && InventoryData.summary_fields &&
|
||||
InventoryData.summary_fields.insights_credential && InventoryData.summary_fields.insights_credential.id) ?
|
||||
InventoryData.summary_fields.insights_credential.id : null;
|
||||
|
||||
$scope.canRemediate = CanRemediate;
|
||||
}
|
||||
|
||||
function filter(str){
|
||||
|
||||
@ -61,7 +61,7 @@
|
||||
|
||||
<div class="InsightsBody">
|
||||
<div class="InsightsBody-missingIssues" ng-show="reports.length===0 && insights_credential" translate>
|
||||
No data is available. Either there are no issues to report or no scan jobs have been run on this host.
|
||||
No data is available. There are no issues to report.
|
||||
</div>
|
||||
<div class="InsightsBody-missingIssues" ng-show="!insights_credential" translate>
|
||||
The Insights Credential for {{inventory.name}} was not found.
|
||||
@ -88,6 +88,6 @@
|
||||
|
||||
<div class="buttons Form-buttons">
|
||||
<button type="button" class="btn btn-sm Form-primaryButton" ng-click="viewDataInInsights()"> <i class="fa fa-sign-out"></i> VIEW DATA IN INSIGHTS</button>
|
||||
<button type="button" class="btn btn-sm Form-primaryButton" ng-click="remediateInventory(inventory.id, insights_credential)" ng-hide="reports.length === 0 || !insights_credential"> REMEDIATE INVENTORY</button>
|
||||
<button type="button" class="btn btn-sm Form-primaryButton" ng-click="remediateInventory(inventory.id, insights_credential)" ng-hide="reports.length === 0 || !insights_credential || !canRemediate"> REMEDIATE INVENTORY</button>
|
||||
<button type="button" class="btn btn-sm Form-cancelButton Insights-cancelButton" ng-click="formCancel()"> Close</button>
|
||||
</div>
|
||||
|
||||
@ -49,6 +49,50 @@ export default {
|
||||
return resourceData.data;
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
checkProjectPermission: ['InventoryData', '$stateParams', 'Rest', 'GetBasePath',
|
||||
function(InventoryData, $stateParams, Rest, GetBasePath){
|
||||
if(_.has(InventoryData, 'summary_fields.insights_credential')){
|
||||
let credential_id = InventoryData.summary_fields.insights_credential.id,
|
||||
path = `${GetBasePath('projects')}?credential__id=${credential_id}&role_level=use_role`;
|
||||
Rest.setUrl(path);
|
||||
return Rest.get().then(({data}) => {
|
||||
if (data.results.length > 0){
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}).catch(() => {
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}],
|
||||
checkInventoryPermission: ['InventoryData', '$stateParams', 'Rest', 'GetBasePath',
|
||||
function(InventoryData, $stateParams, Rest, GetBasePath){
|
||||
if(_.has(InventoryData, 'summary_fields.insights_credential')){
|
||||
let path = `${GetBasePath('inventory')}${InventoryData.id}/?role_level=use_role`;
|
||||
Rest.setUrl(path);
|
||||
return Rest.get().then(() => {
|
||||
return true;
|
||||
}).catch(() => {
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}],
|
||||
CanRemediate: ['checkProjectPermission', 'checkInventoryPermission',
|
||||
function(checkProjectPermission, checkInventoryPermission){
|
||||
// the user can remediate an insights
|
||||
// inv if the user has "use" permission on
|
||||
// an insights project and the inventory
|
||||
// being edited:
|
||||
return checkProjectPermission === true && checkInventoryPermission === true;
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
@ -123,8 +123,53 @@ angular.module('inventory', [
|
||||
'status: ' + status
|
||||
});
|
||||
});
|
||||
}]
|
||||
}
|
||||
}],
|
||||
checkProjectPermission: ['resourceData', '$stateParams', 'Rest', 'GetBasePath',
|
||||
function(resourceData, $stateParams, Rest, GetBasePath){
|
||||
if(_.has(resourceData, 'data.summary_fields.insights_credential')){
|
||||
let credential_id = resourceData.data.summary_fields.insights_credential.id,
|
||||
path = `${GetBasePath('projects')}?credential__id=${credential_id}&role_level=use_role`;
|
||||
Rest.setUrl(path);
|
||||
return Rest.get().then(({data}) => {
|
||||
if (data.results.length > 0){
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}).catch(() => {
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}],
|
||||
checkInventoryPermission: ['resourceData', '$stateParams', 'Rest', 'GetBasePath',
|
||||
function(resourceData, $stateParams, Rest, GetBasePath){
|
||||
if(_.has(resourceData, 'data.summary_fields.insights_credential')){
|
||||
let path = `${GetBasePath('inventory')}${$stateParams.inventory_id}/?role_level=use_role`;
|
||||
Rest.setUrl(path);
|
||||
return Rest.get().then(() => {
|
||||
return true;
|
||||
}).catch(() => {
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}],
|
||||
CanRemediate: ['checkProjectPermission', 'checkInventoryPermission',
|
||||
function(checkProjectPermission, checkInventoryPermission){
|
||||
// the user can remediate an insights
|
||||
// inv if the user has "use" permission on
|
||||
// an insights project and the inventory
|
||||
// being edited:
|
||||
return checkProjectPermission === true && checkInventoryPermission === true;
|
||||
}]
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
function InventoriesEdit($scope, $location,
|
||||
$stateParams, InventoryForm, Rest, ProcessErrors,
|
||||
GetBasePath, ParseTypeChange, Wait, ToJSON,
|
||||
ParseVariableString, $state, OrgAdminLookup, $rootScope, resourceData, CreateSelect2, InstanceGroupsService, InstanceGroupsData) {
|
||||
ParseVariableString, $state, OrgAdminLookup, $rootScope, resourceData,
|
||||
CreateSelect2, InstanceGroupsService, InstanceGroupsData, CanRemediate) {
|
||||
|
||||
// Inject dynamic view
|
||||
let defaultUrl = GetBasePath('inventory'),
|
||||
@ -37,6 +38,7 @@ function InventoriesEdit($scope, $location,
|
||||
$scope.inventory_variables = inventoryData.variables === null || inventoryData.variables === '' ? '---' : ParseVariableString(inventoryData.variables);
|
||||
$scope.parseType = 'yaml';
|
||||
$scope.instance_groups = InstanceGroupsData;
|
||||
$scope.canRemediate = CanRemediate;
|
||||
|
||||
$rootScope.$on('$stateChangeSuccess', function(event, toState) {
|
||||
if(toState.name === 'inventories.edit') {
|
||||
@ -115,5 +117,6 @@ export default ['$scope', '$location',
|
||||
'$stateParams', 'InventoryForm', 'Rest',
|
||||
'ProcessErrors', 'GetBasePath', 'ParseTypeChange', 'Wait',
|
||||
'ToJSON', 'ParseVariableString',
|
||||
'$state', 'OrgAdminLookup', '$rootScope', 'resourceData', 'CreateSelect2', 'InstanceGroupsService', 'InstanceGroupsData', InventoriesEdit,
|
||||
'$state', 'OrgAdminLookup', '$rootScope', 'resourceData', 'CreateSelect2',
|
||||
'InstanceGroupsService', 'InstanceGroupsData', 'CanRemediate', InventoriesEdit,
|
||||
];
|
||||
|
||||
@ -201,7 +201,7 @@ function(i18n, InventoryCompletedJobsList) {
|
||||
relatedButtons: {
|
||||
remediate_inventory: {
|
||||
ngClick: 'remediateInventory(id, insights_credential)',
|
||||
ngShow: 'is_insights && mode !== "add"',
|
||||
ngShow: 'is_insights && mode !== "add" && canRemediate',
|
||||
label: i18n._('Remediate Inventory'),
|
||||
class: 'Form-primaryButton'
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user