Fix displaying graphs with no content

This commit is contained in:
Joe Fiorini
2015-01-28 14:10:31 -05:00
parent 6e2c9f5eda
commit 4fc86e30ea
3 changed files with 19 additions and 16 deletions

View File

@@ -96,9 +96,6 @@ function Home($scope, $compile, $routeParams, $rootScope, $location, $log, Wait,
$scope.graphData = graphData; $scope.graphData = graphData;
if ($rootScope.user_is_superuser !== true) {
$('#dash-host-count-graph').remove(); //replaceWith("<div id='dash-host-count-graph' class='left-side col-sm-12 col-xs-12'></div>");
}
DashboardJobs({ DashboardJobs({
scope: $scope, scope: $scope,
target: 'dash-jobs-list', target: 'dash-jobs-list',

View File

@@ -17,6 +17,11 @@ angular.module('DashboardGraphs')
}); });
function adjustGraphSize() { function adjustGraphSize() {
if (angular.isUndefined(host_pie_chart)) {
return;
}
var parentHeight = element.parent().parent().height(); var parentHeight = element.parent().parent().height();
var toolbarHeight = element.find('.toolbar').height(); var toolbarHeight = element.find('.toolbar').height();
var container = element.find('svg').parent(); var container = element.find('svg').parent();
@@ -80,19 +85,20 @@ angular.module('DashboardGraphs')
return host_pie_chart; return host_pie_chart;
} }
else{ else{
winHeight = $($window).height(); // This should go in a template or something
available_height = winHeight - $('#main-menu-container .navbar').outerHeight() - $('#count-container').outerHeight() - 120; // but I'm at the end of a card and need to get this done.
element.find('.graph-wrapper').height(available_height/2); // We definitely need to refactor this, I'm letting
element.find('svg').replaceWith('<canvas id="circlecanvas" width="120" height="120"></canvas>'); // good enough be good enough for right now.
var notFoundContainer = $('<div></div>');
notFoundContainer.css({
'text-align': 'center',
'width': '100%',
'padding-top': '2em'
});
canvas = document.getElementById("circlecanvas"); notFoundContainer.text('No host data');
context = canvas.getContext("2d");
context.arc(55, 55, 50, 0, Math.PI * 2, false); element.find('svg').replaceWith(notFoundContainer);
context.lineWidth = 1;
context.strokeStyle = '#1778c3';
context.stroke();
context.font = "12px Open Sans";
context.fillText("No Host data",18,55);
} }
} }

View File

@@ -26,7 +26,7 @@
<div class="row"> <div class="row">
<div id="dash-jobs-list" class="left-side col-sm-6 col-xs-12"></div> <div id="dash-jobs-list" class="left-side col-sm-6 col-xs-12"></div>
<div class="right-side col-sm-6 col-xs-12"> <div class="right-side col-sm-6 col-xs-12">
<div id="dash-host-count-graph" auto-size-module class="graph-container"> <div id="dash-host-count-graph" ng-if="user_is_superuser" auto-size-module class="graph-container">
<host-count-graph data="graphData.hostCounts"></host-count-graph> <host-count-graph data="graphData.hostCounts"></host-count-graph>
</div> </div>
</div> </div>