using refId from panel model

This commit is contained in:
Peter Holmberg
2019-03-14 17:20:33 +01:00
parent 5f059038c6
commit cf55d68894
5 changed files with 36 additions and 32 deletions

View File

@@ -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) }];
}
/**