diff --git a/awx/ui/static/js/controllers/Users.js b/awx/ui/static/js/controllers/Users.js index b293f759b6..7cff5b4c23 100644 --- a/awx/ui/static/js/controllers/Users.js +++ b/awx/ui/static/js/controllers/Users.js @@ -25,6 +25,10 @@ function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest, Ale var scope = view.inject(UserList, { mode: mode }); // Inject our view scope.selected = []; + var url = (base == 'organizations') ? GetBasePath('organizations') + $routeParams.organization_id + '/users/' : + GetBasePath('teams') + $routeParams.team_id + '/users/'; + SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 }); + if (scope.removePostRefresh) { scope.removePostRefresh(); } @@ -41,10 +45,6 @@ function UsersList ($scope, $rootScope, $location, $log, $routeParams, Rest, Ale LoadBreadCrumbs(); - var url = (base == 'organizations') ? GetBasePath('organizations') + $routeParams.organization_id + '/users/' : - GetBasePath('teams') + $routeParams.team_id + '/users/'; - SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 }); - scope.showActivity = function() { Stream(); } scope.addUser = function() { diff --git a/awx/ui/static/js/forms/InventoryHosts.js b/awx/ui/static/js/forms/InventoryHosts.js index a75070ae90..cfdf5e49bb 100644 --- a/awx/ui/static/js/forms/InventoryHosts.js +++ b/awx/ui/static/js/forms/InventoryHosts.js @@ -81,7 +81,7 @@ angular.module('InventoryHostsFormDefinition', []) ngClick: "addHost()", ngHide: "hostAddHide", awToolTip: "Copy an existing host to the selected group", - dataPlacement: 'bottom', + dataPlacement: 'top', 'class': 'btn-xs btn-success', icon: 'icon-check' }, @@ -90,7 +90,7 @@ angular.module('InventoryHostsFormDefinition', []) ngClick: 'createHost()', ngHide: 'hostCreateHide', awToolTip: 'Create a new host and add it to the selected group', - dataPlacement: 'bottom', + dataPlacement: 'top', 'class': 'btn-xs btn-success', icon: 'icon-plus' }, diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 29c313e0de..94369c7423 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -239,18 +239,17 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' $('#form-modal .btn-none').removeClass('btn-none').addClass('btn-success'); $('#form-modal').modal({ backdrop: 'static', keyboard: false }); + // Initialize the selection list var url = (group_id) ? GetBasePath('groups') + group_id + '/children/' : GetBasePath('inventory') + inventory_id + '/groups/'; + var selected = []; + SelectionInit({ scope: scope, list: list, url: url, selected: selected }); - SelectionInit({ scope: scope, list: list, url: url }); - - //var finish = scope.finishSelection; - scope.formModalAction = function() { var groups = []; - for (var j=0; j < scope.selected.length; j++) { - if (scope.inventoryRootGroups.indexOf(scope.selected[j].id) > -1) { - groups.push(scope.selected[j].name); + for (var j=0; j < selected.length; j++) { + if (scope.inventoryRootGroups.indexOf(selected[j].id) > -1) { + groups.push(selected[j].name); } } @@ -286,19 +285,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' } } - /* Now using /potential_children resource, so should not need to do this any longer. - if (scope.PostRefreshRemove) { - scope.PostRefreshRemove(); - } - scope.PostRefreshRemove = scope.$on('PostRefresh', function() { - for (var i=0; i < scope.groups.length; i++) { - if (scope.groups[i].id == group_id) { - scope.groups.splice(i,1); - } - } - }); - */ - var searchUrl = (group_id) ? GetBasePath('groups') + group_id + '/potential_children/' : GetBasePath('inventory') + inventory_id + '/groups/'; diff --git a/awx/ui/static/js/helpers/Selection.js b/awx/ui/static/js/helpers/Selection.js index 92367f2375..1522a356f7 100644 --- a/awx/ui/static/js/helpers/Selection.js +++ b/awx/ui/static/js/helpers/Selection.js @@ -20,9 +20,16 @@ angular.module('SelectionHelper', ['Utilities', 'RestServices']) var list = params.list; // list object var target_url = params.url; // URL to POST selected objects var returnToCaller = params.returnToCaller; - - scope.selected = []; //array of selected row IDs + + if (params.selected !== undefined) { + var selected = params.selected; + } + else { + var selected = []; //array of selected row IDs + } + scope.formModalActionDisabled = true; + scope.disableSelectBtn = true; // toggle row selection scope['toggle_' + list.iterator] = function(id, ischeckbox) { @@ -35,14 +42,14 @@ angular.module('SelectionHelper', ['Utilities', 'RestServices']) // add selected object to the array var found = false; - for (var j=0; j < scope.selected.length; j++) { - if (scope.selected[j].id == id) { + for (var j=0; j < selected.length; j++) { + if (selected[j].id == id) { found = true; break; } } if (!found) { - scope.selected.push(scope[list.name][i]); + selected.push(scope[list.name][i]); } } else { @@ -51,87 +58,89 @@ angular.module('SelectionHelper', ['Utilities', 'RestServices']) scope[list.name][i]['success_class'] = ''; // remove selected object from the array - for (var j=0; j < scope.selected.length; j++) { - if (scope.selected[j].id == id) { - scope.selected.splice(j,1); + for (var j=0; j < selected.length; j++) { + if (selected[j].id == id) { + selected.splice(j,1); break; } } } } } - if (scope.selected.length > 0) { - scope.formModalActionDisabled = false; + if (selected.length > 0) { + scope.formModalActionDisabled = false; + scope.disableSelectBtn = false; } else { scope.formModalActionDisabled = true; + scope.disableSelectBtn = true; } } + + // Add the selections + scope.finishSelection = function() { + Rest.setUrl(target_url); + var queue = []; + scope.formModalActionDisabled = true; + scope.disableSelectBtn = true; + + Wait('start'); - if (target_url) { - scope.finishSelection = function() { - Rest.setUrl(target_url); - scope.queue = []; - scope.formModalActionDisabled = true; - - Wait('start'); + function finished() { + selected = []; + if (returnToCaller !== undefined) { + ReturnToCaller(returnToCaller); + } + else { + $('#form-modal').modal('hide'); + scope.$emit('modalClosed'); + } + } + + if (scope.callFinishedRemove) { + scope.callFinishedRemove(); + } + scope.callFinishedRemove = scope.$on('callFinished', function() { + // We call the API for each selected item. We need to hang out until all the api + // calls are finished. + if (queue.length == selected.length) { + Wait('stop'); + var errors = 0; + for (var i=0; i < queue.length; i++) { + if (queue[i].result == 'error') { + ProcessErrors(scope, queue[i].data, queue[i].status, null, + { hdr: 'POST Failure', msg: 'Failed to add ' + list.iterator + + '. POST returned status: ' + queue[i].status }); + errors++; + } + } + if (errors == 0) { + finished(); + } + } + }); - function finished() { - scope.selected = []; - if (returnToCaller !== undefined) { - ReturnToCaller(returnToCaller); - } - else { - $('#form-modal').modal('hide'); - scope.$emit('modalClosed'); - } - } - - if (scope.callFinishedRemove) { - scope.callFinishedRemove(); + if (selected.length > 0 ) { + for (var j=0; j < selected.length; j++) { + Rest.post(selected[j]) + .success( function(data, status, headers, config) { + queue.push({ result: 'success', data: data, status: status }); + scope.$emit('callFinished'); + }) + .error( function(data, status, headers, config) { + queue.push({ result: 'error', data: data, status: status, headers: headers }); + scope.$emit('callFinished'); + }); } - scope.callFinishedRemove = scope.$on('callFinished', function() { - // We call the API for each selected item. We need to hang out until all the api - // calls are finished. - if (scope.queue.length == scope.selected.length) { - Wait('stop'); - var errors = 0; - for (var i=0; i < scope.queue.length; i++) { - if (scope.queue[i].result == 'error') { - ProcessErrors(scope, scope.queue[i].data, scope.queue[i].status, null, - { hdr: 'POST Failure', msg: 'Failed to add ' + list.iterator + - '. POST returned status: ' + scope.queue[i].status }); - errors++; - } - } - if (errors == 0) { - finished(); - } - } - }); - - if (scope.selected.length > 0 ) { - for (var j=0; j < scope.selected.length; j++) { - Rest.post(scope.selected[j]) - .success( function(data, status, headers, config) { - scope.queue.push({ result: 'success', data: data, status: status }); - scope.$emit('callFinished'); - }) - .error( function(data, status, headers, config) { - scope.queue.push({ result: 'error', data: data, status: status, headers: headers }); - scope.$emit('callFinished'); - }); - } - } - else { - finished(); - } - } - } + } + else { + finished(); + } + } scope.formModalAction = scope.finishSelection; - // Initialize our data set after a refresh + // Initialize our data set after a refresh (page change or search) if (scope.SelectPostRefreshRemove) { scope.SelectPostRefreshRemove(); } @@ -139,8 +148,8 @@ angular.module('SelectionHelper', ['Utilities', 'RestServices']) if (scope[list.name]) { for (var i=0; i < scope[list.name].length; i++) { var found = false; - for (var j=0; j < scope.selected.length; j++) { - if (scope.selected[j].id == scope[list.name][i].id) { + for (var j=0; j < selected.length; j++) { + if (selected[j].id == scope[list.name][i].id) { found = true; break; } diff --git a/awx/ui/static/js/lists/Groups.js b/awx/ui/static/js/lists/Groups.js index 493d670020..c0e92d600e 100644 --- a/awx/ui/static/js/lists/Groups.js +++ b/awx/ui/static/js/lists/Groups.js @@ -31,7 +31,7 @@ angular.module('GroupListDefinition', []) help: { awPopOver: "Choose groups by clicking on each group you wish to add. Click the Select button to add the groups to " + "the selected inventory group.", - dataPlacement: 'top', + dataPlacement: 'left', dataContainer: '#form-modal .modal-content', icon: "icon-question-sign", mode: 'all', diff --git a/awx/ui/static/js/lists/Hosts.js b/awx/ui/static/js/lists/Hosts.js index 9aaee1510b..15057aa220 100644 --- a/awx/ui/static/js/lists/Hosts.js +++ b/awx/ui/static/js/lists/Hosts.js @@ -15,7 +15,7 @@ angular.module('HostListDefinition', []) selectTitle: 'Add Existing Hosts', editTitle: 'Hosts', index: true, - well: true, + well: false, fields: { name: { @@ -31,7 +31,7 @@ angular.module('HostListDefinition', []) actions: { help: { awPopOver: "Select hosts by clicking on each host you wish to add. Add the selected hosts to the group by clicking the Select button.", - dataPlacement: 'top', + dataPlacement: 'left', dataContainer: '#form-modal .modal-content', icon: "icon-question-sign", mode: 'all', diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index 7e6bc12025..22bd00ea63 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -1345,7 +1345,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities']) html += "
\n"; html += "
\n"; html += SearchWidget({ iterator: form.iterator, template: form, mini: true, size: 'col-md-5 col-lg-5'}); - html += "
\n" + html += "
\n" html += "
\n"; // Add actions(s) diff --git a/awx/ui/static/lib/ansible/list-generator.js b/awx/ui/static/lib/ansible/list-generator.js index 0dc3586f6c..bf5f297de1 100644 --- a/awx/ui/static/lib/ansible/list-generator.js +++ b/awx/ui/static/lib/ansible/list-generator.js @@ -402,7 +402,7 @@ angular.module('ListGenerator', ['GeneratorHelpers']) if (options.mode == 'select' && (options.selectButton == undefined || options.selectButton == true)) { html += "
\n"; html += " \n"; + "ng-click=\"finishSelection()\" ng-disabled=\"disableSelectBtn\"> Select\n"; html += "
\n"; }