diff --git a/awx/ui/static/css/ansible-ui.css b/awx/ui/static/css/ansible-ui.css index 3daccf84e4..5912af227d 100644 --- a/awx/ui/static/css/ansible-ui.css +++ b/awx/ui/static/css/ansible-ui.css @@ -31,7 +31,7 @@ /* Attempt to make button heights consistent. For some reason success, info, etc. are taller than plain .btn */ - .btn-success, .btn-danger, .btn-info, .btn-primary { + .btn-success, .btn-danger, .btn-info, .btn-primary, .btn-warning { padding-top: 1px; padding-bottom: 2px; } diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index 7eaab2a2f6..f778bbed69 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -488,7 +488,13 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP } scope.deleteHost = function(host_id, host_name) { - HostsDelete({ scope: scope, "inventory_id": id, group_id: scope.group_id, host_id: host_id, host_name: host_name }); + HostsDelete({ scope: scope, "inventory_id": id, group_id: scope.group_id, host_id: host_id, host_name: host_name, + request: 'delete' }); + } + + scope.removeHost = function(host_id, host_name) { + HostsDelete({ scope: scope, "inventory_id": id, group_id: scope.group_id, host_id: host_id, host_name: host_name, + request: 'remove' }); } scope.showEvents = function(host_name, last_job) { diff --git a/awx/ui/static/js/forms/Inventories.js b/awx/ui/static/js/forms/Inventories.js index b26742ccf6..1e162fe329 100644 --- a/awx/ui/static/js/forms/Inventories.js +++ b/awx/ui/static/js/forms/Inventories.js @@ -156,12 +156,20 @@ angular.module('InventoryFormDefinition', []) awToolTip: 'Edit host', 'class': 'btn-inventory-edit' }, + "remove": { + ngClick: "removeHost(\{\{ host.id \}\}, '\{\{ host.name \}\}')", + icon: 'icon-minus-sign', + label: 'Remove', + "class": 'btn-success', + ngHide: "group_id === null || group_id === undefined", + awToolTip: 'Remove this host from the group, but leave it as part of the inventory under All Hosts' + }, "delete": { ngClick: "deleteHost(\{\{ host.id \}\}, '\{\{ host.name \}\}')", icon: 'icon-remove', label: 'Delete', "class": 'btn-danger', - awToolTip: 'Remove host' + awToolTip: 'Permanently remove this host from the inventory' } } } diff --git a/awx/ui/static/js/helpers/Hosts.js b/awx/ui/static/js/helpers/Hosts.js index 31ad6b04f4..65dfb20575 100644 --- a/awx/ui/static/js/helpers/Hosts.js +++ b/awx/ui/static/js/helpers/Hosts.js @@ -345,53 +345,62 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H function($rootScope, $location, $log, $routeParams, Rest, Alert, Prompt, ProcessErrors, GetBasePath, HostsReload) { return function(params) { - // Delete the selected host. Disassociates it from the group. - + // Remove the selected host from the current group by dissaciating + var scope = params.scope; var group_id = scope.group_id; var inventory_id = params.inventory_id; var host_id = params.host_id; - var host_name = params.host_name; - var url = (scope.group_id !== null) ? GetBasePath('groups') + scope.group_id + '/hosts/' : - GetBasePath('inventory') + inventory_id + '/hosts/'; - + var host_name = params.host_name; + var req = (params.request) ? params.request : null; + + var url = (scope.group_id == null || req == 'delete') ? GetBasePath('inventory') + inventory_id + '/hosts/' : + GetBasePath('groups') + scope.group_id + '/hosts/'; + var action_to_take = function() { if (scope.removeHostsReload) { scope.removeHostsReload(); } scope.removeHostsReload = scope.$on('hostsReload', function() { + $('#prompt-modal').modal('hide'); HostsReload(params); }); Rest.setUrl(url); Rest.post({ id: host_id, disassociate: 1 }) - .success( function(data, status, headers, config) { - $('#prompt-modal').modal('hide'); - scope.$emit('hostsReload'); - }) - .error( function(data, status, headers, config) { - $('#prompt-modal').modal('hide'); - scope.$emit('hostsReload'); - ProcessErrors(scope, data, status, null, - { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); - }); - }; + .success( function(data, status, headers, config) { + scope.$emit('hostsReload'); + }) + .error( function(data, status, headers, config) { + scope.$emit('hostsReload'); + ProcessErrors(scope, data, status, null, + { hdr: 'Error!', msg: 'Call to ' + url + ' failed. POST returned status: ' + status }); + }); + } //Force binds to work. Not working usual way. - if (scope.group_id !== null) { - $('#prompt-header').text('Remove Host from Group'); - $('#prompt-body').text('Are you sure you want to remove host ' + host_name + ' from the group?'); + if (scope.group_id == null || req == 'delete') { + scope['promptHeader'] = 'Delete Host'; + scope['promptBody'] = 'Are you sure you want to permanently delete ' + host_name + ' from the inventory?'; + scope['promptActionBtnClass'] = 'btn-danger'; } else { - $('#prompt-header').text('Delete Host'); - $('#prompt-body').text('Are you sure you want to permenantly remove host ' + host_name + '?'); + scope['promptHeader'] = 'Remove Host from Group'; + scope['promptBody'] = 'Are you sure you want to remove ' + host_name + ' from the group?'; + scope['promptActionBtnClass'] = 'btn-success'; } - $('#prompt-action-btn').addClass('btn-danger'); - scope.promptAction = action_to_take; // for some reason this binds? + + scope.promptAction = action_to_take; + $('#prompt-modal').modal({ backdrop: 'static', keyboard: true, show: true }); + + if (!scope.$$phase) { + scope.$digest(); + } + } }]) @@ -401,8 +410,11 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H return function(params) { // Rerfresh the Hosts view on right side of page scope = params.scope; + scope['hosts'] = null; + var url = (scope.group_id !== null) ? GetBasePath('groups') + scope.group_id + '/all_hosts/' : GetBasePath('inventory') + params.inventory_id + '/hosts/'; + var relatedSets = { hosts: { url: url, iterator: 'host' } }; RelatedSearchInit({ scope: params.scope, form: InventoryForm, relatedSets: relatedSets }); RelatedPaginateInit({ scope: params.scope, relatedSets: relatedSets }); diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index 0da879d8c3..98cee63aed 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -861,12 +861,12 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) if (form.related[itm].type == 'tree') { html += "
"; html += "
"; + html += ""; html += ""; - html += ""; html += "
diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index 6746dec3ff..a6768862d2 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -209,7 +209,7 @@