) => {\n const { onChange, query, onRunQuery } = this.props;\n onChange({ ...query, path: sel?.value });\n onRunQuery();\n };\n\n renderListPublicFiles() {\n let { path } = this.props.query;\n let { folders } = this.state;\n if (!folders) {\n folders = [];\n this.loadFolderInfo();\n }\n const currentFolder = folders.find((f) => f.value === path);\n if (path && !currentFolder) {\n folders = [\n ...folders,\n {\n value: path,\n label: path,\n },\n ];\n }\n\n return (\n \n \n \n \n );\n }\n\n // Skip rendering the file list as we're handling that in this component instead.\n fileListRenderer = (file: DropzoneFile, removeFile: (file: DropzoneFile) => void) => {\n return null;\n };\n\n onFileDrop = (acceptedFiles: File[], fileRejections: FileRejection[], event: DropEvent) => {\n DFImport.filesToDataframes(acceptedFiles).subscribe((next) => {\n const snapshot: DataFrameJSON[] = [];\n next.dataFrames.forEach((df) => {\n const dataframeJson = dataFrameToJSON(df);\n snapshot.push(dataframeJson);\n });\n this.props.onChange({\n ...this.props.query,\n file: { name: next.file.name, size: next.file.size },\n queryType: GrafanaQueryType.Snapshot,\n snapshot,\n });\n this.props.onRunQuery();\n\n reportInteraction('grafana_datasource_drop_files', {\n number_of_files: fileRejections.length + acceptedFiles.length,\n accepted_files: acceptedFiles.map((a) => {\n return { type: a.type, size: a.size };\n }),\n rejected_files: fileRejections.map((r) => {\n return { type: r.file.type, size: r.file.size };\n }),\n });\n });\n };\n\n renderSnapshotQuery() {\n const { query, theme } = this.props;\n const file = query.file;\n const styles = getStyles(theme);\n const fileSize = getValueFormat('decbytes')(file ? file.size : 0);\n\n return (\n <>\n \n \n {pluralize('frame', query.snapshot?.length ?? 0, true)}\n \n \n {config.featureToggles.editPanelCSVDragAndDrop && (\n <>\n \n \n \n {file && (\n \n {file?.name}\n \n {formattedValueToString(fileSize)}\n \n
\n )}\n >\n )}\n >\n );\n }\n\n onSearchChange = (search: SearchQuery) => {\n const { query, onChange, onRunQuery } = this.props;\n\n onChange({\n ...query,\n search,\n });\n onRunQuery();\n };\n\n render() {\n const query = {\n ...defaultQuery,\n ...this.props.query,\n };\n\n const { queryType } = query;\n\n // Only show \"snapshot\" when it already exists\n let queryTypes = this.queryTypes;\n if (queryType === GrafanaQueryType.Snapshot && !config.featureToggles.editPanelCSVDragAndDrop) {\n queryTypes = [\n ...this.queryTypes,\n {\n label: 'Snapshot',\n value: queryType,\n },\n ];\n }\n\n return (\n <>\n {queryType === GrafanaQueryType.Search && (\n \n Using this datasource to call the new search system is experimental, and subject to change at any time\n without notice.\n \n )}\n \n \n \n \n {queryType === GrafanaQueryType.LiveMeasurements && this.renderMeasurementsQuery()}\n {queryType === GrafanaQueryType.List && this.renderListPublicFiles()}\n {queryType === GrafanaQueryType.Snapshot && this.renderSnapshotQuery()}\n {queryType === GrafanaQueryType.Search && (\n \n )}\n >\n );\n }\n}\n\nexport const QueryEditor = withTheme2(UnthemedQueryEditor);\n\nfunction getStyles(theme: GrafanaTheme2) {\n return {\n file: css`\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n padding: ${theme.spacing(2)};\n border: 1px dashed ${theme.colors.border.medium};\n background-color: ${theme.colors.background.secondary};\n margin-top: ${theme.spacing(1)};\n `,\n };\n}\n","import { DataSourcePlugin } from '@grafana/data';\n\nimport { QueryEditor } from './components/QueryEditor';\nimport { GrafanaDatasource } from './datasource';\nimport { GrafanaQuery } from './types';\n\nexport const plugin = new DataSourcePlugin(GrafanaDatasource).setQueryEditor(\n QueryEditor\n);\n"],"names":["SearchEditor","value","onChange","json","setJSON","query","setQuery","handleSearchBlur","handleSearchEnterKey","e","onSaveSearchJSON","rawSearchJSON","searchQuery","ex","InlineFieldRow","InlineField","Input","CodeEditor","labelWidth","UnthemedQueryEditor","props","sel","onRunQuery","item","fields","v","tf","f","key","txt","buffer","err","file","removeFile","acceptedFiles","fileRejections","event","next","snapshot","df","dataframeJson","a","r","search","config","channelInfo","channelFields","channels","c","distinctFields","frame","n","ds","rsp","folders","channel","filter","currentChannel","formattedTime","Select","input","Stack","Alert","path","currentFolder","theme","styles","getStyles","fileSize","InlineLabel","FileDropzone","queryType","queryTypes","QueryEditor"],"sourceRoot":""}