diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index 894d71209f..c8f5170d14 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -22,6 +22,35 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com paths = $location.path().replace(/^\//, '').split('/'), mode = (paths[0] === 'inventories') ? 'edit' : 'select'; + function ellipsis(a) { + if (a.length > 20) { + return a.substr(0,20) + '...'; + } + return a; + } + + function attachElem(event, html, title) { + var elem = $(event.target).parent(); + try { + elem.tooltip('hide'); + elem.popover('destroy'); + } + catch(err) { + //ignore + } + elem.attr({ "aw-pop-over": html, "data-title": title, "data-placement": "right" }); + $compile(elem)($scope); + elem.on('shown.bs.popover', function() { + $('.popover').each(function() { + $compile($(this))($scope); //make nested directives work! + }); + $('.popover-content, .popover-title').click(function() { + elem.popover('hide'); + }); + }); + elem.popover('show'); + } + view.inject(InventoryList, { mode: mode, scope: $scope }); $rootScope.flashMessage = null; @@ -31,6 +60,7 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com list: list, url: defaultUrl }); + PaginateInit({ scope: $scope, list: list, @@ -128,63 +158,77 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com $scope.search(list.iterator); }); + if ($scope.removeHostSummaryReady) { + $scope.removeHostSummaryReady(); + } + $scope.removeHostSummaryReady = $scope.$on('HostSummaryReady', function(e, event, data) { + + var html, title = "Recent Jobs"; + Wait('stop'); + if (data.count > 0) { + html = "\n"; + html += "\n"; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += "\n"; + html += "\n"; + html += "\n"; + + data.results.forEach(function(row) { + html += "\n"; + html += "\n"; + html += ""; + html += ""; + html += ""; + html += "\n"; + }); + html += "\n"; + html += "
StatusFinishedViewName
" + ($filter('date')(row.finished,'MM/dd HH:mm:ss')).replace(/ /,'
') + "
Events
" + + "Hosts
" + ellipsis(row.name) + "
\n"; + html += "
esc or click to close
\n"; + } + else { + html = "

No recent job data available for this inventory.

\n" + + "
esc or click to close
\n"; + } + attachElem(event, html, title); + }); if ($scope.removeGroupSummaryReady) { $scope.removeGroupSummaryReady(); } $scope.removeGroupSummaryReady = $scope.$on('GroupSummaryReady', function(e, event, inventory, data) { - var j, elem, html, title, row; + var html, title; - function ellipsis(a) { - if (a.length > 20) { - return a.substr(0,20) + '...'; - } - return a; - } + Wait('stop'); - if (data.count) { - html = "\n"; - html += "\n"; - html += "\n"; - html += "\n"; - html += "\n"; - html += "\n"; + // Build the html for our popover + html = "
StatusGroupLast Sync
\n"; + html += "\n"; + html += ""; + html += ""; + html += ""; + html += ""; + html += ""; + html += "\n"; + html += "\n"; + data.results.forEach( function(row) { + html += ""; + html += ""; + html += ""; + html += ""; html += "\n"; - html += "\n"; - html += "\n"; - for (j=0; j < data.results.length; j++) { - row = data.results[j]; - html += ""; - html += ""; - html += ""; - html += ""; - html += "\n"; - } - html += "\n"; - html += "
StatusLast SyncGroup
" + ($filter('date')(row.last_updated,'MM/dd HH:mm:ss')).replace(/ /,'
') + "
" + ellipsis(row.summary_fields.group.name) + "
" + ellipsis(row.summary_fields.group.name) + "" + $filter('date')(row.last_updated,'MM/dd HH:mm:ss') + "
\n"; - html += "
esc or click to close
\n"; - title = "Sync Status"; - elem = $(event.target).parent(); - try { - elem.tooltip('hide'); - elem.popover('destroy'); - } - catch(err) { - //ignore - } - elem.attr({ "aw-pop-over": html, "data-title": title, "data-placement": "right" }); - Wait('stop'); - $compile(elem)($scope); - elem.on('shown.bs.popover', function() { - $('.popover').each(function() { - $compile($(this))($scope); //make nested directives work! - }); - $('.popover-content, .popover-title').click(function() { - elem.popover('hide'); - }); - }); - elem.popover('show'); - } + }); + html += "\n"; + html += "\n"; + html += "
esc or click to close
\n"; + title = "Sync Status"; + attachElem(event, html, title); }); $scope.showGroupSummary = function(event, id) { @@ -207,6 +251,24 @@ function InventoriesList($scope, $rootScope, $location, $log, $routeParams, $com } }; + $scope.showHostSummary = function(event, id) { + var url; + if (!Empty(id)) { + Wait('start'); + url = GetBasePath('jobs') + "?type=job&inventory=" + id + "&order_by=-finished&page_size=5"; + Rest.setUrl(url); + Rest.get() + .success( function(data) { + $scope.$emit('HostSummaryReady', event, data); + }) + .error( function(data, status) { + ProcessErrors( $scope, data, status, null, { hdr: 'Error!', + msg: 'Call to ' + url + ' failed. GET returned: ' + status + }); + }); + } + }; + $scope.viewJob = function(url) { LogViewer({ scope: $scope,