2021-02-11 06:45:25 -06:00
|
|
|
import { DataQueryRequest, DataQuery, CoreApp, dateTime } from '@grafana/data';
|
2019-01-18 11:59:32 -06:00
|
|
|
|
2019-02-13 04:39:41 -06:00
|
|
|
export function getQueryOptions<TQuery extends DataQuery>(
|
2019-04-18 23:56:27 -05:00
|
|
|
options: Partial<DataQueryRequest<TQuery>>
|
|
|
|
): DataQueryRequest<TQuery> {
|
2019-02-13 04:39:41 -06:00
|
|
|
const raw = { from: 'now', to: 'now-1h' };
|
2019-05-08 06:51:44 -05:00
|
|
|
const range = { from: dateTime(), to: dateTime(), raw: raw };
|
2019-01-18 11:59:32 -06:00
|
|
|
|
2019-04-18 23:56:27 -05:00
|
|
|
const defaults: DataQueryRequest<TQuery> = {
|
|
|
|
requestId: 'TEST',
|
2019-12-27 02:11:16 -06:00
|
|
|
app: CoreApp.Dashboard,
|
2019-01-18 11:59:32 -06:00
|
|
|
range: range,
|
|
|
|
targets: [],
|
|
|
|
scopedVars: {},
|
|
|
|
timezone: 'browser',
|
|
|
|
panelId: 1,
|
2023-04-14 18:50:10 -05:00
|
|
|
dashboardUID: 'test-uid-1',
|
2019-01-18 11:59:32 -06:00
|
|
|
interval: '60s',
|
|
|
|
intervalMs: 60000,
|
|
|
|
maxDataPoints: 500,
|
2019-04-18 23:56:27 -05:00
|
|
|
startTime: 0,
|
2019-01-18 11:59:32 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
Object.assign(defaults, options);
|
|
|
|
|
|
|
|
return defaults;
|
|
|
|
}
|