Skip to content

Commit 94342f3

Browse files
author
Gabriel Loewen
authored
Updating to latest
1 parent 8a8ac7f commit 94342f3

1 file changed

Lines changed: 61 additions & 79 deletions

File tree

statsproj/openstack_stats/static/aggregator.js

Lines changed: 61 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ function plotLines(div,results) {
5555
var container = $(div+"legend");
5656
container.find("input:checked").each(function() {
5757
for (var i=0; i<results.length; ++i) {
58-
if (this.name == results[i].label) {
59-
data.push(results[i]);
60-
}
58+
if (this.name == results[i].label) {
59+
data.push(results[i]);
60+
}
6161
}
6262
});
6363
function xAxisFormatter(val, axis) {
@@ -76,15 +76,15 @@ function plotLines(div,results) {
7676

7777
var date = new Date(val);
7878
if (showTime) {
79-
return date.getUTCMonth()+1 + "/" +
80-
date.getUTCDate() + "/" +
81-
date.getUTCFullYear() + "\n" +
82-
pad(date.getUTCHours()) + ":" +
83-
pad(date.getUTCMinutes());
79+
return date.getUTCMonth()+1 + "/" +
80+
date.getUTCDate() + "/" +
81+
date.getUTCFullYear() + "\n" +
82+
pad(date.getUTCHours()) + ":" +
83+
pad(date.getUTCMinutes());
8484
} else {
85-
return date.getUTCMonth()+1 + "/" +
86-
date.getUTCDate() + "/" +
87-
date.getUTCFullYear();
85+
return date.getUTCMonth()+1 + "/" +
86+
date.getUTCDate() + "/" +
87+
date.getUTCFullYear();
8888
}
8989
}
9090
var plot = $.plot($(div), data, {
@@ -98,27 +98,27 @@ function plotLines(div,results) {
9898
$(div).bind("plothover", function (event, pos, item) {
9999
var date = null;
100100
if (item) {
101-
date = item.datapoint[0];
102-
}
101+
date = item.datapoint[0];
102+
}
103103
if (date) {
104-
plot.unhighlight();
105-
var labels=[];
106-
for (var j=0; j<data.length; ++j) {
107-
for (i=0;i<data[j].data.length;++i) {
108-
var x = data[j].data[i];
109-
if (x[0] == date) {
110-
plot.highlight(j,i);
111-
labels.push({"label":data[j].label,"val":data[j].data[i][1]});
112-
break
113-
}
114-
}
115-
}
104+
plot.unhighlight();
105+
var labels=[];
106+
for (var j=0; j<data.length; ++j) {
107+
for (i=0;i<data[j].data.length;++i) {
108+
var x = data[j].data[i];
109+
if (x[0] == date) {
110+
plot.highlight(j,i);
111+
labels.push({"label":data[j].label,"val":data[j].data[i][1]});
112+
break
113+
}
114+
}
115+
}
116116
// Convert to javascript date object
117117
date = new Date(date);
118-
$("#tooltip").html(tooltipFormatter(date,labels)).css({top: item.pageY-$("#tooltip").height()+$("#tooltip").height()/2-5, left: item.pageX+15}).fadeIn(200);
118+
$("#tooltip").html(tooltipFormatter(date,labels)).css({top: item.pageY-$("#tooltip").height()+$("#tooltip").height()/2-5, left: item.pageX+15}).fadeIn(200);
119119
} else {
120-
$("#tooltip").hide();
121-
plot.unhighlight();
120+
$("#tooltip").hide();
121+
plot.unhighlight();
122122
}
123123
});
124124
$(div).mouseleave(function() {
@@ -131,15 +131,16 @@ function plotLines(div,results) {
131131
function plotPie(div, data) {
132132
$.plot($(div), data, {
133133
series: {
134-
pie: {
135-
show: true,
136-
radius: 1,
137-
stroke: { color: "#eee", width: 0.5 },
138-
label: { radius: 5/8,
139-
show: true,
140-
threshold: 0.01,
141-
}
142-
}
134+
pie: {
135+
show: true,
136+
radius: 1,
137+
label: { radius: 3/4,
138+
show: true,
139+
formatter: function(label, series){
140+
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'+label+'<br/>'+Math.round(series.percent)+'%</div>';
141+
},
142+
}
143+
}
143144
},
144145
legend: { show: false }
145146
});
@@ -169,7 +170,7 @@ function processData(project) {
169170
fail = novaFail;
170171
miss = novaMiss;
171172
} catch (err) {
172-
success = [];
173+
success = [];
173174
fail = [];
174175
miss = [];
175176
}
@@ -179,17 +180,17 @@ function processData(project) {
179180
upstreamFail = upstreamNovaFail;
180181
upstreamMiss = upstreamNovaMiss;
181182
} catch (err) {
182-
upstreamSuccess = [];
183+
upstreamSuccess = [];
183184
upstreamFail = [];
184-
upstreamMiss = [];
185+
upstreamMiss = [];
185186
}
186187
} else if (project == "neutron") {
187188
try {
188189
success = neutronSuccess;
189190
fail = neutronFail;
190191
miss = neutronMiss;
191192
} catch (err) {
192-
success = [];
193+
success = [];
193194
fail = [];
194195
miss = [];
195196
}
@@ -198,9 +199,9 @@ function processData(project) {
198199
upstreamFail = upstreamNeutronFail;
199200
upstreamMiss = upstreamNeutronMiss;
200201
} catch (err) {
201-
upstreamSuccess = [];
202+
upstreamSuccess = [];
202203
upstreamFail = [];
203-
upstreamMiss = [];
204+
upstreamMiss = [];
204205
}
205206
} else {
206207
return null;
@@ -227,44 +228,39 @@ function processData(project) {
227228
outage.push([date,0]);
228229
}
229230
var sums = [sum(success),sum(fail),sum(miss)];
230-
var results = [{label: 'Success', color: '#356AA0', data: success, points: {symbol: "triangle"}},
231-
{label: 'Failed', color: '#CD4B4B', data: fail, points: {symbol: "square"}},
232-
{label: 'Missed', color: '#555', data: miss, points: {symbol: "circle"}},
233-
{label: 'Upstream Success', color: '#6755E3', data: upstreamSuccess, points: {symbol: "triangle"}},
234-
{label: 'Upstream Failed', color: '#01FCEF', data: upstreamFail, points: {symbol: "square"}},
235-
{label: 'Upstream Missed', color: '#59DF00', data: upstreamMiss, points: {symbol: "circle"}},
236-
{label: 'Outage', color: 'RED', data: outage, points: {symbol: "exclamation"}, lines: {show: false}}]
231+
var results = [{label: 'Success', color: '#356AA0', data: success, points: {symbol: "triangle"}},
232+
{label: 'Failed', color: '#CD4B4B', data: fail, points: {symbol: "square"}},
233+
{label: 'Missed', color: '#555', data: miss, points: {symbol: "circle"}},
234+
{label: 'Upstream Success', color: '#6755E3', data: upstreamSuccess, points: {symbol: "triangle"}},
235+
{label: 'Upstream Failed', color: '#01FCEF', data: upstreamFail, points: {symbol: "square"}},
236+
{label: 'Upstream Missed', color: '#59DF00', data: upstreamMiss, points: {symbol: "circle"}},
237+
{label: 'Outage', color: 'RED', data: outage, points: {symbol: "exclamation"}, lines: {show: false}}]
237238
return [sums,results];
238239
}
239240

240241
// On document load, get the data, plot, and setup various options using JQuery
241242
$(document).ready(function() {
242243
// Set up the datepicker divs
243244
$('.datepicker').datepicker({ dateFormat: 'yy-mm-dd' });
244-
245-
$('#total').html(totalSuccess+totalFail+totalMiss);
246-
$('#success').html(totalSuccess);
247-
$('#failed').html(totalFail);
248-
$('#missed').html(totalMiss);
249-
$('#totalps').html(patchsetSuccess+patchsetFail+patchsetMiss);
250-
$('#successps').html(patchsetSuccess);
251-
$('#failedps').html(patchsetFail);
252-
$('#missedps').html(patchsetMiss);
245+
$('#total').html("Total: " + (totalSuccess+totalFail+totalMiss));
246+
$('#success').html("Success: " + totalSuccess);
247+
$('#failed').html("Failed: " + totalFail);
248+
$('#missed').html("Missed: " + totalMiss);
253249

254250
// Process the nova data and setup the nova charts
255251
var novaData = processData("nova");
256252
var novaSums = novaData[0];
257253
var totalNova = novaSums[0] + novaSums[1] + novaSums[2];
258-
$("#novaInfo").html("<strong>Total:</strong> " + totalNova + "<br /><strong>Success:</strong> " + novaSums[1] + "<br /><strong>Failed:</strong> " + novaSums[0] + "<br /><strong>Missed:</strong> " + novaSums[2]);
254+
$("#novaInfo").html("<h3>Total: " + totalNova + "</h3><h3>Success: " + novaSums[1] + "</h3><h3>Failed: " + novaSums[0] + "</h3><h3>Missed: " + novaSums[2] + "</h3>");
259255
if (totalNova > 0) {
260256
novaData = novaData[1];
261257
insertCheckBoxes("#novachartlegend", novaData, "nova");
262258
$("#novachartlegend").find("input").click(function() {plotLines("#novachart", novaData);});
263259
plotLines("#novachart",novaData);
264260

265261
var novapiedata = [{"label": "Failed", "data": novaSums[1], "color": "#CD4B4B"},
266-
{"label": "Success", "data": novaSums[0], "color": "#356AA0"},
267-
{"label": "Missed", "data": novaSums[2], "color": "#555"}];
262+
{"label": "Success", "data": novaSums[0], "color": "#356AA0"},
263+
{"label": "Missed", "data": novaSums[2], "color": "#555"}];
268264
plotPie("#novapiechart", novapiedata);
269265
} else {
270266
$("#novachart").html("<p>No data available or has been unselected in data model.</p>").css({height: 'auto'});
@@ -274,32 +270,18 @@ $(document).ready(function() {
274270
var neutronData = processData("neutron");
275271
var neutronSums = neutronData[0];
276272
var totalNeutron = neutronSums[0] + neutronSums[1] + neutronSums[2];
277-
$("#neutronInfo").html("<strong>Total:</strong> " + totalNeutron + "<br /><strong>Success:</strong> " + neutronSums[1] + "<br /><strong>Failed:</strong> " + neutronSums[0] + "<br /><strong>Missed:</strong> " + neutronSums[2]);
273+
$("#neutronInfo").html("<h3>Total: " + totalNeutron + "</h3><h3>Success: " + neutronSums[1] + "</h3><h3>Failed: " + neutronSums[0] + "</h3><h3>Missed: " + neutronSums[2] + "</h3>");
278274
if (totalNeutron > 0) {
279275
neutronData = neutronData[1];
280276
insertCheckBoxes("#neutronchartlegend", neutronData, "neutron");
281277
$("#neutronchartlegend").find("input").click(function() {plotLines("#neutronchart", neutronData);});
282278
plotLines("#neutronchart",neutronData);
283279

284280
var neutronpiedata = [{"label": "Failed", "data": neutronSums[1], "color": "#CD4B4B"},
285-
{"label": "Success", "data": neutronSums[0], "color": "#356AA0"},
286-
{"label": "Missed", "data": neutronSums[2], "color": "#555"}]
281+
{"label": "Success", "data": neutronSums[0], "color": "#356AA0"},
282+
{"label": "Missed", "data": neutronSums[2], "color": "#555"}]
287283
plotPie("#neutronpiechart", neutronpiedata);
288284
} else {
289285
$("#neutronchart").html("<p>No data available or has been unselected in data model.</p>").css({height: 'auto'});
290286
}
291-
$("#sidebar").css({"width": "auto", "max-width": "200px"});
292-
$("#sidebar").width("auto");
293-
$("#main").css("padding-left", $("#sidebar").width()+20);
294-
$("#print").click(function(e) {
295-
var win = window.open();
296-
win.document.write("<table>");
297-
win.document.write("<tr><td><h3>Nova</h3>"+$("#novaInfo").html()+"</td>");
298-
win.document.write("<td><img src=\""+$("#novachart").children()[0].toDataURL()+"\"/></td>");
299-
win.document.write("<td><img src=\""+$("#novapiechart").children()[0].toDataURL()+"\"/></td></tr>");
300-
win.document.write("<tr><td><h3>Neutron</h3>"+$("#neutronInfo").html()+"</td>");
301-
win.document.write("<td><img src=\""+$("#neutronchart").children()[0].toDataURL()+"\"/></td>");
302-
win.document.write("<td><img src=\""+$("#neutronpiechart").children()[0].toDataURL()+"\"/></td></tr>");
303-
win.document.write("</table>");
304-
});
305287
});

0 commit comments

Comments
 (0)