2021-05-26 10:42:42 +02:00
|
|
|
import React from 'react';
|
2022-04-22 14:33:13 +01:00
|
|
|
|
2021-05-26 10:42:42 +02:00
|
|
|
import { SelectableValue } from '@grafana/data';
|
2022-04-22 14:33:13 +01:00
|
|
|
import { InlineField, InlineFieldRow, Select } from '@grafana/ui';
|
|
|
|
|
|
2021-05-26 10:42:42 +02:00
|
|
|
import { EditorProps } from '../QueryEditor';
|
|
|
|
|
|
|
|
|
|
export const CSVFileEditor = ({ onChange, query }: EditorProps) => {
|
|
|
|
|
const onChangeFileName = ({ value }: SelectableValue<string>) => {
|
|
|
|
|
onChange({ ...query, csvFileName: value });
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-26 14:11:57 +02:00
|
|
|
const files = [
|
2021-07-12 20:47:39 -07:00
|
|
|
'flight_info_by_state.csv',
|
2021-05-26 14:11:57 +02:00
|
|
|
'population_by_state.csv',
|
|
|
|
|
'gdp_per_capita.csv',
|
|
|
|
|
'js_libraries.csv',
|
2021-11-05 20:01:26 -05:00
|
|
|
'ohlc_dogecoin.csv',
|
2021-05-27 17:27:29 +02:00
|
|
|
'weight_height.csv',
|
2021-05-26 14:11:57 +02:00
|
|
|
'browser_marketshare.csv',
|
2023-11-29 11:54:16 -06:00
|
|
|
'automobiles.csv',
|
2021-05-26 14:11:57 +02:00
|
|
|
].map((name) => ({ label: name, value: name }));
|
2021-05-26 10:42:42 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<InlineFieldRow>
|
|
|
|
|
<InlineField label="File" labelWidth={14}>
|
|
|
|
|
<Select
|
|
|
|
|
width={32}
|
|
|
|
|
onChange={onChangeFileName}
|
|
|
|
|
placeholder="Select csv file"
|
|
|
|
|
options={files}
|
|
|
|
|
value={files.find((f) => f.value === query.csvFileName)}
|
|
|
|
|
/>
|
|
|
|
|
</InlineField>
|
|
|
|
|
</InlineFieldRow>
|
|
|
|
|
);
|
|
|
|
|
};
|