diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 3e8e77b43e..5af7f5541b 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -73,6 +73,7 @@ angular.module('ansible', [ 'JobStatusWidget', 'InventorySyncStatusWidget', 'SCMSyncStatusWidget', + 'ObjectCountWidget', 'JobsHelper', 'InventoryStatusDefinition' ]) diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index 6aa4e6dd75..a4fa35b27d 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -10,12 +10,13 @@ 'use strict'; -function Home ($routeParams, $scope, $rootScope, $location, Wait, JobStatus, InventorySyncStatus, SCMSyncStatus, ClearScope) +function Home ($routeParams, $scope, $rootScope, $location, Wait, ObjectCount, JobStatus, InventorySyncStatus, SCMSyncStatus, + ClearScope) { ClearScope('home'); //Garbage collection. Don't leave behind any listeners/watchers from the prior //scope. - var waitCount = 3; + var waitCount = 4; var loadedCount = 0; if (!$routeParams['login']) { @@ -25,7 +26,8 @@ function Home ($routeParams, $scope, $rootScope, $location, Wait, JobStatus, Inv JobStatus({ target: 'container1' }); InventorySyncStatus({ target: 'container2' }); - SCMSyncStatus({ target: 'container3' }); + SCMSyncStatus({ target: 'container4' }); + ObjectCount({ target: 'container3' }); $rootScope.$on('WidgetLoaded', function() { // Once all the widgets report back 'loaded', turn off Wait widget @@ -36,5 +38,5 @@ function Home ($routeParams, $scope, $rootScope, $location, Wait, JobStatus, Inv }); } -Home.$inject=[ '$routeParams', '$scope', '$rootScope', '$location', 'Wait', 'JobStatus', 'InventorySyncStatus', +Home.$inject=[ '$routeParams', '$scope', '$rootScope', '$location', 'Wait', 'ObjectCount', 'JobStatus', 'InventorySyncStatus', 'SCMSyncStatus', 'ClearScope']; \ No newline at end of file diff --git a/awx/ui/static/js/widgets/ObjectCount.js b/awx/ui/static/js/widgets/ObjectCount.js index 6cd55f52ce..16097f54de 100644 --- a/awx/ui/static/js/widgets/ObjectCount.js +++ b/awx/ui/static/js/widgets/ObjectCount.js @@ -15,20 +15,25 @@ angular.module('ObjectCountWidget', ['RestServices', 'Utilities']) var current_version; var scope = $rootScope.$new(); - var counts = []; + var counts = {}; var target = params.target; - - scope.$on('countReady', function(e, obj, count) { + var expected; + + if (scope.removeCountReady) { + scope.removeCountReady(); + } + scope.removeCountReady = scope.$on('countReady', function(e, obj, count) { var keys=[]; - var hash = {}; - if (counts.length == 10) { + var html, itm; + var cnt = 0; + for (itm in counts) { + cnt++; + } + if (cnt == expected) { // sort the list of objs - for (var i=0; i < counts.length; i++) { - for (var key in counts[i]) { - if (key !== 'hosts' && key !== 'groups') { - keys.push(key); - } - hash[key] = counts[i][key]; + for (var key in counts) { + if (key !== 'hosts' && key !== 'groups') { + keys.push(key); } } // sort the keys, forcing groups and hosts to appear directlry after inventory @@ -45,43 +50,43 @@ angular.module('ObjectCountWidget', ['RestServices', 'Utilities']) } } keys = new_keys; - - var html = "