diff --git a/awx/ui/client/src/helpers/Hosts.js b/awx/ui/client/src/helpers/Hosts.js index efc3cad8bf..1bd62c955c 100644 --- a/awx/ui/client/src/helpers/Hosts.js +++ b/awx/ui/client/src/helpers/Hosts.js @@ -236,47 +236,6 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', listGenerator.name, }; }]) -.factory('ToggleHostEnabled', [ 'GetBasePath', 'Rest', 'Wait', 'ProcessErrors', 'Alert', 'Find', 'SetEnabledMsg', - function(GetBasePath, Rest, Wait, ProcessErrors, Alert, Find, SetEnabledMsg) { - return function(params) { - - var id = params.host_id, - external_source = params.external_source, - parent_scope = params.parent_scope, - host_scope = params.host_scope, - host; - - function setMsg(host) { - host.enabled = (host.enabled) ? false : true; - host.enabled_flag = host.enabled; - SetEnabledMsg(host); - } - - if (!external_source) { - // Host is not managed by an external source - Wait('start'); - host = Find({ list: host_scope.hosts, key: 'id', val: id }); - setMsg(host); - - Rest.setUrl(GetBasePath('hosts') + id + '/'); - Rest.put(host) - .success( function() { - Wait('stop'); - }) - .error( function(data, status) { - // Flip the enabled flag back - setMsg(host); - ProcessErrors(parent_scope, data, status, null, - { hdr: 'Error!', msg: 'Failed to update host. PUT returned status: ' + status }); - }); - } - else { - Alert('Action Not Allowed', 'This host is managed by an external cloud source. Disable it at the external source, ' + - 'then run an inventory sync to update Tower with the new status.', 'alert-info'); - } - }; - }]) - .factory('HostsList', ['$rootScope', '$location', '$log', '$stateParams', 'Rest', 'Alert', 'HostList', 'generateList', 'Prompt', 'SearchInit', 'PaginateInit', 'ProcessErrors', 'GetBasePath', 'HostsAdd', 'HostsReload', 'SelectionInit', function($rootScope, $location, $log, $stateParams, Rest, Alert, HostList, GenerateList, Prompt, SearchInit, diff --git a/awx/ui/client/src/inventories/manage/inventory-manage.controller.js b/awx/ui/client/src/inventories/manage/inventory-manage.controller.js index 96dd9a9936..2f2a62e8d5 100644 --- a/awx/ui/client/src/inventories/manage/inventory-manage.controller.js +++ b/awx/ui/client/src/inventories/manage/inventory-manage.controller.js @@ -16,7 +16,7 @@ function InventoriesManage($log, $scope, $rootScope, $location, InjectHosts, Find, HostsReload, SearchInit, PaginateInit, GetSyncStatusMsg, GetHostsStatusMsg, GroupsEdit, InventoryUpdate, GroupsCancelUpdate, ViewUpdateStatus, GroupsDelete, Store, HostsEdit, HostsDelete, - EditInventoryProperties, ToggleHostEnabled, ShowJobSummary, + EditInventoryProperties, ShowJobSummary, InventoryGroupsHelp, HelpDialog, GroupsCopy, HostsCopy, $stateParams, ParamPass) { @@ -331,8 +331,15 @@ function InventoriesManage($log, $scope, $rootScope, $location, } groups.push(group.id); groups = groups.join(); - $state.transitionTo('inventoryManage', {inventory_id: $state.params.inventory_id, groups: groups}, { notify: false }); + $state.transitionTo('inventoryManage', {inventory_id: $state.params.inventory_id, groups: groups}, { notify: false}); loadGroups(group.related.children, group.id); + $scope.selected_group_id = group.id; + HostsReload({ + scope: hostScope, + group_id: $scope.selected_group_id, + inventory_id: $scope.inventory.id, + pageSize: hostScope.host_page_size + }); }; $scope.createGroup = function () { @@ -470,15 +477,6 @@ function InventoriesManage($log, $scope, $rootScope, $location, $state.go('inventoryManage.copy.host', {host_id: id}); }; - hostScope.toggleHostEnabled = function (host_id, external_source) { - ToggleHostEnabled({ - parent_scope: $scope, - host_scope: hostScope, - host_id: host_id, - external_source: external_source - }); - }; - hostScope.showJobSummary = function (job_id) { ShowJobSummary({ job_id: job_id @@ -527,7 +525,6 @@ export default [ 'SearchInit', 'PaginateInit', 'GetSyncStatusMsg', 'GetHostsStatusMsg', 'GroupsEdit', 'InventoryUpdate', 'GroupsCancelUpdate', 'ViewUpdateStatus', 'GroupsDelete', 'Store', 'HostsEdit', 'HostsDelete', - 'EditInventoryProperties', 'ToggleHostEnabled', 'ShowJobSummary', - 'InventoryGroupsHelp', 'HelpDialog', 'GroupsCopy', + 'EditInventoryProperties', 'ShowJobSummary', 'InventoryGroupsHelp', 'HelpDialog', 'GroupsCopy', 'HostsCopy', '$stateParams', 'ParamPass', InventoriesManage, ]; diff --git a/awx/ui/client/src/inventories/manage/inventory-manage.route.js b/awx/ui/client/src/inventories/manage/inventory-manage.route.js index 1aa1407409..62306cd91b 100644 --- a/awx/ui/client/src/inventories/manage/inventory-manage.route.js +++ b/awx/ui/client/src/inventories/manage/inventory-manage.route.js @@ -9,7 +9,7 @@ import InventoriesManage from './inventory-manage.controller'; export default { name: 'inventoryManage', - url: '/inventories/:inventory_id/manage', + url: '/inventories/:inventory_id/manage?groups', templateUrl: templateUrl('inventories/manage/inventory-manage'), controller: InventoriesManage, data: { diff --git a/awx/ui/client/src/inventories/manage/inventory-manage.service.js b/awx/ui/client/src/inventories/manage/inventory-manage.service.js deleted file mode 100644 index 4332f1ecf4..0000000000 --- a/awx/ui/client/src/inventories/manage/inventory-manage.service.js +++ /dev/null @@ -1,23 +0,0 @@ -/************************************************* - * Copyright (c) 2016 Ansible, Inc. - * - * All Rights Reserved - *************************************************/ - - export default - ['$rootScope', 'Rest', 'GetBasePath', 'ProcessErrors', function($rootScope, Rest, GetBasePath, ProcessErrors){ - return { - getRootGroups: function(id){ - var url = GetBasePath('inventory') + id + '/root_groups/'; - Rest.setUrl(url); - return Rest.get() - .success(function(data){ - return data.results; - }) - .error(function(data, status) { - ProcessErrors($rootScope, data, status, null, { hdr: 'Error!', - msg: 'Call to ' + url + '. GET returned: ' + status }); - }); - } - }; - }]; \ No newline at end of file diff --git a/awx/ui/client/src/inventories/manage/manage-hosts/manage-hosts-add.controller.js b/awx/ui/client/src/inventories/manage/manage-hosts/manage-hosts-add.controller.js index ebaeefd010..0cad2dc9fa 100644 --- a/awx/ui/client/src/inventories/manage/manage-hosts/manage-hosts-add.controller.js +++ b/awx/ui/client/src/inventories/manage/manage-hosts/manage-hosts-add.controller.js @@ -5,19 +5,19 @@ *************************************************/ export default - ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'ManageHostsService', - function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, ManageHostsService){ - var generator = GenerateForm, - form = HostForm; - $scope.parseType = 'yaml'; + ['$state', '$stateParams', '$scope', 'HostForm', 'ParseTypeChange', 'GenerateForm', 'ManageHostsService', + function($state, $stateParams, $scope, HostForm, ParseTypeChange, GenerateForm, ManageHostsService){ + var generator = GenerateForm, + form = HostForm; + $scope.parseType = 'yaml'; $scope.extraVars = '---'; - $scope.formCancel = function(){ - $state.go('^', null, {reload: true}); - }; - $scope.toggleEnabled = function(){ - $scope.host.enabled = !$scope.host.enabled; - }; - $scope.formSave = function(){; + $scope.formCancel = function(){ + $state.go('^', null, {reload: true}); + }; + $scope.toggleEnabled = function(){ + $scope.host.enabled = !$scope.host.enabled; + }; + $scope.formSave = function(){; var params = { variables: $scope.extraVars === '---' || $scope.extraVars === '{}' ? null : $scope.extraVars, name: $scope.name, @@ -28,15 +28,15 @@ ManageHostsService.post(params).then(function(res){ $state.go('^', null, {reload: true}); }); - }; - var init = function(){ - $scope.host = {enabled: true}; + }; + var init = function(){ + $scope.host = {enabled: true}; generator.inject(form, {mode: 'add', related: false, id: 'Inventory-hostManage--panel', scope: $scope}); ParseTypeChange({ scope: $scope, field_id: 'host_variables', variable: 'extraVars', }); - }; - init(); - }]; \ No newline at end of file + }; + init(); + }]; \ No newline at end of file