diff --git a/awx/ui/static/js/controllers/Hosts.js b/awx/ui/static/js/controllers/Hosts.js index 0df47fd520..f26d6cc282 100644 --- a/awx/ui/static/js/controllers/Hosts.js +++ b/awx/ui/static/js/controllers/Hosts.js @@ -89,9 +89,10 @@ function InventoryHosts ($scope, $rootScope, $compile, $location, $log, $routePa $location.url('/jobs/?job_host_summaries__host=' + id); } - scope.allHostSummaries = function(id, name) { - LoadBreadCrumbs({ path: '/inventories/' + scope.inventory_id + '/hosts', title: name }); - $location.url('/hosts/' + id + '/job_host_summaries'); + scope.allHostSummaries = function(id, name, inventory_id) { + LoadBreadCrumbs({ path: '/hosts/' + id, title: name, altPath: '/inventories/' + inventory_id + '/hosts', + inventory_id: inventory_id }); + $location.url('/hosts/' + id + '/job_host_summaries/?inventory=' + inventory_id); } scope.viewLastEvents = function(host_id, last_job, host_name, last_job_name) { diff --git a/awx/ui/static/js/controllers/JobHosts.js b/awx/ui/static/js/controllers/JobHosts.js index 54d9230792..a8297a25e7 100644 --- a/awx/ui/static/js/controllers/JobHosts.js +++ b/awx/ui/static/js/controllers/JobHosts.js @@ -21,6 +21,16 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, var view = GenerateList; var scope = view.inject(list, { mode: 'edit' }); scope.selected = []; + + // control enable/disable/show of job specific view elements + if (base == 'hosts') { + scope.job_id = null; + scope.host_id = $routeParams.id; + } + else { + scope.job_id = $routeParams.id; + scope.host_id = null; + } // After a refresh, populate any needed summary field values on each row if (scope.PostRefreshRemove) { @@ -48,30 +58,34 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, LoadBreadCrumbs(); scope.showEvents = function(host_name, last_job) { - // When click on !Failed Events link, redirect to latest job/job_events for the host - Rest.setUrl(last_job); - Rest.get() - .success( function(data, status, headers, config) { - LoadBreadCrumbs({ path: '/jobs/' + data.id, title: data.name }); - $location.url('/jobs/' + data.id + '/job_events/?host=' + escape(host_name)); - }) - .error( function(data, status, headers, config) { - ProcessErrors(scope, data, status, form, - { hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job + '. GET status: ' + status }); - }); - } + // When click on !Failed Events link, redirect to latest job/job_events for the host + Rest.setUrl(last_job); + Rest.get() + .success( function(data, status, headers, config) { + LoadBreadCrumbs({ path: '/jobs/' + data.id, title: data.name }); + $location.url('/jobs/' + data.id + '/job_events/?host=' + escape(host_name)); + }) + .error( function(data, status, headers, config) { + ProcessErrors(scope, data, status, form, + { hdr: 'Error!', msg: 'Failed to lookup last job: ' + last_job + '. GET status: ' + status }); + }); + } + + scope.showJob = function(id) { + $location.path('/jobs/' + id); + } scope.refresh = function() { - scope.search(list.iterator); - } + scope.search(list.iterator); + } scope.jobDetails = function() { - $location.path('/jobs/' + $routeParams.id); - }; + $location.path('/jobs/' + $routeParams.id); + }; scope.jobEvents = function() { - $location.path('/jobs/' + $routeParams.id + '/job_events'); - }; + $location.path('/jobs/' + $routeParams.id + '/job_events'); + }; } diff --git a/awx/ui/static/js/forms/InventoryHosts.js b/awx/ui/static/js/forms/InventoryHosts.js index 67ece1ec53..6064b480ea 100644 --- a/awx/ui/static/js/forms/InventoryHosts.js +++ b/awx/ui/static/js/forms/InventoryHosts.js @@ -40,7 +40,8 @@ angular.module('InventoryHostsFormDefinition', []) //ngDisabled: 'host.last_job == null', options: [ { ngClick: "allJobs(\{\{ host.id \}\})", label: 'All jobs', ngShow: 'host.last_job' }, - { ngClick: "allHostSummaries(\{\{ host.id \}\},'\{\{ host.name \}\}')", label: 'All host summaries', ngShow: 'host.last_job' }, + { ngClick: "allHostSummaries(\{\{ host.id \}\},'\{\{ host.name \}\}', \{\{ inventory_id \}\})", label: 'All host summaries', + ngShow: 'host.last_job' }, { ngClick: 'viewJobs(\{\{ host.last_job \}\})', label: 'Latest job', ngShow: 'host.last_job' }, { ngClick: "viewLastEvents(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " + "'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest job events', ngShow: 'host.last_job' }, diff --git a/awx/ui/static/js/lists/JobHosts.js b/awx/ui/static/js/lists/JobHosts.js index a4e3dcf143..f203f52c01 100644 --- a/awx/ui/static/js/lists/JobHosts.js +++ b/awx/ui/static/js/lists/JobHosts.js @@ -17,6 +17,13 @@ angular.module('JobHostDefinition', []) hover: true, fields: { + job: { + label: 'Job ID', + ngClick: "showJob(\{\{ jobhost.job \}\})", + columnShow: 'host_id !== null', + key: true, + desc: true + }, host: { label: 'Host', key: true, @@ -68,6 +75,7 @@ angular.module('JobHostDefinition', []) label: 'Details', icon: 'icon-edit', ngClick: "jobDetails()", + ngShow: 'job_id !== null', "class": 'btn btn-default btn-sm', awToolTip: 'Edit job details', mode: 'all' @@ -76,6 +84,7 @@ angular.module('JobHostDefinition', []) label: 'Events', icon: 'icon-list-ul', ngClick: "jobEvents()", + ngShow: 'job_id !== null', "class": 'btn btn-default btn-sm', awToolTip: 'View job events', mode: 'all' diff --git a/awx/ui/static/lib/ansible/list-generator.js b/awx/ui/static/lib/ansible/list-generator.js index 17c4f7bb8a..767fa7772f 100644 --- a/awx/ui/static/lib/ansible/list-generator.js +++ b/awx/ui/static/lib/ansible/list-generator.js @@ -213,6 +213,7 @@ angular.module('ListGenerator', ['GeneratorHelpers']) html += "\" id=\""; html += (list.fields[fld].id) ? list.fields[fld].id : fld + "-header"; html += "\""; + html += (list.fields[fld].columnShow) ? " ng-show=\"" + list.fields[fld].columnShow + "\" " : ""; html += (list.fields[fld].nosort === undefined || list.fields[fld].nosort !== true) ? "ng-click=\"sort('" + fld + "')\"" : ""; html += ">"; html += list.fields[fld].label; diff --git a/awx/ui/static/lib/ansible/utilities.js b/awx/ui/static/lib/ansible/utilities.js index 21c214cacb..d192f25c2d 100644 --- a/awx/ui/static/lib/ansible/utilities.js +++ b/awx/ui/static/lib/ansible/utilities.js @@ -133,7 +133,7 @@ angular.module('Utilities',[]) }]) .factory('LoadBreadCrumbs', ['$rootScope', '$routeParams', '$location', function($rootScope, $routeParams, $location, Rest) { - return function(crumb) { + return function(crumb) { //Keep a list of path/title mappings. When we see /organizations/XX in the path, for example, //we'll know the actual organization name it maps to. if (crumb !== null && crumb !== undefined) { @@ -171,10 +171,21 @@ angular.module('Utilities',[]) break; } } - $rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] }); + if ($rootScope.crumbCache[j].altPath) { + $rootScope.breadcrumbs.push({ title: child, path: $rootScope.crumbCache[j].altPath }); + } + else { + $rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] }); + } } else { - $rootScope.breadcrumbs.push({ title: paths[i], path: ppath + '/' + paths[i] }); + if (paths[i] == 'hosts') { + $rootScope.breadcrumbs.push({ title: paths[i], path: '/inventories/' + $routeParams.inventory + + '/hosts' }); + } + else { + $rootScope.breadcrumbs.push({ title: paths[i], path: ppath + '/' + paths[i] }); + } } ppath += '/' + paths[i]; }