check if result is a scalar in order to display correct number of returned time series

This commit is contained in:
conorbroderick 2017-05-19 14:21:55 +01:00 committed by Brian Brazil
parent 09fcbf78df
commit 9c953064c3
2 changed files with 71 additions and 41 deletions

File diff suppressed because one or more lines are too long

View File

@ -415,7 +415,14 @@ Prometheus.Graph.prototype.submitQuery = function() {
return;
}
var duration = new Date().getTime() - startTime;
var totalTimeSeries = (xhr.responseJSON.data !== undefined) ? xhr.responseJSON.data.result.length : 0;
var totalTimeSeries = 0;
if (xhr.responseJSON.data !== undefined) {
if (xhr.responseJSON.data.resultType === "scalar") {
totalTimeSeries = 1;
} else {
totalTimeSeries = xhr.responseJSON.data.result.length;
}
}
self.evalStats.html("Load time: " + duration + "ms <br /> Resolution: " + resolution + "s <br />" + "Total time series: " + totalTimeSeries);
self.spinner.hide();
}