getQueryOptions.ts 689 B

123456789101112131415161718192021222324252627
  1. import { DataQueryRequest, DataQuery, CoreApp, dateTime } from '@grafana/data';
  2. export function getQueryOptions<TQuery extends DataQuery>(
  3. options: Partial<DataQueryRequest<TQuery>>
  4. ): DataQueryRequest<TQuery> {
  5. const raw = { from: 'now', to: 'now-1h' };
  6. const range = { from: dateTime(), to: dateTime(), raw: raw };
  7. const defaults: DataQueryRequest<TQuery> = {
  8. requestId: 'TEST',
  9. app: CoreApp.Dashboard,
  10. range: range,
  11. targets: [],
  12. scopedVars: {},
  13. timezone: 'browser',
  14. panelId: 1,
  15. dashboardId: 1,
  16. interval: '60s',
  17. intervalMs: 60000,
  18. maxDataPoints: 500,
  19. startTime: 0,
  20. };
  21. Object.assign(defaults, options);
  22. return defaults;
  23. }