Query option to override use trends option, fixes #1442

This commit is contained in:
Alexander Zobnin
2022-12-29 14:07:02 +01:00
parent 1cee6f0ae3
commit cf6b19e189
6 changed files with 39 additions and 15 deletions

View File

@@ -279,7 +279,7 @@ export class ZabbixDatasource extends DataSourceApi<ZabbixMetricsQuery, ZabbixDS
request.scopedVars = Object.assign({}, request.scopedVars, utils.getRangeScopedVars(request.range));
this.replaceTargetVariables(target, request);
const timeRange = this.buildTimeRange(request, target);
const useTrends = this.isUseTrends(timeRange);
const useTrends = this.isUseTrends(timeRange, target);
if (!target.queryType || target.queryType === c.MODE_METRICS) {
return this.queryNumericData(target, timeRange, useTrends, request);
@@ -857,11 +857,16 @@ export class ZabbixDatasource extends DataSourceApi<ZabbixMetricsQuery, ZabbixDS
});
}
isUseTrends(timeRange) {
isUseTrends(timeRange, target: ZabbixMetricsQuery) {
if (target.options.useTrends === 'false') {
return false;
}
const [timeFrom, timeTo] = timeRange;
const useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000);
const useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000);
const useTrends = this.trends && (timeFrom < useTrendsFrom || timeTo - timeFrom > useTrendsRange);
const useTrendsToggle = target.options.useTrends === 'true';
const useTrends =
(useTrendsToggle || this.trends) && (timeFrom < useTrendsFrom || timeTo - timeFrom > useTrendsRange);
return useTrends;
}