From 3bcb4b0496738e1ac0a9994fc50d19588fe40cc9 Mon Sep 17 00:00:00 2001 From: jaredevantabor Date: Wed, 5 Apr 2017 16:46:12 -0700 Subject: [PATCH] adjustments to host list adding Inventory column and disabling host toggle for external sources --- .../src/inventoriesnew/hosts/host.list.js | 13 +++++++--- .../hosts/list/host-list.controller.js | 26 ++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/awx/ui/client/src/inventoriesnew/hosts/host.list.js b/awx/ui/client/src/inventoriesnew/hosts/host.list.js index 632a38129b..283ce28779 100644 --- a/awx/ui/client/src/inventoriesnew/hosts/host.list.js +++ b/awx/ui/client/src/inventoriesnew/hosts/host.list.js @@ -21,7 +21,7 @@ export default ['i18n', function(i18n) { fields: { toggleHost: { - ngDisabled: "!host.summary_fields.user_capabilities.edit", + ngDisabled: 'host.has_inventory_sources', label: '', columnClass: 'List-staticColumn--toggle', type: "toggle", @@ -54,13 +54,20 @@ export default ['i18n', function(i18n) { }, name: { key: true, - label: 'Name', + label: i18n._('Name'), ngClick: "editHost(host.id)", columnClass: 'col-lg-6 col-md-8 col-sm-8 col-xs-7', dataHostId: "{{ host.id }}", dataType: "host", class: 'InventoryManage-breakWord' - } + }, + inventory_name: { + label: i18n._('Inventory'), + sourceModel: 'inventory', + sourceField: 'name', + columnClass: 'col-lg-5 col-md-4 col-sm-4 hidden-xs elllipsis', + linkTo: "{{ '/#/inventories/' + host.inventory_id }}" + }, }, fieldActions: { diff --git a/awx/ui/client/src/inventoriesnew/hosts/list/host-list.controller.js b/awx/ui/client/src/inventoriesnew/hosts/list/host-list.controller.js index 3f5ac46872..92c0f2befe 100644 --- a/awx/ui/client/src/inventoriesnew/hosts/list/host-list.controller.js +++ b/awx/ui/client/src/inventoriesnew/hosts/list/host-list.controller.js @@ -5,7 +5,8 @@ *************************************************/ function HostsList($scope, HostsNewList, $rootScope, GetBasePath, - rbacUiControlService, Dataset, $state, $filter, Prompt, Wait, HostManageService) { + rbacUiControlService, Dataset, $state, $filter, Prompt, Wait, + HostManageService, SetStatus) { let list = HostsNewList; @@ -26,6 +27,24 @@ function HostsList($scope, HostsNewList, $rootScope, GetBasePath, $rootScope.flashMessage = null; + $scope.$watchCollection(list.name, function() { + $scope[list.name] = _.map($scope.hosts, function(value) { + value.inventory_name = value.summary_fields.inventory.name; + value.inventory_id = value.summary_fields.inventory.id; + return value; + }); + setJobStatus(); + }); + + } + + function setJobStatus(){ + _.forEach($scope.hosts, function(value) { + SetStatus({ + scope: $scope, + host: value + }); + }); } $scope.createHost = function(){ @@ -58,7 +77,7 @@ function HostsList($scope, HostsNewList, $rootScope, GetBasePath, }); $rootScope.promptActionBtnClass = 'Modal-errorButton'; }; - + $scope.toggleHost = function(event, host) { try { $(event.target).tooltip('hide'); @@ -76,5 +95,6 @@ function HostsList($scope, HostsNewList, $rootScope, GetBasePath, } export default ['$scope', 'HostsNewList', '$rootScope', 'GetBasePath', - 'rbacUiControlService', 'Dataset', '$state', '$filter', 'Prompt', 'Wait', 'HostManageService', HostsList + 'rbacUiControlService', 'Dataset', '$state', '$filter', 'Prompt', 'Wait', + 'HostManageService', 'SetStatus', HostsList ];