|
@@ -17,6 +17,7 @@ class MetricsPanelCtrl extends PanelCtrl {
|
|
|
$timeout: any;
|
|
$timeout: any;
|
|
|
datasourceSrv: any;
|
|
datasourceSrv: any;
|
|
|
timeSrv: any;
|
|
timeSrv: any;
|
|
|
|
|
+ templateSrv: any;
|
|
|
timing: any;
|
|
timing: any;
|
|
|
range: any;
|
|
range: any;
|
|
|
rangeRaw: any;
|
|
rangeRaw: any;
|
|
@@ -34,6 +35,7 @@ class MetricsPanelCtrl extends PanelCtrl {
|
|
|
this.$q = $injector.get('$q');
|
|
this.$q = $injector.get('$q');
|
|
|
this.datasourceSrv = $injector.get('datasourceSrv');
|
|
this.datasourceSrv = $injector.get('datasourceSrv');
|
|
|
this.timeSrv = $injector.get('timeSrv');
|
|
this.timeSrv = $injector.get('timeSrv');
|
|
|
|
|
+ this.templateSrv = $injector.get('templateSrv');
|
|
|
|
|
|
|
|
if (!this.panel.targets) {
|
|
if (!this.panel.targets) {
|
|
|
this.panel.targets = [{}];
|
|
this.panel.targets = [{}];
|
|
@@ -119,7 +121,8 @@ class MetricsPanelCtrl extends PanelCtrl {
|
|
|
|
|
|
|
|
// check panel time overrrides
|
|
// check panel time overrrides
|
|
|
if (this.panel.timeFrom) {
|
|
if (this.panel.timeFrom) {
|
|
|
- var timeFromInfo = rangeUtil.describeTextRange(this.panel.timeFrom);
|
|
|
|
|
|
|
+ var timeFromInterpolated = this.templateSrv.replace(this.panel.timeFrom, this.panel.scopedVars);
|
|
|
|
|
+ var timeFromInfo = rangeUtil.describeTextRange(timeFromInterpolated);
|
|
|
if (timeFromInfo.invalid) {
|
|
if (timeFromInfo.invalid) {
|
|
|
this.timeInfo = 'invalid time override';
|
|
this.timeInfo = 'invalid time override';
|
|
|
return;
|
|
return;
|
|
@@ -136,13 +139,14 @@ class MetricsPanelCtrl extends PanelCtrl {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (this.panel.timeShift) {
|
|
if (this.panel.timeShift) {
|
|
|
- var timeShiftInfo = rangeUtil.describeTextRange(this.panel.timeShift);
|
|
|
|
|
|
|
+ var timeShiftInterpolated = this.templateSrv.replace(this.panel.timeShift, this.panel.scopedVars);
|
|
|
|
|
+ var timeShiftInfo = rangeUtil.describeTextRange(timeShiftInterpolated);
|
|
|
if (timeShiftInfo.invalid) {
|
|
if (timeShiftInfo.invalid) {
|
|
|
this.timeInfo = 'invalid timeshift';
|
|
this.timeInfo = 'invalid timeshift';
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var timeShift = '-' + this.panel.timeShift;
|
|
|
|
|
|
|
+ var timeShift = '-' + timeShiftInterpolated;
|
|
|
this.timeInfo += ' timeshift ' + timeShift;
|
|
this.timeInfo += ' timeshift ' + timeShift;
|
|
|
this.range.from = dateMath.parseDateMath(timeShift, this.range.from, false);
|
|
this.range.from = dateMath.parseDateMath(timeShift, this.range.from, false);
|
|
|
this.range.to = dateMath.parseDateMath(timeShift, this.range.to, true);
|
|
this.range.to = dateMath.parseDateMath(timeShift, this.range.to, true);
|