GrafanaLiveEditor.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import React from 'react';
  2. import { SelectableValue } from '@grafana/data';
  3. import { InlineField, InlineFieldRow, Select } from '@grafana/ui';
  4. import { EditorProps } from '../QueryEditor';
  5. const liveTestDataChannels = [
  6. {
  7. label: 'random-2s-stream',
  8. value: 'random-2s-stream',
  9. description: 'Random stream with points every 2s',
  10. },
  11. {
  12. label: 'random-flakey-stream',
  13. value: 'random-flakey-stream',
  14. description: 'Stream that returns data in random intervals',
  15. },
  16. {
  17. label: 'random-labeled-stream',
  18. value: 'random-labeled-stream',
  19. description: 'Value with moving labels',
  20. },
  21. {
  22. label: 'random-20Hz-stream',
  23. value: 'random-20Hz-stream',
  24. description: 'Random stream with points in 20Hz',
  25. },
  26. ];
  27. export const GrafanaLiveEditor = ({ onChange, query }: EditorProps) => {
  28. const onChannelChange = ({ value }: SelectableValue<string>) => {
  29. onChange({ ...query, channel: value });
  30. };
  31. return (
  32. <InlineFieldRow>
  33. <InlineField label="Channel" labelWidth={14}>
  34. <Select
  35. width={32}
  36. onChange={onChannelChange}
  37. placeholder="Select channel"
  38. options={liveTestDataChannels}
  39. value={liveTestDataChannels.find((f) => f.value === query.channel)}
  40. />
  41. </InlineField>
  42. </InlineFieldRow>
  43. );
  44. };