diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 28453a869b..69a8da5d56 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -102,7 +102,8 @@ angular.module('Tower', [ 'EventViewerHelper', 'JobDetailHelper', 'SocketIO', - 'lrInfiniteScroll' + 'lrInfiniteScroll', + 'HostEventsViewer' ]) .constant('AngularScheduler.partials', $basePath + 'lib/angular-scheduler/lib/') diff --git a/awx/ui/static/js/controllers/JobDetail.js b/awx/ui/static/js/controllers/JobDetail.js index 81aa4dabd2..9ce16e08e8 100644 --- a/awx/ui/static/js/controllers/JobDetail.js +++ b/awx/ui/static/js/controllers/JobDetail.js @@ -9,7 +9,7 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routeParams, $log, ClearScope, Breadcrumbs, LoadBreadCrumbs, GetBasePath, Wait, Rest, ProcessErrors, SelectPlay, SelectTask, Socket, GetElapsed, FilterAllByHostName, DrawGraph, LoadHostSummary, ReloadHostSummaryList, - JobIsFinished, SetTaskStyles, DigestEvent, UpdateDOM, EventViewer, DeleteJob, PlaybookRun) { + JobIsFinished, SetTaskStyles, DigestEvent, UpdateDOM, EventViewer, DeleteJob, PlaybookRun, HostEventsViewer) { ClearScope(); @@ -1004,9 +1004,17 @@ function JobDetailController ($location, $rootScope, $scope, $compile, $routePar } }; + scope.hostEventsViewer = function(id, name) { + HostEventsViewer({ + id: id, + name: name, + url: scope.job.related.job_events + '?event__icontains=runner' + }); + } + } JobDetailController.$inject = [ '$location', '$rootScope', '$scope', '$compile', '$routeParams', '$log', 'ClearScope', 'Breadcrumbs', 'LoadBreadCrumbs', 'GetBasePath', 'Wait', 'Rest', 'ProcessErrors', 'SelectPlay', 'SelectTask', 'Socket', 'GetElapsed', 'FilterAllByHostName', 'DrawGraph', 'LoadHostSummary', 'ReloadHostSummaryList', - 'JobIsFinished', 'SetTaskStyles', 'DigestEvent', 'UpdateDOM', 'EventViewer', 'DeleteJob', 'PlaybookRun' + 'JobIsFinished', 'SetTaskStyles', 'DigestEvent', 'UpdateDOM', 'EventViewer', 'DeleteJob', 'PlaybookRun', 'HostEventsViewer' ]; diff --git a/awx/ui/static/js/helpers/EventViewer.js b/awx/ui/static/js/helpers/EventViewer.js index d0251d0353..3a36a5c49e 100644 --- a/awx/ui/static/js/helpers/EventViewer.js +++ b/awx/ui/static/js/helpers/EventViewer.js @@ -1,7 +1,7 @@ /********************************************* * Copyright (c) 2014 AnsibleWorks, Inc. * - * LogViewer.js + * EventsViewer.js * */ diff --git a/awx/ui/static/js/helpers/HostEventsViewer.js b/awx/ui/static/js/helpers/HostEventsViewer.js new file mode 100644 index 0000000000..a027fa1c5e --- /dev/null +++ b/awx/ui/static/js/helpers/HostEventsViewer.js @@ -0,0 +1,83 @@ +/********************************************* + * Copyright (c) 2014 AnsibleWorks, Inc. + * + * HostEventsViewer.js + * + * View a list of events for a given job and host + * + */ + +'use strict'; + +angular.module('HostEventsViewerHelper', ['ModalDialog', 'Utilities']) + + .factory('HostEventsViewer', ['$compile', 'CreateDialog', 'GetEvent', 'Wait', 'GetBasePath', 'LookUpName', 'Empty', 'GetEvents', + function($compile, CreateDialog, GetEvent, Wait, GetBasePath, LookUpName, Empty, GetEvents) { + return function(params) { + var parent_scope = params.scope, + url = params.url, + title = params.title, //optional + scope = parent_scope.$new(true); + + if (scope.removeModalReady) { + scope.removeModalReady(); + } + scope.removeModalReady = scope.$on('ModalReady', function() { + Wait('stop'); + $('#host-events-modal-dialog').dialog('open'); + }); + + if (scope.removeJobReady) { + scope.removeJobReady(); + } + scope.removeEventReady = scope.$on('EventsReady', function(e, data) { + var elem; + + scope.host_events = data.results; + + elem = angular.element(document.getElementById('host-events-modal-dialog')); + $compile(elem)(scope); + + CreateDialog({ + scope: scope, + width: 675, + height: 600, + minWidth: 450, + callback: 'ModalReady', + id: 'eventviewer-modal-dialog', + // onResizeStop: resizeText, + title: ( (title) ? title : 'Event Details' ), + onOpen: function() { + + } + }); + }); + + GetEvents({ + url: url, + scope: scope + }); + + scope.modalOK = function() { + $('#eventviewer-modal-dialog').dialog('close'); + scope.$destroy(); + }; + }; + }]) + + .factory('GetEvents', ['Wait', 'Rest', 'ProcessErrors', function(Wait, Rest, ProcessErrors) { + return function(params) { + var url = params.url, + scope = params.scope; + Wait('start'); + Rest.setUrl(url); + Rest.get() + .success(function(data) { + scope.$emit('EventsReady', data); + }) + .error(function(data, status) { + ProcessErrors(scope, data, status, null, { hdr: 'Error!', + msg: 'Failed to get events ' + url + '. GET returned: ' + status }); + }); + }; + }]); \ No newline at end of file diff --git a/awx/ui/static/partials/job_detail.html b/awx/ui/static/partials/job_detail.html index e22bf458aa..223b70fe41 100644 --- a/awx/ui/static/partials/job_detail.html +++ b/awx/ui/static/partials/job_detail.html @@ -226,9 +226,8 @@