From 4fc86e30ea6d6a93bf85e72afc32458b32567583 Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Wed, 28 Jan 2015 14:10:31 -0500 Subject: [PATCH] Fix displaying graphs with no content --- awx/ui/static/js/controllers/Home.js | 3 -- .../static/js/directives/host-status-graph.js | 30 +++++++++++-------- awx/ui/static/partials/home.html | 2 +- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index 4fb44d07d4..314a1e4503 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -96,9 +96,6 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, $log, Wait, $scope.graphData = graphData; - if ($rootScope.user_is_superuser !== true) { - $('#dash-host-count-graph').remove(); //replaceWith("
"); - } DashboardJobs({ scope: $scope, target: 'dash-jobs-list', diff --git a/awx/ui/static/js/directives/host-status-graph.js b/awx/ui/static/js/directives/host-status-graph.js index a724d03724..281e6749f9 100644 --- a/awx/ui/static/js/directives/host-status-graph.js +++ b/awx/ui/static/js/directives/host-status-graph.js @@ -17,6 +17,11 @@ angular.module('DashboardGraphs') }); function adjustGraphSize() { + + if (angular.isUndefined(host_pie_chart)) { + return; + } + var parentHeight = element.parent().parent().height(); var toolbarHeight = element.find('.toolbar').height(); var container = element.find('svg').parent(); @@ -80,19 +85,20 @@ angular.module('DashboardGraphs') return host_pie_chart; } else{ - winHeight = $($window).height(); - available_height = winHeight - $('#main-menu-container .navbar').outerHeight() - $('#count-container').outerHeight() - 120; - element.find('.graph-wrapper').height(available_height/2); - element.find('svg').replaceWith(''); + // This should go in a template or something + // but I'm at the end of a card and need to get this done. + // We definitely need to refactor this, I'm letting + // good enough be good enough for right now. + var notFoundContainer = $('
'); + notFoundContainer.css({ + 'text-align': 'center', + 'width': '100%', + 'padding-top': '2em' + }); - canvas = document.getElementById("circlecanvas"); - context = canvas.getContext("2d"); - context.arc(55, 55, 50, 0, Math.PI * 2, false); - context.lineWidth = 1; - context.strokeStyle = '#1778c3'; - context.stroke(); - context.font = "12px Open Sans"; - context.fillText("No Host data",18,55); + notFoundContainer.text('No host data'); + + element.find('svg').replaceWith(notFoundContainer); } } diff --git a/awx/ui/static/partials/home.html b/awx/ui/static/partials/home.html index 5b0e035011..62c90258d0 100644 --- a/awx/ui/static/partials/home.html +++ b/awx/ui/static/partials/home.html @@ -26,7 +26,7 @@
-
+