|
1 |
| -import React from 'react'; |
2 |
| -import { DataSourceHttpSettings } from '@grafana/ui'; |
| 1 | +import React, { ChangeEvent } from 'react'; |
| 2 | +import { InlineFormLabel, Field, Input, Legend } from '@grafana/ui'; |
3 | 3 | import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
|
4 | 4 | import { JsonApiDataSourceOptions } from './types';
|
5 |
| -import { ConfigSettings } from './ConfigSettings'; |
| 5 | +import {} from '@emotion/core'; |
6 | 6 |
|
7 | 7 | interface Props extends DataSourcePluginOptionsEditorProps<JsonApiDataSourceOptions> {}
|
8 | 8 |
|
9 | 9 | export const ConfigEditor: React.FC<Props> = ({ options, onOptionsChange }) => {
|
| 10 | + const onUrlChange = (e: ChangeEvent<HTMLInputElement>) => { |
| 11 | + onOptionsChange({ ...options, jsonData: { ...options, url: e.currentTarget.value } }); |
| 12 | + }; |
| 13 | + const onParamsChange = (e: ChangeEvent<HTMLInputElement>) => { |
| 14 | + onOptionsChange({ ...options, jsonData: { ...options.jsonData, queryParams: e.currentTarget.value } }); |
| 15 | + }; |
10 | 16 | return (
|
11 | 17 | <>
|
12 |
| - <DataSourceHttpSettings |
13 |
| - defaultUrl="http://localhost:8080" |
14 |
| - dataSourceConfig={options} |
15 |
| - onChange={onOptionsChange} |
16 |
| - /> |
17 |
| - |
18 |
| - <ConfigSettings options={options} onOptionsChange={onOptionsChange} /> |
| 18 | + <Legend>HTTP</Legend> |
| 19 | + <div className="gf-form-group"> |
| 20 | + <div className="gf-form"> |
| 21 | + <InlineFormLabel tooltip={<p>URL to an endpoint that returns a JSON response.</p>}>URL</InlineFormLabel> |
| 22 | + <Input className="width-25" value={options.url} onChange={onUrlChange} placeholder="page=1&limit=100" /> |
| 23 | + </div> |
| 24 | + <div className="gf-form"> |
| 25 | + <InlineFormLabel tooltip={<p>Add custom query parameters to your query.</p>}> |
| 26 | + Query parameters |
| 27 | + </InlineFormLabel> |
| 28 | + <Input |
| 29 | + className="width-25" |
| 30 | + value={options.jsonData.queryParams} |
| 31 | + onChange={onParamsChange} |
| 32 | + placeholder="page=1&limit=100" |
| 33 | + /> |
| 34 | + </div> |
| 35 | + </div> |
19 | 36 | </>
|
20 | 37 | );
|
21 | 38 | };
|
0 commit comments