From 6d9ef4dfa61771db0600535ef349f0adc5144cab Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Fri, 27 Sep 2013 13:40:47 -0400 Subject: [PATCH] AC-525 Found and fixed inconsistencies and bugs in links from Inventories->Hosts to Jobs. Changed Job->Hosts to Job->Summaries so that it works or is consistent with Host->All summaries title. When viewing Host->All summaries disable the breadcrumb drop-down menu. Made breadcrumbs work after browser refresh. --- awx/ui/static/js/controllers/JobEvents.js | 11 +++--- awx/ui/static/js/controllers/JobHosts.js | 17 +++++---- awx/ui/static/js/forms/InventoryHosts.js | 10 +++--- awx/ui/static/js/forms/Jobs.js | 2 +- awx/ui/static/js/lists/Inventories.js | 4 +-- awx/ui/static/js/lists/JobEvents.js | 2 +- awx/ui/static/js/lists/JobHosts.js | 5 +-- awx/ui/static/js/lists/Jobs.js | 2 +- awx/ui/static/lib/ansible/Utilities.js | 10 +++++- awx/ui/static/lib/ansible/list-generator.js | 38 ++++++++++++++------- 10 files changed, 63 insertions(+), 38 deletions(-) diff --git a/awx/ui/static/js/controllers/JobEvents.js b/awx/ui/static/js/controllers/JobEvents.js index 95cf4042c4..c7f962ccab 100644 --- a/awx/ui/static/js/controllers/JobEvents.js +++ b/awx/ui/static/js/controllers/JobEvents.js @@ -109,10 +109,10 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest, return html; } - if (scope.RemovePostRefresh) { - scope.RemovePostRefresh(); + if (scope.PostRefreshRemove) { + scope.PostRefreshRemove(); } - scope.RemovePostRefresh = scope.$on('PostRefresh', function() { + scope.PostRefreshRemove = scope.$on('PostRefresh', function() { // Initialize the parent levels var set = scope[list.name]; var cDate; @@ -189,8 +189,9 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest, } scope.refresh = function() { - scope.expand = true; - scope.search(list.iterator); + scope['jobSearchSpin'] = true; + scope['jobLoading'] = true; + Refresh({ scope: scope, set: 'jobevents', iterator: 'jobevent', url: scope['current_url'] }); } } diff --git a/awx/ui/static/js/controllers/JobHosts.js b/awx/ui/static/js/controllers/JobHosts.js index d307dab402..e0eef59d66 100644 --- a/awx/ui/static/js/controllers/JobHosts.js +++ b/awx/ui/static/js/controllers/JobHosts.js @@ -12,7 +12,7 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, Rest, Alert, JobHostList, GenerateList, LoadBreadCrumbs, Prompt, SearchInit, PaginateInit, ReturnToCaller, - ClearScope, ProcessErrors, GetBasePath) + ClearScope, ProcessErrors, GetBasePath, Refresh) { ClearScope('htmlTemplate'); var list = JobHostList; @@ -31,7 +31,7 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, 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; @@ -41,7 +41,7 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, scope.job_id = $routeParams.id; scope.host_id = null; } - + // After a refresh, populate any needed summary field values on each row if (scope.PostRefreshRemove) { scope.PostRefreshRemove(); @@ -51,7 +51,7 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, scope.jobhosts[i].host_name = scope.jobhosts[i].summary_fields.host.name; scope.jobhosts[i].status = (scope.jobhosts[i].failed) ? 'error' : 'success'; } - if (scope.host_id == null) { + if (scope.job_id !== null && scope.job_id !== undefined && scope.job_id !== '') { // need job_status so we can show/hide refresh button Rest.setUrl(GetBasePath('jobs') + scope.job_id); Rest.get() @@ -81,7 +81,6 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, } scope.search(list.iterator); - LoadBreadCrumbs(); scope.showEvents = function(host_name, last_job) { @@ -103,12 +102,16 @@ function JobHostSummaryList ($scope, $rootScope, $location, $log, $routeParams, } scope.refresh = function() { - scope.search(list.iterator); + if (scope.host_id == null) { + scope['jobSearchSpin'] = true; + scope['jobLoading'] = true; + Refresh({ scope: scope, set: 'jobhosts', iterator: 'jobhost', url: scope['current_url'] }); + } } } JobHostSummaryList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'JobHostList', 'GenerateList', 'LoadBreadCrumbs', 'Prompt', 'SearchInit', 'PaginateInit', 'ReturnToCaller', 'ClearScope', - 'ProcessErrors','GetBasePath' + 'ProcessErrors', 'GetBasePath', 'Refresh' ]; diff --git a/awx/ui/static/js/forms/InventoryHosts.js b/awx/ui/static/js/forms/InventoryHosts.js index 3fd5d9c20f..b51e820e45 100644 --- a/awx/ui/static/js/forms/InventoryHosts.js +++ b/awx/ui/static/js/forms/InventoryHosts.js @@ -64,14 +64,14 @@ angular.module('InventoryHostsFormDefinition', []) icon: 'icon-zoom-in', "class": "btn-default btn-sm", options: [ - { ngClick: "allJobs(\{\{ host.id \}\})", label: 'All jobs', ngShow: 'host.last_job' }, - { ngClick: "allHostSummaries(\{\{ host.id \}\},'\{\{ host.name \}\}', \{\{ inventory_id \}\})", label: 'All host summaries', + { ngClick: "allJobs(\{\{ host.id \}\})", label: 'All', ngShow: 'host.last_job' }, + { ngClick: "allHostSummaries(\{\{ host.id \}\},'\{\{ host.name \}\}', \{\{ inventory_id \}\})", label: 'All summaries', ngShow: 'host.last_job' }, - { ngClick: 'viewJobs(\{\{ host.last_job \}\})', label: 'Latest job', ngShow: 'host.last_job' }, + { ngClick: 'viewJobs(\{\{ host.last_job \}\})', label: 'Latest', 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' }, + "'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest events', ngShow: 'host.last_job' }, { ngClick: "viewLastSummary(\{\{ host.id \}\}, '\{\{ host.last_job \}\}', '\{\{ host.name \}\}', " + - "'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest host summary', ngShow: 'host.last_job' }, + "'\{\{ host.summary_fields.last_job.name \}\}')", label: 'Latest summary', ngShow: 'host.last_job' }, { ngClick: "", label: 'No job data available', ngShow: 'host.last_job == null' } ] }, diff --git a/awx/ui/static/js/forms/Jobs.js b/awx/ui/static/js/forms/Jobs.js index 7eb9150423..94bcfcb8a8 100644 --- a/awx/ui/static/js/forms/Jobs.js +++ b/awx/ui/static/js/forms/Jobs.js @@ -29,7 +29,7 @@ angular.module('JobFormDefinition', []) }, hosts: { href: "/#/jobs/{{ job_id }}/job_host_summaries", - label: 'Hosts', + label: 'Summary', icon: 'icon-laptop' }, events: { diff --git a/awx/ui/static/js/lists/Inventories.js b/awx/ui/static/js/lists/Inventories.js index 91f5459f87..aaf4ca01c8 100644 --- a/awx/ui/static/js/lists/Inventories.js +++ b/awx/ui/static/js/lists/Inventories.js @@ -59,8 +59,8 @@ angular.module('InventoriesListDefinition', []) icon: 'icon-zoom-in', 'class': 'btn-default btn-xs', options: [ - { ngClick: 'viewJobs(\{\{ inventory.id \}\})', label: 'All Jobs' }, - { ngClick: "viewFailedJobs(\{\{ inventory.id \}\})", label: 'Failed jobs' } + { ngClick: 'viewJobs(\{\{ inventory.id \}\})', label: 'All' }, + { ngClick: "viewFailedJobs(\{\{ inventory.id \}\})", label: 'Failed' } ] }, edit: { diff --git a/awx/ui/static/js/lists/JobEvents.js b/awx/ui/static/js/lists/JobEvents.js index ea95717e88..63818dc798 100644 --- a/awx/ui/static/js/lists/JobEvents.js +++ b/awx/ui/static/js/lists/JobEvents.js @@ -27,7 +27,7 @@ angular.module('JobEventsListDefinition', []) }, hosts: { href: "/#/jobs/{{ job_id }}/job_host_summaries", - label: 'Hosts', + label: 'Summary', icon: 'icon-laptop' }, events: { diff --git a/awx/ui/static/js/lists/JobHosts.js b/awx/ui/static/js/lists/JobHosts.js index 2562e68b00..67cc2eb40b 100644 --- a/awx/ui/static/js/lists/JobHosts.js +++ b/awx/ui/static/js/lists/JobHosts.js @@ -12,11 +12,12 @@ angular.module('JobHostDefinition', []) name: 'jobhosts', iterator: 'jobhost', - editTitle: 'Job Host Summary', + editTitle: 'All summaries', index: true, hover: true, navigationLinks: { + ngHide: 'host_id !== null', details: { href: "/#/jobs/{{ job_id }}", label: 'Status', @@ -25,7 +26,7 @@ angular.module('JobHostDefinition', []) }, hosts: { href: "/#/jobs/{{ job_id }}/job_host_summaries", - label: 'Hosts', + label: 'Summary', active: true, icon: 'icon-laptop' }, diff --git a/awx/ui/static/js/lists/Jobs.js b/awx/ui/static/js/lists/Jobs.js index 579c27af4d..63356e3c4d 100644 --- a/awx/ui/static/js/lists/Jobs.js +++ b/awx/ui/static/js/lists/Jobs.js @@ -98,7 +98,7 @@ angular.module('JobsListDefinition', []) 'class': 'btn-default btn-xs', options: [ { ngClick: "editJob(\{\{ job.id \}\}, '\{\{ job.summary_fields.job_template.name \}\}')", label: 'Status' }, - { ngClick: "viewSummary(\{{ job.id \}\}, '\{\{ job.summary_fields.job_template.name \}\}')", label: 'Hosts', + { ngClick: "viewSummary(\{{ job.id \}\}, '\{\{ job.summary_fields.job_template.name \}\}')", label: 'Summary', ngHide: "job.status == 'new'" }, { ngClick: "viewEvents(\{{ job.id \}\}, '\{\{ job.summary_fields.job_template.name \}\}')", label: 'Events', ngHide: "job.status == 'new'" } diff --git a/awx/ui/static/lib/ansible/Utilities.js b/awx/ui/static/lib/ansible/Utilities.js index 7238d2bf0f..3992687909 100644 --- a/awx/ui/static/lib/ansible/Utilities.js +++ b/awx/ui/static/lib/ansible/Utilities.js @@ -194,7 +194,15 @@ angular.module('Utilities',[]) $rootScope.breadcrumbs.push({ title: child, path: $rootScope.crumbCache[j].altPath }); } else { - $rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] }); + if (paths[i - 1] == 'hosts') { + // For hosts, there is no /hosts, so we need to link back to the inventory + // We end up here when user has clicked refresh and the crumbcache is missing + $rootScope.breadcrumbs.push({ title: child, + path: '/inventories/' + $routeParams.inventory + '/hosts' }); + } + else { + $rootScope.breadcrumbs.push({ title: child, path: ppath + '/' + paths[i] }); + } } } else { diff --git a/awx/ui/static/lib/ansible/list-generator.js b/awx/ui/static/lib/ansible/list-generator.js index 907aab3964..c61fbac8da 100644 --- a/awx/ui/static/lib/ansible/list-generator.js +++ b/awx/ui/static/lib/ansible/list-generator.js @@ -108,11 +108,21 @@ angular.module('ListGenerator', ['GeneratorHelpers']) if (list.navigationLinks) { var navigation = list.navigationLinks; - html += "
  • \n"; - html += "\n"; - html += "
    \n"; + if (navigation['ngHide']) { + html += "
  • "; + html += list.editTitle; + html += "
  • \n"; + html += "
  • \n"; + } + else { + html += "
  • \n"; + html += "\n"; + } + html += "
    "; @@ -121,15 +131,17 @@ angular.module('ListGenerator', ['GeneratorHelpers']) } html += "\n"; html += "
    \n";