getQueryOptions.ts 705 B

123456789101112131415161718192021222324252627
  1. import { DataQueryRequest, DataQuery } from '@grafana/ui';
  2. import { dateTime } from '@grafana/ui/src/utils/moment_wrapper';
  3. export function getQueryOptions<TQuery extends DataQuery>(
  4. options: Partial<DataQueryRequest<TQuery>>
  5. ): DataQueryRequest<TQuery> {
  6. const raw = { from: 'now', to: 'now-1h' };
  7. const range = { from: dateTime(), to: dateTime(), raw: raw };
  8. const defaults: DataQueryRequest<TQuery> = {
  9. requestId: 'TEST',
  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. }