mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
Variables: Fixes error with: cannot read property length of undefined (#31458)
* Variables: Fixes error with: cannot read property length of undefined * A different fix
This commit is contained in:
parent
aeabaee2da
commit
e9d2592481
@ -9,6 +9,7 @@ import { DataSourceApi, FieldType, getFieldDisplayName, isDataFrame, MetricFindV
|
|||||||
import { updateVariableOptions, updateVariableTags } from './reducer';
|
import { updateVariableOptions, updateVariableTags } from './reducer';
|
||||||
import { getTimeSrv, TimeSrv } from '../../dashboard/services/TimeSrv';
|
import { getTimeSrv, TimeSrv } from '../../dashboard/services/TimeSrv';
|
||||||
import { getLegacyQueryOptions, getTemplatedRegex } from '../utils';
|
import { getLegacyQueryOptions, getTemplatedRegex } from '../utils';
|
||||||
|
import { getProcessedDataFrames } from 'app/features/query/state/runRequest';
|
||||||
|
|
||||||
export function toMetricFindValues(): OperatorFunction<PanelData, MetricFindValue[]> {
|
export function toMetricFindValues(): OperatorFunction<PanelData, MetricFindValue[]> {
|
||||||
return (source) =>
|
return (source) =>
|
||||||
@ -23,6 +24,7 @@ export function toMetricFindValues(): OperatorFunction<PanelData, MetricFindValu
|
|||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const processedDataFrames = getProcessedDataFrames(frames);
|
||||||
const metrics: MetricFindValue[] = [];
|
const metrics: MetricFindValue[] = [];
|
||||||
|
|
||||||
let valueIndex = -1;
|
let valueIndex = -1;
|
||||||
@ -30,7 +32,7 @@ export function toMetricFindValues(): OperatorFunction<PanelData, MetricFindValu
|
|||||||
let stringIndex = -1;
|
let stringIndex = -1;
|
||||||
let expandableIndex = -1;
|
let expandableIndex = -1;
|
||||||
|
|
||||||
for (const frame of frames) {
|
for (const frame of processedDataFrames) {
|
||||||
for (let index = 0; index < frame.fields.length; index++) {
|
for (let index = 0; index < frame.fields.length; index++) {
|
||||||
const field = frame.fields[index];
|
const field = frame.fields[index];
|
||||||
const fieldName = getFieldDisplayName(field, frame, frames).toLowerCase();
|
const fieldName = getFieldDisplayName(field, frame, frames).toLowerCase();
|
||||||
@ -181,6 +183,7 @@ export function areMetricFindValues(data: any[]): data is MetricFindValue[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const firstValue: any = data[0];
|
const firstValue: any = data[0];
|
||||||
|
|
||||||
if (isDataFrame(firstValue)) {
|
if (isDataFrame(firstValue)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user