mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Primarily- moving majority of the types and utils from @grafana/ui to @grafana/data * Move types from grafana-ui to grafana-data * Move valueFormats to grafana-data * Move utils from grafana-ui to grafana-data * Update imports in grafana-ui * revert data's tsconfig change * Update imports in grafana-runtime * Fix import paths in grafana-ui * Move rxjs to devDeps * Core import updates batch 1 * Import updates batch 2 * Imports fix batch 3 * Imports fixes batch i don't know * Fix imorts in grafana-toolkit * Fix imports after master merge
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import React, { useEffect } from 'react';
|
|
import { DataSourceHttpSettings } from '@grafana/ui';
|
|
import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
|
|
import { ElasticsearchOptions } from '../types';
|
|
import { defaultMaxConcurrentShardRequests, ElasticDetails } from './ElasticDetails';
|
|
import { LogsConfig } from './LogsConfig';
|
|
|
|
export type Props = DataSourcePluginOptionsEditorProps<ElasticsearchOptions>;
|
|
export const ConfigEditor = (props: Props) => {
|
|
const { options, onOptionsChange } = props;
|
|
|
|
// Apply some defaults on initial render
|
|
useEffect(() => {
|
|
const esVersion = options.jsonData.esVersion || 5;
|
|
onOptionsChange({
|
|
...options,
|
|
jsonData: {
|
|
...options.jsonData,
|
|
timeField: options.jsonData.timeField || '@timestamp',
|
|
esVersion,
|
|
maxConcurrentShardRequests:
|
|
options.jsonData.maxConcurrentShardRequests || defaultMaxConcurrentShardRequests(esVersion),
|
|
logMessageField: options.jsonData.logMessageField || '',
|
|
logLevelField: options.jsonData.logLevelField || '',
|
|
},
|
|
});
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<DataSourceHttpSettings
|
|
defaultUrl={'http://localhost:3100'}
|
|
dataSourceConfig={options}
|
|
showAccessOptions={true}
|
|
onChange={onOptionsChange}
|
|
/>
|
|
|
|
<ElasticDetails value={options} onChange={onOptionsChange} />
|
|
|
|
<LogsConfig
|
|
value={options.jsonData}
|
|
onChange={newValue =>
|
|
onOptionsChange({
|
|
...options,
|
|
jsonData: newValue,
|
|
})
|
|
}
|
|
/>
|
|
</>
|
|
);
|
|
};
|