From 0c4758a220109416a8b9b3192a2b9b6e85e1ebf2 Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Mon, 9 Jun 2014 16:02:50 -0700 Subject: [PATCH] retry chart if it fails --- planetstack/core/static/planetstack_graphs.js | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/planetstack/core/static/planetstack_graphs.js b/planetstack/core/static/planetstack_graphs.js index fb33022..5f7977c 100644 --- a/planetstack/core/static/planetstack_graphs.js +++ b/planetstack/core/static/planetstack_graphs.js @@ -10,11 +10,13 @@ function renderChart(newStyle, dialog, container, dataSourceUrl, yColumn, xColum $('.modal-body').scrollTop(0); } - console.log(dataSourceUrl); + startQuery(container, dataSourceUrl, yColumn, xColumn, aggFunc, options) +} +function startQuery(container, dataSourceUrl, yColumn, xColumn, aggFunc, options) { var query = new google.visualization.Query(dataSourceUrl); query && query.abort(); - query.send(function(response) {handleResponse_psg(container, response, yColumn, xColumn, aggFunc, options);}); + query.send(function(response) {handleResponse_psg(container, dataSourceUrl, response, yColumn, xColumn, aggFunc, options);}); } // NOTE: appended _psg to showLine() and handleResponse() to prevent conflict @@ -66,7 +68,7 @@ function fixDate2(unixDate) { return new Date(unixDate); } -function handleResponse_psg(container, response, yColumn, xColumn, aggFunc, options) { +function handleResponse_psg(container, dataSourceUrl, response, yColumn, xColumn, aggFunc, options) { var supportedClasses = { 'Table':google.visualization.Table, 'LineChart':google.visualization.LineChart, @@ -76,6 +78,12 @@ function handleResponse_psg(container, response, yColumn, xColumn, aggFunc, opti 'PieChart':google.visualization.PieChart, 'Histogram':google.visualization.Histogram}; + if (response.isError()) { + #console.log("retry chart"); + setTimeout(function () { startQuery(container, dataSourceUrl, yColumn, xColumn, aggFunc, options) }, 5000); + return + } + var proxy = new google.visualization.ChartWrapper({ 'chartType': 'Table', 'containerId': 'graph_work', @@ -113,15 +121,4 @@ function handleResponse_psg(container, response, yColumn, xColumn, aggFunc, opti proxy.draw(); } -$('.nodesLabel, .nodesValue').click(function() { - renderChart(false,"#chartsModal", "#graph", window.pageAnalyticsUrl, 0, "Number of Nodes", 2, "Node Count", google.visualization.data.sum); -}); - -$('.cpuLabel, .cpuValue').click(function() { - var jsonData = window.pageAnalyticsData; - renderChart(false,"#chartsModal", "#graph", window.pageAnalyticsUrl, 0, "Average CPU", 1, "Average CPU", google.visualization.data.sum); -}); -$('.bandwidthLabel, .bandwidthValue').click(function() { - var jsonData = window.pageBandData; - renderChart(false,"#chartsModal", "#graph", window.pageBandUrl, 0, "Total Bandwidth (Gbps)", 1, "Total Bandwidth", agg_bandwidth); -}); + -- 2.47.0