making request for inventory information

for remediation flow
This commit is contained in:
Jared Tabor 2017-07-26 17:21:59 -07:00
parent d00ccfc442
commit b97fe33152
6 changed files with 23 additions and 15 deletions

View File

@ -42,8 +42,8 @@ function (data, $scope, moment, $state, InventoryData, InsightsService) {
window.open(`https://access.redhat.com/insights/inventory?machine=${$scope.$parent.host.insights_system_id}`, '_blank');
};
$scope.remediateInventory = function(inv_id, inv_name, insights_credential){
$state.go('templates.addJobTemplate', {inventory_id: inv_id, inventory_name:inv_name, credential_id: insights_credential});
$scope.remediateInventory = function(inv_id, insights_credential){
$state.go('templates.addJobTemplate', {inventory_id: inv_id, credential_id: insights_credential});
};
$scope.formCancel = function(){

View File

@ -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, inventory.name, 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"> REMEDIATE INVENTORY</button>
<button type="button" class="btn btn-sm Form-cancelButton Insights-cancelButton" ng-click="formCancel()"> Close</button>
</div>

View File

@ -105,8 +105,8 @@ function InventoriesEdit($scope, $location,
$state.go('inventories');
};
$scope.remediateInventory = function(inv_id, inv_name, insights_credential){
$state.go('templates.addJobTemplate', {inventory_id: inv_id, inventory_name:inv_name, credential_id: insights_credential});
$scope.remediateInventory = function(inv_id, insights_credential){
$state.go('templates.addJobTemplate', {inventory_id: inv_id, credential_id: insights_credential});
};
}

View File

@ -200,7 +200,7 @@ function(i18n, InventoryCompletedJobsList) {
},
relatedButtons: {
remediate_inventory: {
ngClick: 'remediateInventory(id, name, insights_credential)',
ngClick: 'remediateInventory(id, insights_credential)',
ngShow: 'is_insights && mode !== "add"',
label: i18n._('Remediate Inventory'),
class: 'Form-primaryButton'

View File

@ -197,8 +197,8 @@
};
if(Inventory){
$scope.inventory = Inventory.inventory_id;
$scope.inventory_name = Inventory.inventory_name;
$scope.inventory = Inventory.id;
$scope.inventory_name = Inventory.name;
}
if(Project){
$scope.project = Project.id;

View File

@ -44,7 +44,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates.
addJobTemplate = stateDefinitions.generateTree({
name: 'templates.addJobTemplate',
url: '/add_job_template?inventory_id&inventory_name&credential_id',
url: '/add_job_template?inventory_id&credential_id',
modes: ['add'],
form: 'JobTemplateForm',
controllers: {
@ -52,13 +52,21 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates.
},
resolve: {
add: {
Inventory: ['$stateParams',
function($stateParams){
Inventory: ['$stateParams', 'Rest', 'GetBasePath', 'ProcessErrors',
function($stateParams, Rest, GetBasePath, ProcessErrors){
if($stateParams.inventory_id){
let obj = {};
obj.inventory_id = Number($stateParams.inventory_id);
obj.inventory_name = $stateParams.inventory_name;
return obj;
let path = `${GetBasePath('inventory')}${$stateParams.inventory_id}`;
Rest.setUrl(path);
return Rest.get().
then(function(data){
return data.data;
}).catch(function(response) {
ProcessErrors(null, response.data, response.status, null, {
hdr: 'Error!',
msg: 'Failed to get inventory info. GET returned status: ' +
response.status
});
});
}
}],
Project: ['$stateParams', 'Rest', 'GetBasePath', 'ProcessErrors',