diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index 0d64318f14..266fe1150a 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -199,7 +199,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP ParseTypeChange(scope,'inventory_variables', 'inventoryParseType'); - $('#inventory-tabs a:first').tab('show'); //activate the groups tab + $('#inventory-tabs a:first').tab('show'); //activate the hosts tab scope['inventoryParseType'] = 'yaml'; scope['inventory_id'] = id; @@ -210,11 +210,16 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP scope.inventoryLoadedRemove(); } scope.inventoryLoadedRemove = scope.$on('inventoryLoaded', function() { + LoadSearchTree({ scope: scope, inventory_id: scope['inventory_id'] }); TreeInit(scope.TreeParams); + if (!scope.$$phase) { + scope.$digest(); + } }); LoadInventory({ scope: scope, doPostSteps: true }); $('#inventory-tabs a[href="#inventory-hosts"]').on('show.bs.tab', function() { + scope['hosts'] = null; LoadSearchTree({ scope: scope, inventory_id: scope['inventory_id'] }); if (!scope.$$phase) { scope.$digest(); @@ -402,9 +407,6 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP if (!scope.$$phase) { scope.$digest(); } - - //HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: scope['group_id'] }); - }); scope.addGroup = function() { @@ -423,7 +425,7 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP GroupsDelete({ scope: scope, "inventory_id": id, group_id: scope.group_id }); } - scope.selectHost = function() { + scope.addHost = function() { HostsList({ scope: scope, "inventory_id": id, group_id: scope.group_id }); } @@ -440,10 +442,10 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP request: 'delete' }); } - scope.removeHost = function(host_id, host_name) { + /* 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) { // When click on !Failed Events link, redirect to latest job/job_events for the host @@ -463,6 +465,16 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP scope.$on('refreshHost', function(e, group, title) { scope.groupTitle = title; scope.group_id = group; + if (scope.group_id == null) { + scope.hostAddHide = true; + scope.hostCreateHide = true; + scope.hostDeleteHide = true; + } + else { + scope.hostAddHide = false; + scope.hostCreateHide = false; + scope.hostDeleteHide = false; + } HostsReload({ scope: scope, inventory_id: scope['inventory_id'], group_id: group }); }); diff --git a/awx/ui/static/js/helpers/inventory.js b/awx/ui/static/js/helpers/inventory.js index cb694f1909..14c60fe97d 100644 --- a/awx/ui/static/js/helpers/inventory.js +++ b/awx/ui/static/js/helpers/inventory.js @@ -199,41 +199,41 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi }); $(tree_id).bind('move_node.jstree', function(e, data) { - // When user drags-n-drops a node, update the API + // When user drags-n-drops a node, update the API + Wait('start'); + var node, target, url, parent, inv_id, variables; node = $('#tree-view li[id="' + data.rslt.o[0].id + '"]'); // node being moved parent = $('#tree-view li[id="' + data.args[0].op[0].id + '"]'); //node moving from target = $('#tree-view li[id="' + data.rslt.np[0].id + '"]'); // node moving to inv_id = inventory_id; + + function cleanUp() { + Wait('stop'); + if (!scope.$$phase) { + scope.$digest(); + } + } if (scope.removeCopyVariables) { scope.removeCopyVariables(); } scope.removeCopyVariables = scope.$on('copyVariables', function(e, id, url) { - - function showSuccessMsg() { - var parent_descr = (parent.attr('type') == 'inventory') ? 'the inventory root' : parent.attr('name'); - var target_descr = (target.attr('type') == 'inventory') ? 'the inventory root' : target.attr('name'); - Wait('stop'); - if (!scope.$$phase) { - scope.$digest(); - } - } - if (variables) { Rest.setUrl(url); Rest.put(variables) .success(function(data, status, headers, config) { - showSuccessMsg(); + cleanUp(); }) .error(function(data, status, headers, config) { + cleanUp(); ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to update variables. PUT returned status: ' + status }); }); } else { - showSuccessMsg(); + cleanUp(); } }); @@ -263,6 +263,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi scope.$emit('copyVariables', data.id, data.related.variable_data); }) .error( function(data, status, headers, config) { + cleanUp(); ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to add ' + node.attr('name') + ' to ' + target.attr('name') + '. POST returned status: ' + status }); @@ -282,6 +283,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi scope.$emit('addToTarget'); }) .error( function(data, status, headers, config) { + cleanUp(); ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to remove ' + node.attr('name') + ' from ' + parent.attr('name') + '. POST returned status: ' + status }); @@ -296,6 +298,7 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi scope.$emit('removeGroup'); }) .error( function(data, status, headers, config) { + cleanUp(); ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Failed to lookup group ' + node.attr('name') + '. GET returned status: ' + status }); diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index 7bf4f7fcac..e13c02b517 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -546,7 +546,7 @@ input[type="text"].job-successful { border-radius: 6px; } - .groups-menu { + .groups-menu, .hosts-menu { min-height: 30px; background-color: #f5f5f5; border: 1px solid #e3e3e3; @@ -634,27 +634,28 @@ input[type="text"].job-successful { list-style-type: none; padding-left: 13px; } + ul:first-child { padding-left: 0; } - } + + .activate:hover { + background-color: #ddd; + } - .search-tree .active { - /*background-color: #ddd; - padding: 1px 1px 1px 0; - border: 1px solid #ddd; - border-radius: 4px;*/ - font-weight: bold; - color: #000; - } + .active { + font-weight: bold; + color: #000; + } - .search-tree .expand { - padding: 3px; - } + .expand { + padding: 3px; + } - .search-tree .expand:hover { - background-color: #ddd; - border: 1px solid #ddd; + .expand:hover { + background-color: #ddd; + border: 1px solid #ddd; + } } .parse-selection { diff --git a/awx/ui/static/lib/ansible/directives.js b/awx/ui/static/lib/ansible/directives.js index 15fee8919e..0c9ac0c834 100644 --- a/awx/ui/static/lib/ansible/directives.js +++ b/awx/ui/static/lib/ansible/directives.js @@ -317,8 +317,8 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos } }]) - .directive('awTree', ['Rest', 'ProcessErrors', 'Authorization', '$compile', '$rootScope', - function(Rest, ProcessErrors, Authorization, $compile, $rootScope) { + .directive('awTree', ['Rest', 'ProcessErrors', 'Authorization', '$compile', '$rootScope', 'Wait', + function(Rest, ProcessErrors, Authorization, $compile, $rootScope, Wait) { return { //require: 'ngModel', @@ -354,12 +354,12 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos var group, title; if (parent.attr('data-group-id')) { group = parent.attr('data-group-id'); - title = '
' + parent.attr('data-description') + '
' : ''; + title = parent.attr('data-name'); + //title += (parent.attr('data-description') !== "") ? '' + parent.attr('data-description') + '
' : ''; } else { group = null; - title = '