-
Notifications
You must be signed in to change notification settings - Fork 8.6k
rename advanced setting ml:fileDataVisualizerMaxFileSize to fileUpload:maxFileSize and increase max geojson upload size to 1GB #92620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a102bab
rename ml:fileDataVisualizerMaxFileSize to fileUppload:maxFileSize
nreese bf4bf6a
add saved object migration
nreese 1db54f7
file preview
nreese eb63959
importing status
nreese 1665c45
remove console statement
nreese aca5463
import complete view
nreese 1889840
fix geojson_importer test
nreese 21c38f2
tslint
nreese e7f6866
i18n fixes
nreese 07ff940
cleanup
nreese 1818acf
Merge branch 'master' into file_upload_max_size
kibanamachine ed7a0fa
update documenation for advanced setting rename
nreese 295ef6c
advanced settings usage_collection
nreese 494f5ac
Merge branch 'master' into file_upload_max_size
kibanamachine 5035cc1
remove ml:fileDataVisualizerMaxFileSize from schemas and types
nreese c18846c
Merge branch 'file_upload_max_size' of github.com:nreese/kibana into …
nreese a15ca72
add copy buttons for import response and fix geojson upload functiona…
nreese 61b9203
Merge branch 'master' into file_upload_max_size
kibanamachine b2e03fb
tslint
nreese f48dc87
remove clipboard-read check
nreese be10ff7
return early if env does not support reading from clipboard
nreese 88c3a4a
Merge branch 'master' into file_upload_max_size
kibanamachine cd56eda
fix reporting tests
nreese 600bea2
review feedback
nreese 56957f4
update GeoJsonFileSource to support showing results trimmed icon and …
nreese a1cbbfb
add fileUpload to useMlKibana context and replace dependencyCache wit…
nreese 7f4ce1c
tslint
nreese ef47a78
merge with master
nreese 812b511
review feedback
nreese e80285a
lower case file name
nreese eedb74e
default to selecting geo_shape when file contains both points and shapes
nreese 5968394
fix wizard onError callback to not advance to next step
nreese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
155 changes: 155 additions & 0 deletions
155
x-pack/plugins/file_upload/public/components/geojson_file_picker.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import React, { Component } from 'react'; | ||
| import { EuiFilePicker, EuiFormRow } from '@elastic/eui'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { MB } from '../../common'; | ||
| import { getMaxBytesFormatted } from '../get_max_bytes'; | ||
| import { validateFile } from '../importer'; | ||
| import { GeoJsonImporter, GeoJsonPreview, GEOJSON_FILE_TYPES } from '../importer/geojson_importer'; | ||
|
|
||
| interface Props { | ||
| onSelect: ({ | ||
| features, | ||
| hasPoints, | ||
| hasShapes, | ||
| importer, | ||
| indexName, | ||
| previewCoverage, | ||
| }: GeoJsonPreview & { | ||
| indexName: string; | ||
| importer: GeoJsonImporter; | ||
| }) => void; | ||
| onClear: () => void; | ||
| } | ||
|
|
||
| interface State { | ||
| error: string | null; | ||
| isLoadingPreview: boolean; | ||
| previewSummary: string | null; | ||
| } | ||
|
|
||
| export class GeoJsonFilePicker extends Component<Props, State> { | ||
| private _isMounted = false; | ||
|
|
||
| state: State = { | ||
| error: null, | ||
| isLoadingPreview: false, | ||
| previewSummary: null, | ||
| }; | ||
|
|
||
| async componentDidMount() { | ||
| this._isMounted = true; | ||
| } | ||
|
|
||
| componentWillUnmount() { | ||
| this._isMounted = false; | ||
| } | ||
|
|
||
| _onFileSelect = (files: FileList | null) => { | ||
| this.props.onClear(); | ||
|
|
||
| this.setState({ | ||
| error: null, | ||
| isLoadingPreview: false, | ||
| previewSummary: null, | ||
| }); | ||
|
|
||
| if (files && files.length) { | ||
| this._loadFilePreview(files[0]); | ||
| } | ||
| }; | ||
|
|
||
| async _loadFilePreview(file: File) { | ||
| this.setState({ isLoadingPreview: true }); | ||
|
|
||
| let importer: GeoJsonImporter | null = null; | ||
| let previewError: string | null = null; | ||
| let preview: GeoJsonPreview | null = null; | ||
| try { | ||
| validateFile(file, GEOJSON_FILE_TYPES); | ||
| importer = new GeoJsonImporter(file); | ||
| preview = await importer.previewFile(10000, MB * 3); | ||
| if (preview.features.length === 0) { | ||
| previewError = i18n.translate('xpack.fileUpload.geojsonFilePicker.noFeaturesDetected', { | ||
| defaultMessage: 'No GeoJson features found in selected file.', | ||
| }); | ||
| } | ||
| } catch (error) { | ||
| previewError = error.message; | ||
| } | ||
|
|
||
| if (!this._isMounted) { | ||
| return; | ||
| } | ||
|
|
||
| this.setState({ | ||
| error: previewError, | ||
| isLoadingPreview: false, | ||
| previewSummary: | ||
| !previewError && preview | ||
| ? i18n.translate('xpack.fileUpload.geojsonFilePicker.previewSummary', { | ||
| defaultMessage: 'Previewing {numFeatures} features, {previewCoverage}% of file.', | ||
| values: { | ||
| numFeatures: preview.features.length, | ||
| previewCoverage: preview.previewCoverage, | ||
| }, | ||
| }) | ||
| : null, | ||
| }); | ||
|
|
||
| if (importer && preview) { | ||
| this.props.onSelect({ | ||
| ...preview, | ||
| importer, | ||
| indexName: file.name.split('.')[0].toLowerCase(), | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| _renderHelpText() { | ||
| return this.state.previewSummary !== null ? ( | ||
| this.state.previewSummary | ||
| ) : ( | ||
| <span> | ||
| {i18n.translate('xpack.fileUpload.geojsonFilePicker.acceptedFormats', { | ||
| defaultMessage: 'Formats accepted: {fileTypes}', | ||
| values: { fileTypes: GEOJSON_FILE_TYPES.join(', ') }, | ||
| })} | ||
| <br /> | ||
| {i18n.translate('xpack.fileUpload.geojsonFilePicker.maxSize', { | ||
| defaultMessage: 'Max size: {maxFileSize}', | ||
| values: { maxFileSize: getMaxBytesFormatted() }, | ||
| })} | ||
| <br /> | ||
| {i18n.translate('xpack.fileUpload.geojsonFilePicker.acceptedCoordinateSystem', { | ||
| defaultMessage: 'Coordinates must be in EPSG:4326 coordinate reference system.', | ||
| })} | ||
| </span> | ||
| ); | ||
| } | ||
|
|
||
| render() { | ||
| return ( | ||
| <EuiFormRow | ||
| isInvalid={!!this.state.error} | ||
| error={!!this.state.error ? [this.state.error] : []} | ||
| helpText={this._renderHelpText()} | ||
| > | ||
| <EuiFilePicker | ||
| initialPromptText={i18n.translate('xpack.fileUpload.geojsonFilePicker.filePicker', { | ||
| defaultMessage: 'Select or drag and drop a file', | ||
| })} | ||
| onChange={this._onFileSelect} | ||
| accept={GEOJSON_FILE_TYPES.join(',')} | ||
| isLoading={this.state.isLoadingPreview} | ||
| /> | ||
| </EuiFormRow> | ||
| ); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.