Fix data alignment for db connection queries
This commit is contained in:
@@ -2,7 +2,7 @@ import _ from 'lodash';
|
||||
import moment from 'moment';
|
||||
import * as c from './constants';
|
||||
import { VariableQuery, VariableQueryTypes } from './types';
|
||||
import { MappingType, ValueMapping, getValueFormats, DataFrame, FieldType, rangeUtil } from '@grafana/data';
|
||||
import { DataFrame, FieldType, getValueFormats, MappingType, rangeUtil, ValueMapping } from '@grafana/data';
|
||||
|
||||
/*
|
||||
* This regex matches 3 types of variable reference with an optional format specifier
|
||||
@@ -57,7 +57,7 @@ function splitKeyParams(paramStr) {
|
||||
} else if (symbol === '"' && !quoted) {
|
||||
quoted = true;
|
||||
} else if (symbol === '[' && !quoted) {
|
||||
in_array = true;
|
||||
in_array = true;
|
||||
} else if (symbol === ']' && !quoted) {
|
||||
in_array = false;
|
||||
} else if (symbol === split_symbol && !quoted && !in_array) {
|
||||
@@ -218,7 +218,7 @@ export function getRangeScopedVars(range) {
|
||||
__range_ms: { text: msRange, value: msRange },
|
||||
__range_s: { text: sRange, value: sRange },
|
||||
__range: { text: regularRange, value: regularRange },
|
||||
__range_series: {text: c.RANGE_VARIABLE_VALUE, value: c.RANGE_VARIABLE_VALUE},
|
||||
__range_series: { text: c.RANGE_VARIABLE_VALUE, value: c.RANGE_VARIABLE_VALUE },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ export function escapeRegex(value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses Zabbix item update interval. Returns 0 in case of custom intervals.
|
||||
* Parses Zabbix item update interval (returns milliseconds). Returns 0 in case of custom intervals.
|
||||
*/
|
||||
export function parseItemInterval(interval: string): number {
|
||||
const normalizedInterval = normalizeZabbixInterval(interval);
|
||||
@@ -255,6 +255,7 @@ export function normalizeZabbixInterval(interval: string): string {
|
||||
return parsedInterval[1] + (parsedInterval.length > 2 ? parsedInterval[2] : 's');
|
||||
}
|
||||
|
||||
// Returns interval in milliseconds
|
||||
export function parseInterval(interval: string): number {
|
||||
const intervalPattern = /(^[\d]+)(y|M|w|d|h|m|s)/g;
|
||||
const momentInterval: any[] = intervalPattern.exec(interval);
|
||||
@@ -315,7 +316,7 @@ export function convertToZabbixAPIUrl(url) {
|
||||
* when waiting for result.
|
||||
*/
|
||||
export function callOnce(func, promiseKeeper) {
|
||||
return function() {
|
||||
return function () {
|
||||
if (!promiseKeeper) {
|
||||
promiseKeeper = Promise.resolve(
|
||||
func.apply(this, arguments)
|
||||
@@ -337,7 +338,7 @@ export function callOnce(func, promiseKeeper) {
|
||||
* @param {*} funcsArray functions to apply
|
||||
*/
|
||||
export function sequence(funcsArray) {
|
||||
return function(result) {
|
||||
return function (result) {
|
||||
for (let i = 0; i < funcsArray.length; i++) {
|
||||
result = funcsArray[i].call(this, result);
|
||||
}
|
||||
@@ -399,7 +400,7 @@ export function parseTags(tagStr: string): any[] {
|
||||
let tags: any[] = _.map(tagStr.split(','), (tag) => tag.trim());
|
||||
tags = _.map(tags, (tag) => {
|
||||
const tagParts = tag.split(':');
|
||||
return {tag: tagParts[0].trim(), value: tagParts[1].trim()};
|
||||
return { tag: tagParts[0].trim(), value: tagParts[1].trim() };
|
||||
});
|
||||
return tags;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user