2019-01-18 11:59:32 -06:00
|
|
|
import { DataQueryOptions, DataQuery } from '@grafana/ui';
|
|
|
|
import moment from 'moment';
|
|
|
|
|
2019-02-13 04:39:41 -06:00
|
|
|
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 };
|
2019-01-18 11:59:32 -06:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|