diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index 62ca24f2b5..56914cfdb8 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -12,7 +12,7 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, InventoryList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, - ClearScope, ProcessErrors, GetBasePath) + ClearScope, ProcessErrors, GetBasePath, Wait) { ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. @@ -43,14 +43,16 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res var action = function() { var url = defaultUrl + id + '/'; + $('#prompt-modal').modal('hide'); + Wait('start'); Rest.setUrl(url); Rest.destroy() .success( function(data, status, headers, config) { - $('#prompt-modal').modal('hide'); scope.search(list.iterator); + Wait('stop'); }) .error( function(data, status, headers, config) { - $('#prompt-modal').modal('hide'); + Wait('stop'); ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); }); @@ -79,7 +81,7 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res InventoriesList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'InventoryList', 'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', 'ProcessErrors', - 'GetBasePath' ]; + 'GetBasePath', 'Wait' ]; function InventoriesAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, InventoryForm, @@ -219,6 +221,23 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP scope.inventoryLoadedRemove = scope.$on('inventoryLoaded', function() { LoadSearchTree({ scope: scope, inventory_id: scope['inventory_id'] }); TreeInit(scope.TreeParams); + Rest.setUrl(scope.inventoryGroupsUrl); + Rest.get() + .success(function(data, status, headers, config) { + if (data.results.length == 0) { + // No groups exist yet, activate the groups tab + scope.showGroupHelp = true; + $('#inventory-tabs a[href="#inventory-groups"]').tab('show') + } + else { + scope.showGroupHelp = false; + $('#inventory-tabs a[href="#inventory-hosts"]').tab('show') + } + }) + .error(function(data, status, headers, config) { + ProcessErrors(scope, data, status, null, + { hdr: 'Error!', msg: 'Failed to get inventory groups. GET returned status: ' + status }); + }); if (!scope.$$phase) { scope.$digest(); } @@ -236,13 +255,14 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP }); 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(); } - }); + }); scope.filterInventory = function() { $rootScope.hostFailureFilter = scope.hostFailureFilter; diff --git a/awx/ui/static/js/forms/Inventories.js b/awx/ui/static/js/forms/Inventories.js index 912858c6f6..b7632bc8a1 100644 --- a/awx/ui/static/js/forms/Inventories.js +++ b/awx/ui/static/js/forms/Inventories.js @@ -122,6 +122,7 @@ angular.module('InventoryFormDefinition', []) dropdown: { type: 'DropDown', label: 'View', + ngDisabled: 'host.last_job == null', options: [ { ngClick: 'viewJobs(\{\{ host.id \}\})', label: 'Jobs' }, { ngClick: "viewLastEvents(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " + diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index c6105b2464..d99b71b152 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -138,6 +138,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' Rest.setUrl(defaultUrl); Rest.post(data) .success( function(data, status, headers, config) { + scope.showGroupHelp = false; // get rid of the Hint if (scope.variables) { Rest.setUrl(data.related.variable_data); Rest.put(json_data) diff --git a/awx/ui/static/js/helpers/inventory.js b/awx/ui/static/js/helpers/inventory.js index a51281bef2..926dd791f5 100644 --- a/awx/ui/static/js/helpers/inventory.js +++ b/awx/ui/static/js/helpers/inventory.js @@ -349,7 +349,8 @@ angular.module('InventoryHelper', [ 'RestServices', 'Utilities', 'OrganizationLi scope[form.fields[fld].sourceModel + '_' + form.fields[fld].sourceField]; } } - + + scope.inventoryGroupsUrl = data.related.groups; scope.TreeParams = { scope: scope, inventory: data }; scope.variable_url = data.related.variable_data; scope.relatedSets['hosts'] = { url: data.related.hosts, iterator: 'host' }; diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index fb21106c18..bb89f52c63 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -481,8 +481,8 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) html += "class=\"" + getFieldWidth() + "\">\n"; // Use 'text' rather than 'number' so that our integer directive works correctly html += (field.slider) ? "
\n" : ""; - html += "\n"; html += "
\n"; + html += "
\n"; + html += "\n"; + html += "

Hint: Get started building your inventory by adding a group. After creating a group, " + + "use the Hosts tab to add hosts to the group." + html += "

\n"; + // build the groups tab html += "
\n"; html += "\n"; @@ -935,15 +941,10 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) "aw-tool-tip=\"Delete the selected group\" data-placement=\"bottom\"> Delete Group\n"; html += "
  • Loading...
  • \n"; html += "\n"; - /*html += "
    \n"; - html += "\n"; - html += "
    \n"; */ + html += "
    \n"; html += "
    \n"; - //html += "
    \n"; + html += "\n"; // build the hosts tab @@ -976,7 +977,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies']) // Add actions(s) for (var action in form.related[itm].actions) { - html += "\n"; html += "\n";