From b97fe3315239878aeb03d57ed721ba78862e263b Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 26 Jul 2017 17:21:59 -0700 Subject: [PATCH] making request for inventory information for remediation flow --- .../insights/insights.controller.js | 4 ++-- .../insights/insights.partial.html | 2 +- .../edit/inventory-edit.controller.js | 4 ++-- .../standard-inventory/inventory.form.js | 2 +- .../job-template-add.controller.js | 4 ++-- awx/ui/client/src/templates/main.js | 22 +++++++++++++------ 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/awx/ui/client/src/inventories-hosts/inventories/insights/insights.controller.js b/awx/ui/client/src/inventories-hosts/inventories/insights/insights.controller.js index 88c70ee00a..0e143d0b35 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/insights/insights.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/insights/insights.controller.js @@ -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(){ diff --git a/awx/ui/client/src/inventories-hosts/inventories/insights/insights.partial.html b/awx/ui/client/src/inventories-hosts/inventories/insights/insights.partial.html index f89fb237f8..5bd39fb816 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/insights/insights.partial.html +++ b/awx/ui/client/src/inventories-hosts/inventories/insights/insights.partial.html @@ -88,6 +88,6 @@
- +
diff --git a/awx/ui/client/src/inventories-hosts/inventories/standard-inventory/edit/inventory-edit.controller.js b/awx/ui/client/src/inventories-hosts/inventories/standard-inventory/edit/inventory-edit.controller.js index a709d5a919..2af0a612b0 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/standard-inventory/edit/inventory-edit.controller.js +++ b/awx/ui/client/src/inventories-hosts/inventories/standard-inventory/edit/inventory-edit.controller.js @@ -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}); }; } diff --git a/awx/ui/client/src/inventories-hosts/inventories/standard-inventory/inventory.form.js b/awx/ui/client/src/inventories-hosts/inventories/standard-inventory/inventory.form.js index 0be972390c..5ee49cf0b7 100644 --- a/awx/ui/client/src/inventories-hosts/inventories/standard-inventory/inventory.form.js +++ b/awx/ui/client/src/inventories-hosts/inventories/standard-inventory/inventory.form.js @@ -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' diff --git a/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js b/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js index 5e5fd2ae7d..85d7480957 100644 --- a/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js +++ b/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js @@ -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; diff --git a/awx/ui/client/src/templates/main.js b/awx/ui/client/src/templates/main.js index ecb07913c9..4ebb8f186b 100644 --- a/awx/ui/client/src/templates/main.js +++ b/awx/ui/client/src/templates/main.js @@ -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',