mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
using refId from panel model
This commit is contained in:
@@ -23,6 +23,7 @@ import {
|
||||
ResultGetter,
|
||||
} from 'app/types/explore';
|
||||
import { LogsDedupStrategy } from 'app/core/logs_model';
|
||||
import { getNextQueryLetter } from './query';
|
||||
|
||||
export const DEFAULT_RANGE = {
|
||||
from: 'now-6h',
|
||||
@@ -225,12 +226,8 @@ export function generateKey(index = 0): string {
|
||||
return `Q-${Date.now()}-${Math.random()}-${index}`;
|
||||
}
|
||||
|
||||
export function generateRefId(index = 0): string {
|
||||
return `${index + 1}`;
|
||||
}
|
||||
|
||||
export function generateEmptyQuery(index = 0): { refId: string; key: string } {
|
||||
return { refId: generateRefId(index), key: generateKey(index) };
|
||||
export function generateEmptyQuery(queries: DataQuery[], index = 0): { refId: string; key: string } {
|
||||
return { refId: getNextQueryLetter(queries), key: generateKey(index) };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -238,9 +235,9 @@ export function generateEmptyQuery(index = 0): { refId: string; key: string } {
|
||||
*/
|
||||
export function ensureQueries(queries?: DataQuery[]): DataQuery[] {
|
||||
if (queries && typeof queries === 'object' && queries.length > 0) {
|
||||
return queries.map((query, i) => ({ ...query, ...generateEmptyQuery(i) }));
|
||||
return queries.map((query, i) => ({ ...query, ...generateEmptyQuery(queries, i) }));
|
||||
}
|
||||
return [{ ...generateEmptyQuery() }];
|
||||
return [{ ...generateEmptyQuery(queries) }];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user