Merge branch 'master' into getting-started-panel

This commit is contained in:
Torkel Ödegaard
2016-11-24 13:17:22 +01:00
1047 changed files with 32752 additions and 766238 deletions

View File

@@ -40,6 +40,7 @@ var reducerTypes = [
{text: 'sum()' , value: 'sum'},
{text: 'count()', value: 'count'},
{text: 'last()', value: 'last'},
{text: 'median()', value: 'median'},
];
var noDataModes = [

View File

@@ -42,7 +42,7 @@
<span class="gf-form-label query-keyword width-5" ng-if="$index===0">WHEN</span>
</div>
<div class="gf-form">
<query-part-editor class="gf-form-label query-part width-5" part="conditionModel.reducerPart" handle-event="ctrl.handleReducerPartEvent(conditionModel, $event)">
<query-part-editor class="gf-form-label query-part width-6" part="conditionModel.reducerPart" handle-event="ctrl.handleReducerPartEvent(conditionModel, $event)">
</query-part-editor>
<span class="gf-form-label query-keyword">OF</span>
</div>

View File

@@ -493,8 +493,6 @@ export class DashboardModel {
templateVariable.hide = 2;
} else if (templateVariable.hideLabel) {
templateVariable.hide = 1;
} else {
templateVariable.hide = 0;
}
});
}

View File

@@ -15,6 +15,7 @@ export class SubmenuCtrl {
private $location) {
this.annotations = this.dashboard.templating.list;
this.variables = this.variableSrv.variables;
console.log(this.variables);
}
annotationStateChanged() {

View File

@@ -143,7 +143,14 @@ function(angular, _) {
};
modalScope.save = function() {
tracker.scope.$emit('save-dashboard');
var cancel = $rootScope.$on('dashboard-saved', function() {
cancel();
$timeout(function() {
tracker.goto_next();
});
});
$rootScope.$emit('save-dashboard');
};
$rootScope.appEvent('show-modal', {

View File

@@ -252,6 +252,7 @@ class MetricsPanelCtrl extends PanelCtrl {
},
complete: () => {
console.log('panel: observer got complete');
this.dataStream = null;
}
});
}

View File

@@ -106,7 +106,7 @@ export class VariableEditorCtrl {
};
$scope.duplicate = function(variable) {
var clone = _.cloneDeep(variable.getModel());
var clone = _.cloneDeep(variable.getSaveModel());
$scope.current = variableSrv.createVariableFromModel(clone);
$scope.variables.push($scope.current);
$scope.current.name = 'copy_of_'+variable.name;

View File

@@ -22,7 +22,7 @@ function ($) {
var len = series.datapoints.points.length;
for (var j = initial; j < len; j += ps) {
// Special case of a non stepped line, highlight the very last point just before a null point
if ((series.datapoints.points[initial] != null && series.datapoints.points[j] == null && ! series.lines.steps)
if ((!series.lines.steps && series.datapoints.points[initial] != null && series.datapoints.points[j] == null)
//normal case
|| series.datapoints.points[j] > posX) {
return Math.max(j - ps, 0)/ps;
@@ -41,15 +41,17 @@ function ($) {
return j - 1;
};
this.showTooltip = function(absoluteTime, innerHtml, pos) {
var body = '<div class="graph-tooltip-time">'+ absoluteTime + '</div>';
body += innerHtml + '</div>';
$tooltip.html(body).place_tt(pos.pageX + 20, pos.pageY);
this.showTooltip = function(absoluteTime, innerHtml, pos, xMode) {
if (xMode === 'time') {
innerHtml = '<div class="graph-tooltip-time">'+ absoluteTime + '</div>' + innerHtml;
}
$tooltip.html(innerHtml).place_tt(pos.pageX + 20, pos.pageY);
};
this.getMultiSeriesPlotHoverInfo = function(seriesList, pos) {
var value, i, series, hoverIndex, hoverDistance, pointTime, yaxis;
var results = [];
// 3 sub-arrays, 1st for hidden series, 2nd for left yaxis, 3rd for right yaxis.
var results = [[],[],[]];
//now we know the current X (j) position for X and Y values
var last_value = 0; //needed for stacked values
@@ -60,14 +62,14 @@ function ($) {
series = seriesList[i];
if (!series.data.length || (panel.legend.hideEmpty && series.allIsNull)) {
// Init value & yaxis so that it does not brake series sorting
results.push({ hidden: true, value: 0, yaxis: 0 });
// Init value so that it does not brake series sorting
results[0].push({ hidden: true, value: 0 });
continue;
}
if (!series.data.length || (panel.legend.hideZero && series.allIsZero)) {
// Init value & yaxis so that it does not brake series sorting
results.push({ hidden: true, value: 0, yaxis: 0 });
// Init value so that it does not brake series sorting
results[0].push({ hidden: true, value: 0 });
continue;
}
@@ -110,18 +112,20 @@ function ($) {
yaxis = series.yaxis.n;
}
results.push({
results[yaxis].push({
value: value,
hoverIndex: hoverIndex,
color: series.color,
label: series.label,
time: pointTime,
distance: hoverDistance,
yaxis: yaxis,
index: i
});
}
// Contat the 3 sub-arrays
results = results[0].concat(results[1],results[2]);
// Time of the point closer to pointer
results.time = minTime;
@@ -145,6 +149,8 @@ function ($) {
elem.bind("plothover", function (event, pos, item) {
var plot = elem.data().plot;
var plotData = plot.getData();
var xAxes = plot.getXAxes();
var xMode = xAxes[0].options.mode;
var seriesList = getSeriesFn();
var group, value, absoluteTime, hoverInfo, i, series, seriesHtml, tooltipFormat;
@@ -172,7 +178,7 @@ function ($) {
absoluteTime = dashboard.formatDate(seriesHoverInfo.time, tooltipFormat);
// Dynamically reorder the hovercard for the current time point if the
// option is enabled, sort by yaxis by default.
// option is enabled.
if (panel.tooltip.sort === 2) {
seriesHoverInfo.sort(function(a, b) {
return b.value - a.value;
@@ -181,10 +187,6 @@ function ($) {
seriesHoverInfo.sort(function(a, b) {
return a.value - b.value;
});
} else {
seriesHoverInfo.sort(function(a, b) {
return a.yaxis - b.yaxis;
});
}
for (i = 0; i < seriesHoverInfo.length; i++) {
@@ -209,7 +211,7 @@ function ($) {
plot.highlight(hoverInfo.index, hoverInfo.hoverIndex);
}
self.showTooltip(absoluteTime, seriesHtml, pos);
self.showTooltip(absoluteTime, seriesHtml, pos, xMode);
}
// single series tooltip
else if (item) {
@@ -230,7 +232,7 @@ function ($) {
group += '<div class="graph-tooltip-value">' + value + '</div>';
self.showTooltip(absoluteTime, group, pos);
self.showTooltip(absoluteTime, group, pos, xMode);
}
// no hit
else {

View File

@@ -25,8 +25,10 @@ var ARGS;
// Intialize a skeleton with nothing but a rows array and service object
dashboard = {
rows : [],
schemaVersion: 13,
};
// Set a title
dashboard.title = 'Scripted and templated dash';
@@ -39,23 +41,22 @@ dashboard.time = {
};
dashboard.templating = {
enable: true,
list: [
{
name: 'test',
query: 'apps.backend.*',
refresh: true,
options: [],
current: null,
type: 'custom'
refresh: 1,
type: 'query',
datasource: null,
hide: 2,
},
{
name: 'test2',
query: '*',
refresh: true,
options: [],
current: null,
type: 'custom'
refresh: 1,
type: 'query',
datasource: null,
hide: 2,
}
]
};

View File

@@ -72,52 +72,49 @@ charts or filled areas).
horizontal = s.bars.horizontal,
withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y),
withsteps = withlines && s.lines.steps,
fromgap = true,
keyOffset = horizontal ? 1 : 0,
accumulateOffset = horizontal ? 0 : 1,
i = 0, j = 0, l, m;
while (true) {
// browse all points from the current series and from the previous series
if (i >= points.length && j >= otherpoints.length)
break;
// newpoints will replace current series with
// as many points as different timestamps we have in the 2 (current & previous) series
l = newpoints.length;
px = points[i + keyOffset];
py = points[i + accumulateOffset];
qx = otherpoints[j + keyOffset];
qy = otherpoints[j + accumulateOffset];
bottom = 0;
if (i < points.length && px == null) {
// let's ignore null points from current series, nothing to do with them
i += ps;
}
else if (j < otherpoints.length && qx == null) {
// let's ignore null points from previous series, nothing to do with them
j += otherps;
}
else if (i >= points.length) {
// no more points in the current series, simply take the remaining points
// from the previous series so that next series will correctly stack
for (m = 0; m < ps; ++m)
newpoints.push(otherpoints[j + m]);
bottom = qy;
j += otherps;
}
else if (j >= otherpoints.length) {
// no more points in the previous series, of course let's take
// the remaining points from the current series
if (i < points.length && points[i] == null) {
// copy gaps
for (m = 0; m < ps; ++m)
newpoints.push(points[i + m]);
i += ps;
}
else if (i >= points.length) {
// take the remaining points from the previous series
for (m = 0; m < ps; ++m)
newpoints.push(otherpoints[j + m]);
if (withbottom)
newpoints[l + 2] = otherpoints[j + accumulateOffset];
j += otherps;
}
else if (j >= otherpoints.length) {
// take the remaining points from the current series
for (m = 0; m < ps; ++m)
newpoints.push(points[i + m]);
i += ps;
}
else if (j < otherpoints.length && otherpoints[j] == null) {
// ignore point
j += otherps;
}
else {
// next available points from current and previous series have the same timestamp
// cases where we actually got two points
px = points[i + keyOffset];
py = points[i + accumulateOffset];
qx = otherpoints[j + keyOffset];
qy = otherpoints[j + accumulateOffset];
bottom = 0;
if (px == qx) {
// so take the point from the current series and skip the previous' one
for (m = 0; m < ps; ++m)
newpoints.push(points[i + m]);
@@ -127,23 +124,27 @@ charts or filled areas).
i += ps;
j += otherps;
}
// next available point with the smallest timestamp is from the previous series
else if (px > qx) {
// so take the point from the previous series so that next series will correctly stack
for (m = 0; m < ps; ++m)
newpoints.push(otherpoints[j + m]);
// we might be able to interpolate
if (i > 0 && points[i - ps] != null)
newpoints[l + accumulateOffset] += py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
bottom = qy;
// take the point from the previous series so that next series will correctly stack
if (i == 0) {
for (m = 0; m < ps; ++m)
newpoints.push(otherpoints[j + m]);
bottom = qy;
}
// we got past point below, might need to
// insert interpolated extra point
if (i > 0 && points[i - ps] != null) {
intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
newpoints.push(qx);
newpoints.push(intery + qy);
for (m = 2; m < ps; ++m)
newpoints.push(points[i + m]);
bottom = qy;
}
j += otherps;
}
// (px < qx) next available point with the smallest timestamp is from the current series
else {
// so of course let's take the point from the current series
else { // px < qx
for (m = 0; m < ps; ++m)
newpoints.push(points[i + m]);
@@ -156,10 +157,22 @@ charts or filled areas).
i += ps;
}
}
if (l != newpoints.length && withbottom)
newpoints[l + 2] = bottom;
fromgap = false;
if (l != newpoints.length && withbottom)
newpoints[l + 2] = bottom;
}
// maintain the line steps invariant
if (withsteps && l != newpoints.length && l > 0
&& newpoints[l] != null
&& newpoints[l] != newpoints[l - ps]
&& newpoints[l + 1] != newpoints[l - ps + 1]) {
for (m = 0; m < ps; ++m)
newpoints[l + ps + m] = newpoints[l + m];
newpoints[l + 1] = newpoints[l - ps + 1];
}
}
datapoints.points = newpoints;