mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 21:21:21 -03:30
adding "canRemediate" flag to insights dashboard
This commit is contained in:
parent
a99818f7cd
commit
ba27ad07a1
@ -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){
|
||||
|
||||
@ -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;
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user