mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
more typings work around data query and data source
This commit is contained in:
25
public/test/helpers/getQueryOptions.ts
Normal file
25
public/test/helpers/getQueryOptions.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { DataQueryOptions, DataQuery } from '@grafana/ui';
|
||||
import moment from 'moment';
|
||||
|
||||
|
||||
export function getQueryOptions<TQuery extends DataQuery>(options: Partial<DataQueryOptions<TQuery>>): DataQueryOptions<TQuery> {
|
||||
const raw = {from: 'now', to: 'now-1h'};
|
||||
const range = { from: moment(), to: moment(), raw: raw};
|
||||
|
||||
const defaults: DataQueryOptions<TQuery> = {
|
||||
range: range,
|
||||
rangeRaw: raw,
|
||||
targets: [],
|
||||
scopedVars: {},
|
||||
timezone: 'browser',
|
||||
panelId: 1,
|
||||
dashboardId: 1,
|
||||
interval: '60s',
|
||||
intervalMs: 60000,
|
||||
maxDataPoints: 500,
|
||||
};
|
||||
|
||||
Object.assign(defaults, options);
|
||||
|
||||
return defaults;
|
||||
}
|
||||
Reference in New Issue
Block a user