diff --git a/public/app/plugins/datasource/grafana/annotation_ctrl.ts b/public/app/plugins/datasource/grafana/annotation_ctrl.ts new file mode 100644 index 00000000000..8876ddfb660 --- /dev/null +++ b/public/app/plugins/datasource/grafana/annotation_ctrl.ts @@ -0,0 +1,20 @@ +import { SelectableValue } from '@grafana/data'; +import { GrafanaAnnotationType } from './types'; + +export const annotationTypes: Array> = [ + { text: 'Dashboard', value: GrafanaAnnotationType.Dashboard }, + { text: 'Tags', value: GrafanaAnnotationType.Tags }, +]; + +export class GrafanaAnnotationsQueryCtrl { + annotation: any; + + types = annotationTypes; + + constructor() { + this.annotation.type = this.annotation.type || GrafanaAnnotationType.Tags; + this.annotation.limit = this.annotation.limit || 100; + } + + static templateUrl = 'partials/annotations.editor.html'; +} diff --git a/public/app/plugins/datasource/grafana/components/QueryEditor.tsx b/public/app/plugins/datasource/grafana/components/QueryEditor.tsx new file mode 100644 index 00000000000..6393b5038ad --- /dev/null +++ b/public/app/plugins/datasource/grafana/components/QueryEditor.tsx @@ -0,0 +1,40 @@ +import defaults from 'lodash/defaults'; + +import React, { PureComponent } from 'react'; +import { InlineField, Select } from '@grafana/ui'; +import { QueryEditorProps, SelectableValue } from '@grafana/data'; +import { GrafanaDatasource } from '../datasource'; +import { defaultQuery, GrafanaQuery, GrafanaQueryType } from '../types'; + +type Props = QueryEditorProps; + +export class QueryEditor extends PureComponent { + queryTypes: Array> = [ + { + label: 'Random Walk', + value: GrafanaQueryType.RandomWalk, + description: 'Random signal within the selected time rage', + }, + ]; + + onQueryTypeChange = (sel: SelectableValue) => { + const { onChange, query, onRunQuery } = this.props; + onChange({ ...query, queryType: sel.value! }); + onRunQuery(); + }; + + render() { + const query = defaults(this.props.query, defaultQuery); + return ( +
+ +