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 = "
\n"; + html = "
\n"; html += "
System Summary
\n"; html += "
\n"; - html += "
    \n"; + html += "\n"; + html += "\n"; + html += "\n"; + html += "\n"; + html += "\n"; + html += "\n"; + html += "\n"; + html += "\n"; for (var i=0; i < keys.length; i++) { - html += "
  • \n"; - html += "" + hash[keys[i]] + "\n"; - - if (keys[i] !== 'hosts' && keys[i] !== 'groups') { - html += ""; - } - + html += "
  • \n" + html += "\n"; } - html += "\n"; + html += "\n"; + html += "
    Total
    "; if (keys[i] == 'inventory') { html += 'Inventories'; } - else if (keys[i] == 'job_templates') { - html += 'Job Templates'; - } else { - html += keys[i].substring(0,1).toUpperCase() + keys[i].substring(1); + var txt = keys[i].replace(/\_/g,' '); + html += txt.substring(0,1).toUpperCase() + txt.substring(1); } - html += (keys[i] !== 'hosts' && keys[i] !== 'groups') ? "" : ""; - html += "\n"; + html += ""; + html += counts[keys[i]] + "
    \n"; html += "
\n"; - html += "
\n"; - + html += "
\n" var element = angular.element(document.getElementById(target)); element.html(html); - //scope = element.scope(); // Set scope specific to the element we're compiling, avoids circular reference - // From here use 'scope' to manipulate the form, as the form is not in '$scope' $compile(element)(scope); $rootScope.$emit('WidgetLoaded'); } @@ -93,9 +98,7 @@ angular.module('ObjectCountWidget', ['RestServices', 'Utilities']) Rest.setUrl(url); Rest.get() .success( function(data, status, headers, config) { - var count = {}; - count[obj] = data.count; - counts.push(count); + counts[obj] = data.count; scope.$emit('countReady'); }) .error( function(data, status, headers, config) { @@ -113,11 +116,18 @@ angular.module('ObjectCountWidget', ['RestServices', 'Utilities']) Rest.setUrl(current_version); Rest.get() .success( function(data, status, headers, config) { - for (obj in data) { - if (obj !== 'me' && obj !== 'authtoken' && obj !== 'config') { - getCount(obj); + for (var obj in data) { + if (obj == 'me' || obj == 'authtoken' || obj == 'config' || obj == 'inventory_sources') { + delete data[obj]; } } + expected = 0; + for (var obj in data) { + expected++; + } + for (obj in data) { + getCount(obj); + } }) .error( function(data, status, headers, config) { ProcessErrors(scope, data, status, null, diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index 06fbb3f5ba..ab166b61da 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -231,13 +231,11 @@ dd { text-align: justify; } - - .navbar-collapse { padding-right: 0; } -.nav >li >a:last-child { +.main-menu .nav >li >a:last-child { padding-right: 0; padding-left: 20px; } @@ -1201,6 +1199,10 @@ tr td button i { } } +#home #refresh-row { + margin-bottom: 5px; +} + /* Large desktop */ diff --git a/awx/ui/static/partials/home.html b/awx/ui/static/partials/home.html index 5173abcfdf..2736dcbe3a 100644 --- a/awx/ui/static/partials/home.html +++ b/awx/ui/static/partials/home.html @@ -1,4 +1,11 @@
+
+
+
+ +
+
+
diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index 43eddb68eb..1fb2bdf440 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -111,6 +111,7 @@ + {% endif %}