import { useState } from 'react'; import { QueryEditorProps } from '@grafana/data'; import { InlineFormLabel, Input, InlineSwitch } from '@grafana/ui'; import OpenTsDatasource from '../datasource'; import { OpenTsdbQuery, OpenTsdbOptions } from '../types'; export const AnnotationEditor = (props: QueryEditorProps) => { const { query, onChange } = props; const [target, setTarget] = useState(query.target ?? ''); const [isGlobal, setIsGlobal] = useState(query.isGlobal ?? false); const updateValue = (key: K, val: V) => { onChange({ ...query, [key]: val, fromAnnotations: true, }); }; const updateIsGlobal = (isGlobal: boolean) => { isGlobal = !isGlobal; setIsGlobal(isGlobal); updateValue('isGlobal', isGlobal); }; return (
OpenTSDB metrics query setTarget(e.currentTarget.value ?? '')} onBlur={() => updateValue('target', target)} placeholder="events.eventname" />
Show Global Annotations? updateIsGlobal(isGlobal)} />
); };