diff --git a/awx/ui/static/js/controllers/JobEvents.js b/awx/ui/static/js/controllers/JobEvents.js index 33f478740e..d5c0beba33 100644 --- a/awx/ui/static/js/controllers/JobEvents.js +++ b/awx/ui/static/js/controllers/JobEvents.js @@ -18,14 +18,15 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest, var list = JobEventList; list.base = $location.path(); - var defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events/?parent__isnull=1'; + var defaultUrl = GetBasePath('jobs') + $routeParams.id + '/job_events/?parent__isnull=1'; var view = GenerateList; var base = $location.path().replace(/^\//,'').split('/')[0]; var scope = view.inject(list, { mode: 'edit' }); $rootScope.flashMessage = null; scope.selected = []; - + scope.expand = true; //on load, automatically expand all nodes + if (scope.RemovePostRefresh) { scope.RemovePostRefresh(); } @@ -43,6 +44,44 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest, } scope.jobevents[i].status = (scope.jobevents[i].failed) ? 'error' : 'success'; } + + // Expand all parent nodes + if (scope.removeSetExpanded) { + scope.removeSetExpanded(); + } + scope.removeSetExpanded = scope.$on('setExpanded', function() { + // After ToggleChildren completes, look for the next parent that needs to be expanded + var found = false; + for (var i=0; i < set.length && found == false && scope.expand; i++) { + if (set[i]['related']['children'] && (set[i]['ngicon'] == undefined || set[i]['ngicon'] == 'icon-expand-alt')) { + found = true; + ToggleChildren({ + scope: scope, + list: list, + id: set[i].id, + children: set[i]['related']['children'] + }); + } + } + if (found == false) { + // After looping through all the nodes and finding nothing to expand, turn off + // auto-expand. From now on user will manually collapse and expand nodes. + scope.expand = false; + } + }); + // Start the auto expansion + set = scope[list.name]; + for (var i=0; i < set.length; i++) { + if (set[i]['related']['children'] && (set[i]['ngicon'] == undefined || set[i]['ngicon'] == 'icon-expand-alt')) { + ToggleChildren({ + scope: scope, + list: list, + id: set[i].id, + children: set[i]['related']['children'] + }); + } + } + }); SearchInit({ scope: scope, set: 'jobevents', list: list, url: defaultUrl }); diff --git a/awx/ui/static/js/forms/JobEvents.js b/awx/ui/static/js/forms/JobEvents.js index 58a7c927ac..90fd412e8b 100644 --- a/awx/ui/static/js/forms/JobEvents.js +++ b/awx/ui/static/js/forms/JobEvents.js @@ -27,6 +27,12 @@ angular.module('JobEventFormDefinition', []) readonly: true, "class": 'span3' }, + status: { + label: 'Status', + type: 'text', + "class": 'job-\{\{ event_status \}\}', + readonly: true + }, host: { label: 'Host', type: 'text', diff --git a/awx/ui/static/js/helpers/Children.js b/awx/ui/static/js/helpers/Children.js index 9e23a925d0..2f4fc5a334 100644 --- a/awx/ui/static/js/helpers/Children.js +++ b/awx/ui/static/js/helpers/Children.js @@ -59,7 +59,8 @@ angular.module('ChildrenHelper', ['RestServices', 'Utilities']) set.splice(clicked + 1, 0, data.results[j]); } clicked++; - } + } + scope.$emit('setExpanded'); }) .error( function(data, status, headers, config) { ProcessErrors(scope, data, status, null, diff --git a/awx/ui/static/js/lists/JobEvents.js b/awx/ui/static/js/lists/JobEvents.js index f6656496b0..b402060fba 100644 --- a/awx/ui/static/js/lists/JobEvents.js +++ b/awx/ui/static/js/lists/JobEvents.js @@ -25,6 +25,16 @@ angular.module('JobEventsListDefinition', []) searchable: false, ngClick: "viewJobEvent(\{\{ jobevent.id \}\})", }, + status: { + label: 'Status', + icon: 'icon-circle', + "class": 'job-\{\{ jobevent.status \}\}', + searchField: 'failed', + searchType: 'boolean', + searchOptions: [{ name: "success", value: 0 }, { name: "error", value: 1 }], + nosort: true, + searchable: false, + }, event_display: { label: 'Event', hasChildren: true, @@ -39,16 +49,6 @@ angular.module('JobEventsListDefinition', []) searchField: 'hosts__name', nosort: true, id: 'job-event-host-header' - }, - status: { - label: 'Status', - icon: 'icon-circle', - "class": 'job-\{\{ jobevent.status \}\}', - searchField: 'failed', - searchType: 'boolean', - searchOptions: [{ name: "success", value: 0 }, { name: "error", value: 1 }], - nosort: true, - searchable: false, } }, diff --git a/awx/ui/static/lib/ansible/list-generator.js b/awx/ui/static/lib/ansible/list-generator.js index d9a94a8d47..108cfcd747 100644 --- a/awx/ui/static/lib/ansible/list-generator.js +++ b/awx/ui/static/lib/ansible/list-generator.js @@ -191,7 +191,9 @@ angular.module('ListGenerator', ['GeneratorHelpers']) html += "
\n"; html += "