mirror of
https://github.com/grafana/grafana.git
synced 2024-11-30 12:44:10 -06:00
Further refinements of typings
This commit is contained in:
parent
5d17ad1103
commit
5ab9a7c2b8
@ -3,11 +3,6 @@ import { PanelProps, PanelOptionsProps } from './panel';
|
||||
import { DataQueryOptions, DataQuery, DataQueryResponse, QueryHint } from './datasource';
|
||||
|
||||
export interface DataSourceApi<TQuery extends DataQuery = DataQuery> {
|
||||
// set externally by grafana
|
||||
name?: string;
|
||||
meta?: PluginMeta;
|
||||
pluginExports?: PluginExports;
|
||||
|
||||
/**
|
||||
* min interval range
|
||||
*/
|
||||
@ -37,19 +32,26 @@ export interface DataSourceApi<TQuery extends DataQuery = DataQuery> {
|
||||
* Get hints for query improvements
|
||||
*/
|
||||
getQueryHints?(query: TQuery, results: any[], ...rest: any): QueryHint[];
|
||||
|
||||
/**
|
||||
* Set after constructor is called by Grafana
|
||||
*/
|
||||
name?: string;
|
||||
meta?: PluginMeta;
|
||||
pluginExports?: PluginExports;
|
||||
}
|
||||
|
||||
export interface QueryEditorProps<DSType extends DataSourceApi = DataSourceApi, TQuery extends DataQuery = DataQuery> {
|
||||
export interface QueryEditorProps<DSType extends DataSourceApi, TQuery extends DataQuery> {
|
||||
datasource: DSType;
|
||||
query: TQuery;
|
||||
onExecuteQuery?: () => void;
|
||||
onQueryChange?: (value: DataQuery) => void;
|
||||
onQueryChange?: (value: TQuery) => void;
|
||||
}
|
||||
|
||||
export interface PluginExports {
|
||||
Datasource?: any;
|
||||
Datasource?: DataSourceApi;
|
||||
QueryCtrl?: any;
|
||||
QueryEditor?: ComponentClass<QueryEditorProps>;
|
||||
QueryEditor?: ComponentClass<QueryEditorProps<DataSourceApi,DataQuery>>;
|
||||
ConfigCtrl?: any;
|
||||
AnnotationsQueryCtrl?: any;
|
||||
VariableQueryEditor?: any;
|
||||
|
@ -29,11 +29,12 @@ export class QueryEditor extends PureComponent<Props> {
|
||||
};
|
||||
|
||||
async componentDidMount() {
|
||||
const { query } = this.props;
|
||||
const { query, datasource } = this.props;
|
||||
|
||||
query.scenarioId = query.scenarioId || 'random_walk';
|
||||
|
||||
const scenarioList = await this.backendSrv.get('/api/tsdb/testdata/scenarios');
|
||||
// const scenarioList = await this.backendSrv.get('/api/tsdb/testdata/scenarios');
|
||||
const scenarioList = await datasource.getScenarios();
|
||||
const current = _.find(scenarioList, { id: query.scenarioId });
|
||||
|
||||
this.setState({ scenarioList: scenarioList, current: current });
|
||||
|
@ -1,7 +1,7 @@
|
||||
import _ from 'lodash';
|
||||
import TableModel from 'app/core/table_model';
|
||||
import { DataSourceApi, DataQueryOptions } from '@grafana/ui';
|
||||
import { TestDataQuery } from './types';
|
||||
import { TestDataQuery, Scenario } from './types';
|
||||
|
||||
export class TestDataDatasource implements DataSourceApi<TestDataQuery> {
|
||||
id: number;
|
||||
@ -93,5 +93,9 @@ export class TestDataDatasource implements DataSourceApi<TestDataQuery> {
|
||||
message: 'Data source is working',
|
||||
});
|
||||
}
|
||||
|
||||
getScenarios(): Promise<Scenario[]> {
|
||||
return this.backendSrv.get('/api/tsdb/testdata/scenarios');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { TestDataDatasource } from './datasource';
|
||||
// import { TestDataQueryCtrl } from './query_ctrl';
|
||||
import { QueryEditor } from './QueryEditor';
|
||||
import { TestDataQueryCtrl } from './query_ctrl';
|
||||
// import { QueryEditor } from './QueryEditor';
|
||||
|
||||
class TestDataAnnotationsQueryCtrl {
|
||||
annotation: any;
|
||||
@ -11,8 +11,8 @@ class TestDataAnnotationsQueryCtrl {
|
||||
}
|
||||
|
||||
export {
|
||||
QueryEditor,
|
||||
// QueryEditor,
|
||||
TestDataDatasource as Datasource,
|
||||
// TestDataQueryCtrl as QueryCtrl,
|
||||
TestDataQueryCtrl as QueryCtrl,
|
||||
TestDataAnnotationsQueryCtrl as AnnotationsQueryCtrl,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user