diff --git a/.i18nrc.json b/.i18nrc.json index 4e942485d3aab0..6527a06b3fb7bd 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -31,6 +31,7 @@ "xpack.infra": "x-pack/plugins/infra", "xpack.kueryAutocomplete": "x-pack/plugins/kuery_autocomplete", "xpack.licenseMgmt": "x-pack/plugins/license_management", + "xpack.maps": "x-pack/plugins/maps", "xpack.ml": "x-pack/plugins/ml", "xpack.logstash": "x-pack/plugins/logstash", "xpack.main": "x-pack/plugins/xpack_main", diff --git a/x-pack/plugins/maps/common/constants.js b/x-pack/plugins/maps/common/constants.js index 99cf0b173776e4..0af229569e5d12 100644 --- a/x-pack/plugins/maps/common/constants.js +++ b/x-pack/plugins/maps/common/constants.js @@ -16,4 +16,8 @@ export const ZOOM_PRECISION = 2; export const DEFAULT_EMS_TILE_LAYER = 'road_map'; +export const APP_ID = 'maps'; + +export const APP_ICON = 'gisApp'; + export const SOURCE_DATA_ID_ORIGIN = 'source'; diff --git a/x-pack/plugins/maps/common/i18n_getters.js b/x-pack/plugins/maps/common/i18n_getters.js new file mode 100644 index 00000000000000..0055c899e52c72 --- /dev/null +++ b/x-pack/plugins/maps/common/i18n_getters.js @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { i18n } from '@kbn/i18n'; + +export function getAppTitle() { + return i18n.translate('xpack.maps.appTitle', { + defaultMessage: 'Maps' + }); +} + + +export function getDataSourceLabel() { + return i18n.translate('xpack.maps.source.dataSourceLabel', { + defaultMessage: 'Data source' + }); +} + +export function getUrlLabel() { + return i18n.translate('xpack.maps.source.urlLabel', { + defaultMessage: 'Url' + }); +} diff --git a/x-pack/plugins/maps/index.js b/x-pack/plugins/maps/index.js index ba6a4fcfd4b45a..567e8c5e97deb0 100644 --- a/x-pack/plugins/maps/index.js +++ b/x-pack/plugins/maps/index.js @@ -6,30 +6,35 @@ import { resolve } from 'path'; import { initRoutes } from './server/routes'; -import ecommerceSavedObjects from './server/sample_data/ecommerce_saved_objects.json'; -import fligthsSavedObjects from './server/sample_data/flights_saved_objects.json'; -import webLogsSavedObjects from './server/sample_data/web_logs_saved_objects.json'; +import { getEcommerceSavedObjects } from './server/sample_data/ecommerce_saved_objects'; +import { getFlightsSavedObjects } from './server/sample_data/flights_saved_objects.js'; +import { getWebLogsSavedObjects } from './server/sample_data/web_logs_saved_objects.js'; import mappings from './mappings.json'; import { checkLicense } from './check_license'; import { migrations } from './migrations'; import { watchStatusAndLicenseToInitialize } from '../../server/lib/watch_status_and_license_to_initialize'; import { initTelemetryCollection } from './server/maps_telemetry'; +import { i18n } from '@kbn/i18n'; +import { APP_ID, APP_ICON } from './common/constants'; +import { getAppTitle } from './common/i18n_getters'; export function maps(kibana) { return new kibana.Plugin({ require: ['kibana', 'elasticsearch', 'xpack_main', 'tile_map', 'task_manager'], - id: 'maps', + id: APP_ID, configPrefix: 'xpack.maps', publicDir: resolve(__dirname, 'public'), uiExports: { app: { - title: 'Maps', - description: 'Map application', + title: getAppTitle(), + description: i18n.translate('xpack.maps.appDescription', { + defaultMessage: 'Map application' + }), main: 'plugins/maps/index', icon: 'plugins/maps/icon.svg', - euiIconType: 'gisApp', + euiIconType: APP_ICON, }, injectDefaultVars(server) { const serverConfig = server.config(); @@ -86,9 +91,9 @@ export function maps(kibana) { .feature(this.id) .registerLicenseCheckResultsGenerator(checkLicense); - server.addSavedObjectsToSampleDataset('ecommerce', ecommerceSavedObjects); - server.addSavedObjectsToSampleDataset('flights', fligthsSavedObjects); - server.addSavedObjectsToSampleDataset('logs', webLogsSavedObjects); + server.addSavedObjectsToSampleDataset('ecommerce', getEcommerceSavedObjects()); + server.addSavedObjectsToSampleDataset('flights', getFlightsSavedObjects()); + server.addSavedObjectsToSampleDataset('logs', getWebLogsSavedObjects()); server.injectUiAppVars('maps', async () => { return await server.getInjectedUiAppVars('kibana'); }); diff --git a/x-pack/plugins/maps/public/angular/map_controller.js b/x-pack/plugins/maps/public/angular/map_controller.js index 5c941cc987099b..c5a7f598ebcc40 100644 --- a/x-pack/plugins/maps/public/angular/map_controller.js +++ b/x-pack/plugins/maps/public/angular/map_controller.js @@ -6,7 +6,8 @@ import chrome from 'ui/chrome'; import React from 'react'; -import { I18nContext } from 'ui/i18n'; +import { I18nProvider } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; import { render, unmountComponentAtNode } from 'react-dom'; import { uiModules } from 'ui/modules'; import { timefilter } from 'ui/timefilter'; @@ -143,9 +144,9 @@ app.controller('GisMapController', ($scope, $route, config, kbnUrl, localStorage const root = document.getElementById(REACT_ANCHOR_DOM_ELEMENT_ID); render( - + - + , root ); @@ -201,7 +202,9 @@ app.controller('GisMapController', ($scope, $route, config, kbnUrl, localStorage // TODO subscribe to store change and change when store updates title chrome.breadcrumbs.set([ - { text: 'Maps', href: '#' }, + { text: i18n.translate('xpack.maps.mapController.mapsBreadcrumbLabel', { + defaultMessage: 'Maps' + }), href: '#' }, { text: $scope.map.title } ]); @@ -216,7 +219,10 @@ app.controller('GisMapController', ($scope, $route, config, kbnUrl, localStorage docTitle.change(savedMap.title); } catch(err) { toastNotifications.addDanger({ - title: `Error on saving '${savedMap.title}'`, + title: i18n.translate('xpack.maps.mapController.saveErrorMessage', { + defaultMessage: `Error on saving '{title}'`, + values: { title: savedMap.title } + }), text: err.message, 'data-test-subj': 'saveMapError', }); @@ -225,7 +231,10 @@ app.controller('GisMapController', ($scope, $route, config, kbnUrl, localStorage if (id) { toastNotifications.addSuccess({ - title: `Saved '${savedMap.title}'`, + title: i18n.translate('xpack.maps.mapController.saveSuccessMessage', { + defaultMessage: `Saved '{title}'`, + values: { title: savedMap.title } + }), 'data-test-subj': 'saveMapSuccess', }); @@ -243,23 +252,35 @@ app.controller('GisMapController', ($scope, $route, config, kbnUrl, localStorage timefilter.disableAutoRefreshSelector(); $scope.showDatePicker = true; // used by query-bar directive to enable timepikcer in query bar $scope.topNavMenu = [{ - key: 'full screen', - description: 'full screen', + key: i18n.translate('xpack.maps.mapController.fullScreenButtonLabel', { + defaultMessage: `full screen` + }), + description: i18n.translate('xpack.maps.mapController.fullScreenDescription', { + defaultMessage: `full screen` + }), testId: 'mapsFullScreenMode', run() { store.dispatch(enableFullScreen()); } }, { - key: 'inspect', - description: 'Open Inspector', + key: i18n.translate('xpack.maps.mapController.openInspectorButtonLabel', { + defaultMessage: `inspect` + }), + description: i18n.translate('xpack.maps.mapController.openInspectorDescription', { + defaultMessage: `Open Inspector` + }), testId: 'openInspectorButton', run() { const inspectorAdapters = getInspectorAdapters(store.getState()); Inspector.open(inspectorAdapters, {}); } }, { - key: 'save', - description: 'Save map', + key: i18n.translate('xpack.maps.mapController.saveMapButtonLabel', { + defaultMessage: `save` + }), + description: i18n.translate('xpack.maps.mapController.saveMapDescription', { + defaultMessage: `Save map` + }), testId: 'mapSaveButton', run: async () => { const onSave = ({ newTitle, newCopyOnSave, isTitleDuplicateConfirmed, onTitleDuplicate }) => { diff --git a/x-pack/plugins/maps/public/components/layer_addpanel/view.js b/x-pack/plugins/maps/public/components/layer_addpanel/view.js index 62568b6a88e46a..0808d4ab318045 100644 --- a/x-pack/plugins/maps/public/components/layer_addpanel/view.js +++ b/x-pack/plugins/maps/public/components/layer_addpanel/view.js @@ -20,6 +20,7 @@ import { EuiFlyoutBody, EuiFlyoutFooter, } from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; import _ from 'lodash'; export class AddLayerPanel extends Component { @@ -71,7 +72,10 @@ export class AddLayerPanel extends Component { }} fill > - Add layer + ); } @@ -102,7 +106,12 @@ export class AddLayerPanel extends Component { return ( -

Choose data source

+

+ +

{this._renderSourceCards()}
@@ -130,7 +139,10 @@ export class AddLayerPanel extends Component { onClick={this._clearSource} iconType="arrowLeft" > - Change data source + @@ -156,7 +168,12 @@ export class AddLayerPanel extends Component { > -

Add layer

+

+ +

@@ -175,7 +192,10 @@ export class AddLayerPanel extends Component { flush="left" data-test-subj="layerAddCancelButton" > - Cancel + diff --git a/x-pack/plugins/maps/public/components/layer_panel/__snapshots__/view.test.js.snap b/x-pack/plugins/maps/public/components/layer_panel/__snapshots__/view.test.js.snap index be667afaf2da5f..52eec2aea9dc68 100644 --- a/x-pack/plugins/maps/public/components/layer_panel/__snapshots__/view.test.js.snap +++ b/x-pack/plugins/maps/public/components/layer_panel/__snapshots__/view.test.js.snap @@ -35,7 +35,11 @@ exports[`LayerPanel is rendered 1`] = ` onClick={[Function]} type="button" > - Fit + { const removeBtn = ( @@ -23,11 +25,24 @@ export const FlyoutFooter = ({ cancelLayerPanel, saveLayerEdits, removeLayer, flush="right" data-test-subj="mapRemoveLayerButton" > - Remove layer + ); + + const cancelButtonLabel = hasStateChanged ? () : (); + + return ( @@ -35,7 +50,7 @@ export const FlyoutFooter = ({ cancelLayerPanel, saveLayerEdits, removeLayer, onClick={cancelLayerPanel} flush="left" > - {hasStateChanged ? 'Cancel' : 'Close'} + {cancelButtonLabel} @@ -49,7 +64,10 @@ export const FlyoutFooter = ({ cancelLayerPanel, saveLayerEdits, removeLayer, onClick={saveLayerEdits} fill > - Save & close + diff --git a/x-pack/plugins/maps/public/components/layer_panel/join_editor/resources/join.js b/x-pack/plugins/maps/public/components/layer_panel/join_editor/resources/join.js index 794897c7edd8a9..d487fb3030c17b 100644 --- a/x-pack/plugins/maps/public/components/layer_panel/join_editor/resources/join.js +++ b/x-pack/plugins/maps/public/components/layer_panel/join_editor/resources/join.js @@ -6,13 +6,12 @@ import _ from 'lodash'; import React, { Component } from 'react'; - import { EuiFlexItem, EuiFlexGroup, EuiButtonIcon, } from '@elastic/eui'; - +import { i18n } from '@kbn/i18n'; import { JoinExpression } from './join_expression'; import { MetricsExpression } from './metrics_expression'; @@ -74,7 +73,10 @@ export class Join extends Component { } catch (err) { if (this._isMounted) { this.setState({ - loadError: `Unable to find Index pattern ${indexPatternId}` + loadError: i18n.translate('xpack.maps.layerPanel.join.noIndexPatternErrorMessage', { + defaultMessage: `Unable to find Index pattern {indexPatternId}`, + values: { indexPatternId } + }) }); } return; @@ -204,8 +206,12 @@ export class Join extends Component { className="mapJoinItem__delete" iconType="trash" color="danger" - aria-label="Delete join" - title="Delete join" + aria-label={i18n.translate('xpack.maps.layerPanel.join.deleteJoinAriaLabel', { + defaultMessage: 'Delete join' + })} + title={i18n.translate('xpack.maps.layerPanel.join.deleteJoinTitle', { + defaultMessage: 'Delete join' + })} onClick={onRemove} /> diff --git a/x-pack/plugins/maps/public/components/layer_panel/join_editor/resources/join_expression.js b/x-pack/plugins/maps/public/components/layer_panel/join_editor/resources/join_expression.js index 836efa89fb5323..8950a67249a3d6 100644 --- a/x-pack/plugins/maps/public/components/layer_panel/join_editor/resources/join_expression.js +++ b/x-pack/plugins/maps/public/components/layer_panel/join_editor/resources/join_expression.js @@ -7,7 +7,6 @@ import _ from 'lodash'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; - import { EuiPopover, EuiPopoverTitle, @@ -15,9 +14,10 @@ import { EuiFormRow, EuiComboBox, } from '@elastic/eui'; - +import { i18n } from '@kbn/i18n'; import { IndexPatternSelect } from 'ui/index_patterns/components/index_pattern_select'; import { SingleFieldSelect } from '../../../../shared/components/single_field_select'; +import { FormattedMessage } from '@kbn/i18n/react'; import { indexPatternService, @@ -87,10 +87,14 @@ export class JoinExpression extends Component { return (
- Join + + + { if (!this.props.rightFields) { return ( - JOIN must be set + + + ); } @@ -69,7 +73,12 @@ export class MetricsExpression extends Component { return `${type} ${field}`; }); - + const useMetricDescription = i18n.translate('xpack.maps.layerPanel.metricsExpression.useMetricsDescription', { + defaultMessage: '{metricsLength, plural, one {and use metric} other {and use metrics}}', + values: { + metricsLength: metricExpressions.length + } + }); return ( 1 ? 'and use metrics' : 'and use metric'} + description={useMetricDescription} uppercase={false} value={metricExpressions.length > 0 ? metricExpressions.join(', ') : 'count'} /> } >
- Metrics + + + {this._renderMetricsEditor()}
diff --git a/x-pack/plugins/maps/public/components/layer_panel/join_editor/view.js b/x-pack/plugins/maps/public/components/layer_panel/join_editor/view.js index d6334d93fa6179..600e645f1462b3 100644 --- a/x-pack/plugins/maps/public/components/layer_panel/join_editor/view.js +++ b/x-pack/plugins/maps/public/components/layer_panel/join_editor/view.js @@ -16,6 +16,8 @@ import { } from '@elastic/eui'; import { Join } from './resources/join'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; export function JoinEditor({ joins, layer, onChange }) { @@ -69,10 +71,30 @@ export function JoinEditor({ joins, layer, onChange }) {
-
Term joins
+ +
+ +
+
- + +
diff --git a/x-pack/plugins/maps/public/components/layer_panel/settings_panel/settings_panel.js b/x-pack/plugins/maps/public/components/layer_panel/settings_panel/settings_panel.js index 9aa4d99e9e6be0..c203892e455c1e 100644 --- a/x-pack/plugins/maps/public/components/layer_panel/settings_panel/settings_panel.js +++ b/x-pack/plugins/maps/public/components/layer_panel/settings_panel/settings_panel.js @@ -18,6 +18,8 @@ import { EuiCallOut, } from '@elastic/eui'; import { ValidatedRange } from '../../../shared/components/validated_range'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; export function SettingsPanel(props) { @@ -53,7 +55,11 @@ export function SettingsPanel(props) {

{props.layer.getErrors()} @@ -67,12 +73,18 @@ export function SettingsPanel(props) { const renderZoomSliders = () => { return ( { return ( { return (

-
Settings
+ +
+ +
+
diff --git a/x-pack/plugins/maps/public/components/layer_panel/view.js b/x-pack/plugins/maps/public/components/layer_panel/view.js index 2144731f28cf63..36e4ac6f484f6d 100644 --- a/x-pack/plugins/maps/public/components/layer_panel/view.js +++ b/x-pack/plugins/maps/public/components/layer_panel/view.js @@ -10,7 +10,6 @@ import { StyleTabs } from './style_tabs'; import { JoinEditor } from './join_editor'; import { FlyoutFooter } from './flyout_footer'; import { SettingsPanel } from './settings_panel'; - import { EuiButtonIcon, EuiFlexItem, @@ -26,6 +25,9 @@ import { EuiLink, } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; + export class LayerPanel extends React.Component { static getDerivedStateFromProps(nextProps, prevState) { @@ -41,7 +43,7 @@ export class LayerPanel extends React.Component { return null; } - state = {} + state = {}; componentDidMount() { this._isMounted = true; @@ -133,11 +135,19 @@ export class LayerPanel extends React.Component { - Fit + + @@ -150,7 +160,11 @@ export class LayerPanel extends React.Component {
diff --git a/x-pack/plugins/maps/public/components/layer_panel/view.test.js b/x-pack/plugins/maps/public/components/layer_panel/view.test.js index ab9cb7b9735fdb..200345bf92b742 100644 --- a/x-pack/plugins/maps/public/components/layer_panel/view.test.js +++ b/x-pack/plugins/maps/public/components/layer_panel/view.test.js @@ -29,7 +29,7 @@ jest.mock('./settings_panel', () => ({ })); import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { LayerPanel } from './view'; @@ -53,7 +53,7 @@ const defaultProps = { describe('LayerPanel', () => { test('is rendered', async () => { - const component = shallow( + const component = shallowWithIntl( @@ -69,7 +69,7 @@ describe('LayerPanel', () => { }); test('should render empty panel when selectedLayer is null', async () => { - const component = shallow( + const component = shallowWithIntl( { ]; } }; - const component = shallow( + const component = shallowWithIntl( diff --git a/x-pack/plugins/maps/public/components/widget_overlay/layer_control/__snapshots__/view.test.js.snap b/x-pack/plugins/maps/public/components/widget_overlay/layer_control/__snapshots__/view.test.js.snap index d36e9c5e81072d..0b1d9f96eade81 100644 --- a/x-pack/plugins/maps/public/components/widget_overlay/layer_control/__snapshots__/view.test.js.snap +++ b/x-pack/plugins/maps/public/components/widget_overlay/layer_control/__snapshots__/view.test.js.snap @@ -30,7 +30,11 @@ exports[`LayerControl is rendered 1`] = ` textTransform="none" >

- Layers +

@@ -47,7 +51,11 @@ exports[`LayerControl is rendered 1`] = ` size="xs" type="button" > - Add layer + @@ -92,7 +100,11 @@ exports[`LayerControl props isReadOnly 1`] = ` textTransform="none" >

- Layers +

diff --git a/x-pack/plugins/maps/public/components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js b/x-pack/plugins/maps/public/components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js index 8b5fba602b0a9f..5622a17fd39b82 100644 --- a/x-pack/plugins/maps/public/components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js +++ b/x-pack/plugins/maps/public/components/widget_overlay/layer_control/layer_toc/toc_entry/view.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { TOCEntry } from './view'; @@ -30,7 +30,7 @@ const defaultProps = { describe('TOCEntry', () => { test('is rendered', async () => { - const component = shallow( + const component = shallowWithIntl( @@ -47,7 +47,7 @@ describe('TOCEntry', () => { describe('props', () => { test('isReadOnly', async () => { - const component = shallow( + const component = shallowWithIntl( - Add layer + ); @@ -42,7 +46,12 @@ export function LayerControl({ isReadOnly, showAddLayerWizard }) { > -

Layers

+

+ +

{addLayer} diff --git a/x-pack/plugins/maps/public/components/widget_overlay/layer_control/view.test.js b/x-pack/plugins/maps/public/components/widget_overlay/layer_control/view.test.js index c0b58f864c2ad7..aba7733dd8ed66 100644 --- a/x-pack/plugins/maps/public/components/widget_overlay/layer_control/view.test.js +++ b/x-pack/plugins/maps/public/components/widget_overlay/layer_control/view.test.js @@ -11,7 +11,7 @@ jest.mock('./layer_toc', () => ({ })); import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { LayerControl } from './view'; @@ -21,7 +21,7 @@ const defaultProps = { describe('LayerControl', () => { test('is rendered', () => { - const component = shallow( + const component = shallowWithIntl( @@ -33,7 +33,7 @@ describe('LayerControl', () => { describe('props', () => { test('isReadOnly', () => { - const component = shallow( + const component = shallowWithIntl( { @@ -37,7 +38,10 @@ export function ViewControl({ isSetViewOpen, closeSetView, openSetView, mouseCoo onClick={toggleSetViewVisibility} data-test-subj="toggleSetViewVisibilityButton" > - Go to + )} isOpen={isSetViewOpen} closePopover={closeSetView} @@ -57,8 +61,18 @@ export function ViewControl({ isSetViewOpen, closeSetView, openSetView, mouseCoo

- lat: {lat},{' '} - lon: {lon} + + + {lat},{' '} + + + {lon}

diff --git a/x-pack/plugins/maps/public/elasticsearch_geo_utils.js b/x-pack/plugins/maps/public/elasticsearch_geo_utils.js index cb9c4aef05c45e..f926ceee1cd52d 100644 --- a/x-pack/plugins/maps/public/elasticsearch_geo_utils.js +++ b/x-pack/plugins/maps/public/elasticsearch_geo_utils.js @@ -5,6 +5,7 @@ */ import _ from 'lodash'; +import { i18n } from '@kbn/i18n'; /** * Converts Elasticsearch search results into GeoJson FeatureCollection @@ -27,7 +28,11 @@ export function hitsToGeoJson(hits, flattenHit, geoFieldName, geoFieldType) { } else if (geoFieldType === 'geo_shape') { geometries = geoShapeToGeometry(properties[geoFieldName]); } else { - throw new Error(`Unsupported field type, expected: geo_shape or geo_point, you provided: ${geoFieldType}`); + const errorMessage = i18n.translate('xpack.maps.elasticsearch_geo_utils.unsupportedFieldTypeErrorMessage', { + defaultMessage: 'Unsupported field type, expected: geo_shape or geo_point, you provided: {geoFieldType}', + values: { geoFieldType } + }); + throw new Error(errorMessage); } // don't include geometry field value in properties @@ -63,8 +68,11 @@ export function geoPointToGeometry(value) { if (typeof value === 'string') { const commaSplit = value.split(','); if (commaSplit.length === 1) { - // Geo-point expressed as a geohash. - throw new Error(`Unable to convert to geojson, geohash not supported`); + const errorMessage = i18n.translate('xpack.maps.elasticsearch_geo_utils.geohashIsUnsupportedErrorMessage', { + defaultMessage: `Unable to convert to geojson, geohash not supported` + }); + + throw new Error(errorMessage); } // Geo-point expressed as a string with the format: "lat,lon". const lat = parseFloat(commaSplit[0]); @@ -78,7 +86,13 @@ export function geoPointToGeometry(value) { } if (!Array.isArray(value)) { - throw new Error(`Unsupported geo_point value: ${value}`); + const errorMessage = i18n.translate('xpack.maps.elasticsearch_geo_utils.unsupportedGeoPointValueErrorMessage', { + defaultMessage: `Unsupported geo_point value: {geoPointValue}`, + values: { + geoPointValue: value + } + }); + throw new Error(errorMessage); } if (value.length === 2 @@ -116,7 +130,10 @@ export function geoShapeToGeometry(value) { // TODO handle case where value is WKT and convert to geojson if (typeof value === 'string') { - throw new Error(`Unable to convert WKT to geojson, not supported`); + const errorMessage = i18n.translate('xpack.maps.elasticsearch_geo_utils.wktIsUnsupportedErrorMessage', { + defaultMessage: `Unable to convert WKT to geojson, not supported`, + }); + throw new Error(errorMessage); } const geoJson = _.cloneDeep(value); @@ -180,7 +197,11 @@ export function createExtentFilter(mapExtent, geoFieldName, geoFieldType) { } }; } else { - throw new Error(`Unsupported field type, expected: geo_shape or geo_point, you provided: ${geoFieldType}`); + const errorMessage = i18n.translate('xpack.maps.elasticsearch_geo_utils.unsupportedGeoFieldTypeErrorMessage', { + defaultMessage: `Unsupported field type, expected: geo_shape or geo_point, you provided: {geoFieldType}`, + values: { geoFieldType } + }); + throw new Error(errorMessage); } } diff --git a/x-pack/plugins/maps/public/inspector/views/map_details.js b/x-pack/plugins/maps/public/inspector/views/map_details.js index 038085043505a3..389b69f0058616 100644 --- a/x-pack/plugins/maps/public/inspector/views/map_details.js +++ b/x-pack/plugins/maps/public/inspector/views/map_details.js @@ -15,6 +15,9 @@ import { EuiTableRow, EuiTableRowCell, } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; + const DETAILS_TAB_ID = 'details'; const STYLE_TAB_ID = 'mapStyle'; @@ -23,11 +26,15 @@ class MapDetails extends Component { tabs = [{ id: DETAILS_TAB_ID, - name: 'Map details', + name: i18n.translate('xpack.maps.inspector.mapDetailsTitle', { + defaultMessage: 'Map details' + }), dataTestSubj: 'mapDetailsTab', }, { id: STYLE_TAB_ID, - name: 'Mapbox style', + name: i18n.translate('xpack.maps.inspector.mapboxStyleTitle', { + defaultMessage: 'Mapbox style' + }), dataTestSubj: 'mapboxStyleTab', }]; @@ -60,21 +67,30 @@ class MapDetails extends Component { - Center lon + {this.props.centerLon} - Center lat + {this.props.centerLat} - Zoom + {this.props.zoom} diff --git a/x-pack/plugins/maps/public/inspector/views/map_view.js b/x-pack/plugins/maps/public/inspector/views/map_view.js index a42c7bbddfff97..e1bdcbdf191b7b 100644 --- a/x-pack/plugins/maps/public/inspector/views/map_view.js +++ b/x-pack/plugins/maps/public/inspector/views/map_view.js @@ -9,6 +9,7 @@ import PropTypes from 'prop-types'; import { InspectorView } from 'ui/inspector'; import { MapDetails } from './map_details'; +import { i18n } from '@kbn/i18n'; class MapViewComponent extends Component { @@ -54,9 +55,13 @@ MapViewComponent.propTypes = { }; const MapView = { - title: 'Map details', + title: i18n.translate('xpack.maps.inspector.mapDetailsViewTitle', { + defaultMessage: 'Map details' + }), order: 30, - help: `View the map state`, + help: i18n.translate('xpack.maps.inspector.mapDetailsViewHelpText', { + defaultMessage: 'View the map state' + }), shouldShow(adapters) { return Boolean(adapters.map); }, diff --git a/x-pack/plugins/maps/public/meta.js b/x-pack/plugins/maps/public/meta.js index 91a296f08cf767..cace04a9ae7bff 100644 --- a/x-pack/plugins/maps/public/meta.js +++ b/x-pack/plugins/maps/public/meta.js @@ -36,10 +36,10 @@ export async function getDataSources() { return loadingMetaPromise; } +/** + * Should only call this after verifying `isMetadataLoaded` equals true + */ export function getDataSourcesSync() { - if (!isLoaded) { - throw new Error('Metadata is not loaded yet. Use isMetadataLoaded first before calling this function.'); - } return meta; } diff --git a/x-pack/plugins/maps/public/register_feature.js b/x-pack/plugins/maps/public/register_feature.js index 067348d41afa55..e112ca23483ed9 100644 --- a/x-pack/plugins/maps/public/register_feature.js +++ b/x-pack/plugins/maps/public/register_feature.js @@ -8,14 +8,18 @@ import { FeatureCatalogueRegistryProvider, FeatureCatalogueCategory } from 'ui/registry/feature_catalogue'; - +import { i18n } from '@kbn/i18n'; +import { APP_ID, APP_ICON } from '../common/constants'; +import { getAppTitle } from '../common/i18n_getters'; FeatureCatalogueRegistryProvider.register(() => { return { - id: 'maps', - title: 'Maps', - description: 'Explore geospatial data from Elasticsearch and the Elastic Maps Service', - icon: 'gisApp', + id: APP_ID, + title: getAppTitle(), + description: i18n.translate('xpack.maps.feature.appDescription', { + defaultMessage: 'Explore geospatial data from Elasticsearch and the Elastic Maps Service' + }), + icon: APP_ICON, path: '/app/maps', showOnHomePage: true, category: FeatureCatalogueCategory.DATA diff --git a/x-pack/plugins/maps/public/shared/components/layer_toc_actions.js b/x-pack/plugins/maps/public/shared/components/layer_toc_actions.js index ae71f5db634693..158d51b6fcfbbf 100644 --- a/x-pack/plugins/maps/public/shared/components/layer_toc_actions.js +++ b/x-pack/plugins/maps/public/shared/components/layer_toc_actions.js @@ -15,6 +15,7 @@ import { EuiToolTip, EuiIconTip } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; function flattenPanelTree(tree, array = []) { array.push(tree); @@ -103,7 +104,7 @@ export class LayerTocActions extends Component { if (layer.hasErrors()) { smallLegendIcon = ( {icon} @@ -135,10 +140,14 @@ export class LayerTocActions extends Component { const visibilityToggle = this._getVisbilityIcon(); const panelTree = { id: 0, - title: 'Layer actions', + title: i18n.translate('xpack.maps.layerTocActions.layerActionsTitle', { + defaultMessage: 'Layer actions', + }), items: [ { - name: 'Fit to data', + name: i18n.translate('xpack.maps.layerTocActions.fitToDataTitle', { + defaultMessage: 'Fit to data', + }), icon: ( ), 'data-test-subj': 'fitToBoundsButton', - toolTipContent: this.state.supportsFitToBounds ? null : 'Layer does not support fit to data', + toolTipContent: this.state.supportsFitToBounds ? null : i18n.translate('xpack.maps.layerTocActions.noFitSupportTooltip', { + defaultMessage: 'Layer does not support fit to data', + }), disabled: !this.state.supportsFitToBounds, onClick: () => { this._closePopover(); @@ -154,7 +165,11 @@ export class LayerTocActions extends Component { }, }, { - name: this.props.layer.isVisible() ? 'Hide layer' : 'Show layer', + name: this.props.layer.isVisible() ? i18n.translate('xpack.maps.layerTocActions.hideLayerTitle', { + defaultMessage: 'Hide layer', + }) : i18n.translate('xpack.maps.layerTocActions.showLayerTitle', { + defaultMessage: 'Show layer', + }), icon: visibilityToggle, 'data-test-subj': 'layerVisibilityToggleButton', onClick: () => { diff --git a/x-pack/plugins/maps/public/shared/components/layer_toc_actions.test.js b/x-pack/plugins/maps/public/shared/components/layer_toc_actions.test.js index 118f6b20f23a21..71a5f1cedd008c 100644 --- a/x-pack/plugins/maps/public/shared/components/layer_toc_actions.test.js +++ b/x-pack/plugins/maps/public/shared/components/layer_toc_actions.test.js @@ -5,7 +5,7 @@ */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallowWithIntl } from 'test_utils/enzyme_helpers'; import { LayerTocActions } from './layer_toc_actions'; @@ -41,7 +41,7 @@ describe('LayerTocActions', () => { }); test('is rendered', async () => { - const component = shallow( + const component = shallowWithIntl( @@ -58,7 +58,7 @@ describe('LayerTocActions', () => { test('should disable fit to data when supportsFitToBounds is false', async () => { supportsFitToBounds = false; - const component = shallow( + const component = shallowWithIntl( @@ -75,7 +75,7 @@ describe('LayerTocActions', () => { test('should display spinner when layer is loading', async () => { isLayerLoading = true; - const component = shallow( + const component = shallowWithIntl( @@ -92,7 +92,7 @@ describe('LayerTocActions', () => { test('should show warning when layer has errors', async () => { hasErrors = true; - const component = shallow( + const component = shallowWithIntl( @@ -109,7 +109,7 @@ describe('LayerTocActions', () => { test('should show visible toggle when layer is not visible', async () => { isVisible = false; - const component = shallow( + const component = shallowWithIntl( @@ -126,7 +126,7 @@ describe('LayerTocActions', () => { test('should provide feedback when layer is not visible because of current zoom level', async () => { showAtZoomLevel = false; - const component = shallow( + const component = shallowWithIntl( diff --git a/x-pack/plugins/maps/public/shared/components/map_listing.js b/x-pack/plugins/maps/public/shared/components/map_listing.js index 03b85dfd6752a4..c3e6e42b577a17 100644 --- a/x-pack/plugins/maps/public/shared/components/map_listing.js +++ b/x-pack/plugins/maps/public/shared/components/map_listing.js @@ -25,6 +25,8 @@ import { EuiCallOut, EuiBetaBadge, } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; export const EMPTY_FILTER = ''; @@ -86,7 +88,9 @@ export class MapListing extends React.Component { await this.props.delete(this.state.selectedIds); } catch (error) { toastNotifications.addDanger({ - title: `Unable to delete map(s)`, + title: i18n.translate('xpack.maps.mapListing.unableToDeleteToastTitle', { + defaultMessage: `Unable to delete map(s)` + }), text: `${error}`, }); } @@ -168,14 +172,25 @@ export class MapListing extends React.Component { return ( -

{`You can't recover deleted items.`}

+

+ +

); @@ -186,14 +201,32 @@ export class MapListing extends React.Component { return (

- You have {this.state.totalItems} items, - but your listingLimit setting prevents the table below from displaying more than {this.props.listingLimit}. - You can change this setting under Advanced Settings. + + + + + .

@@ -208,10 +241,14 @@ export class MapListing extends React.Component { } if (this.hasNoItems()) { - return `Looks like you don't have any maps. Click the create button to create one.`; + return i18n.translate('xpack.maps.mapListing.noItemsDescription', { + defaultMessage: `Looks like you don't have any maps. Click the create button to create one.` + }); } - return 'No items matched your search.'; + return i18n.translate('xpack.maps.mapListing.noMatchDescription', { + defaultMessage: 'No items matched your search.' + }); } renderSearchBar() { @@ -225,7 +262,10 @@ export class MapListing extends React.Component { data-test-subj="deleteSelectedItems" key="delete" > - Delete selected + ); @@ -236,8 +276,12 @@ export class MapListing extends React.Component { {deleteBtn} { @@ -256,7 +300,9 @@ export class MapListing extends React.Component { const tableColumns = [ { field: 'title', - name: 'Title', + name: i18n.translate('xpack.maps.mapListing.titleFieldTitle', { + defaultMessage: 'Title' + }), sortable: true, render: (field, record) => ( - Create map + ); @@ -335,7 +386,10 @@ export class MapListing extends React.Component {

- Maps +

@@ -343,7 +397,11 @@ export class MapListing extends React.Component { diff --git a/x-pack/plugins/maps/public/shared/components/metric_select.js b/x-pack/plugins/maps/public/shared/components/metric_select.js index dda659106a1f7d..3be3b13969cac9 100644 --- a/x-pack/plugins/maps/public/shared/components/metric_select.js +++ b/x-pack/plugins/maps/public/shared/components/metric_select.js @@ -6,15 +6,30 @@ import React from 'react'; import PropTypes from 'prop-types'; - +import { i18n } from '@kbn/i18n'; import { EuiComboBox } from '@elastic/eui'; const AGG_OPTIONS = [ - { label: 'Average', value: 'avg' }, - { label: 'Count', value: 'count' }, - { label: 'Max', value: 'max' }, - { label: 'Min', value: 'min' }, - { label: 'Sum', value: 'sum' }, + { label: i18n.translate('xpack.maps.metricSelect.averageDropDownOptionLabel', { + defaultMessage: 'Average' + }), + value: 'avg' }, + { label: i18n.translate('xpack.maps.metricSelect.countDropDownOptionLabel', { + defaultMessage: 'Count' + }), + value: 'count' }, + { label: i18n.translate('xpack.maps.metricSelect.maxDropDownOptionLabel', { + defaultMessage: 'Max' + }), + value: 'max' }, + { label: i18n.translate('xpack.maps.metricSelect.minDropDownOptionLabel', { + defaultMessage: 'Min' + }), + value: 'min' }, + { label: i18n.translate('xpack.maps.metricSelect.sumDropDownOptionLabel', { + defaultMessage: 'Sum' + }), + value: 'sum' }, ]; export const METRIC_AGGREGATION_VALUES = AGG_OPTIONS.map(({ value }) => { return value; }); @@ -34,7 +49,11 @@ export function MetricSelect({ value, onChange, metricsFilter }) { return ( @@ -120,8 +128,12 @@ export function MetricsEditor({ fields, metrics, onChange, allowMultipleMetrics, return (); } diff --git a/x-pack/plugins/maps/public/shared/components/no_index_pattern_callout.js b/x-pack/plugins/maps/public/shared/components/no_index_pattern_callout.js index 64657563878299..498a8e78b56b54 100644 --- a/x-pack/plugins/maps/public/shared/components/no_index_pattern_callout.js +++ b/x-pack/plugins/maps/public/shared/components/no_index_pattern_callout.js @@ -8,24 +8,45 @@ import chrome from 'ui/chrome'; import React from 'react'; import { EuiCallOut, EuiLink } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; export function NoIndexPatternCallout() { return (

- You’ll need to{' '} + - create an index pattern - {' '} - with geospatial fields. + + +

- Don’t have any geospatial data sets?{' '} + - Get started with some sample data sets. +

diff --git a/x-pack/plugins/maps/public/shared/components/validated_range.js b/x-pack/plugins/maps/public/shared/components/validated_range.js index 9447dc6a21a2f8..7b8ead00c2e5a2 100644 --- a/x-pack/plugins/maps/public/shared/components/validated_range.js +++ b/x-pack/plugins/maps/public/shared/components/validated_range.js @@ -7,6 +7,7 @@ import React, { Fragment } from 'react'; import { EuiRange, EuiFormErrorText } from '@elastic/eui'; +import { FormattedText } from '@kbn/i18n/react'; function isWithinRange(min, max, value) { if (value >= min && value <= max) { @@ -68,7 +69,11 @@ export class ValidatedRange extends React.Component { if (!this.state.isValid) { errorMessage = ( - {`Must be between ${min} and ${max}`} + ); } diff --git a/x-pack/plugins/maps/public/shared/layers/heatmap_layer.js b/x-pack/plugins/maps/public/shared/layers/heatmap_layer.js index 7ce0ea9ce39ef8..639df80b00b286 100644 --- a/x-pack/plugins/maps/public/shared/layers/heatmap_layer.js +++ b/x-pack/plugins/maps/public/shared/layers/heatmap_layer.js @@ -20,15 +20,14 @@ export class HeatmapLayer extends AbstractLayer { static createDescriptor(options) { const heatmapLayerDescriptor = super.createDescriptor(options); heatmapLayerDescriptor.type = HeatmapLayer.type; - const defaultStyle = HeatmapStyle.createDescriptor('coarse'); - heatmapLayerDescriptor.style = defaultStyle; + heatmapLayerDescriptor.style = HeatmapStyle.createDescriptor(); return heatmapLayerDescriptor; } constructor({ layerDescriptor, source, style }) { super({ layerDescriptor, source, style }); if (!style) { - const defaultStyle = HeatmapStyle.createDescriptor('coarse'); + const defaultStyle = HeatmapStyle.createDescriptor(); this._style = new HeatmapStyle(defaultStyle); } } diff --git a/x-pack/plugins/maps/public/shared/layers/sources/ems_file_source/create_source_editor.js b/x-pack/plugins/maps/public/shared/layers/sources/ems_file_source/create_source_editor.js index 312ec9539b32c0..03409e09fbbb3f 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/ems_file_source/create_source_editor.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/ems_file_source/create_source_editor.js @@ -13,6 +13,7 @@ import { import { getEmsVectorFilesMeta } from '../../../../meta'; import { getEmsUnavailableMessage } from '../ems_unavailable_message'; +import { i18n } from '@kbn/i18n'; export class EMSFileCreateSourceEditor extends React.Component { @@ -63,11 +64,19 @@ export class EMSFileCreateSourceEditor extends React.Component { return ( source.id === this._descriptor.id)); if (!meta) { - throw new Error(`Unable to find EMS vector shapes for id: ${this._descriptor.id}`); + throw new Error(i18n.translate('xpack.maps.source.emsFile.unableToFindIdErrorMessage', { + defaultMessage: `Unable to find EMS vector shapes for id: {id}`, + values: { + id: this._descriptor.id + } + })); } return meta; } @@ -59,8 +70,16 @@ export class EMSFileSource extends AbstractVectorSource { async getImmutableProperties() { const emsLink = await emsServiceSettings.getEMSHotLink({ id: this._descriptor.id }); return [ - { label: 'Data source', value: EMSFileSource.title }, - { label: 'Layer', value: this._descriptor.id, link: emsLink } + { + label: getDataSourceLabel(), + value: EMSFileSource.title + }, + { + label: i18n.translate('xpack.maps.source.emsFile.layerLabel', { + defaultMessage: `Layer`, + }), + value: this._descriptor.id, + link: emsLink } ]; } diff --git a/x-pack/plugins/maps/public/shared/layers/sources/ems_tms_source/create_source_editor.js b/x-pack/plugins/maps/public/shared/layers/sources/ems_tms_source/create_source_editor.js index ac5c2c5f3cfd18..cdc61b1defe7bb 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/ems_tms_source/create_source_editor.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/ems_tms_source/create_source_editor.js @@ -13,6 +13,7 @@ import { import { getEmsTMSServices } from '../../../../meta'; import { getEmsUnavailableMessage } from '../ems_unavailable_message'; +import { i18n } from '@kbn/i18n'; export class EMSTMSCreateSourceEditor extends React.Component { @@ -53,7 +54,9 @@ export class EMSTMSCreateSourceEditor extends React.Component { return ( + + + diff --git a/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/es_geo_grid_source.js b/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/es_geo_grid_source.js index 3ce3167edd2b0b..d15a9df61ea5ef 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/es_geo_grid_source.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/es_geo_grid_source.js @@ -21,6 +21,8 @@ import { UpdateSourceEditor } from './update_source_editor'; import { GRID_RESOLUTION } from '../../grid_resolution'; import { SOURCE_DATA_ID_ORIGIN, ES_GEO_GRID } from '../../../../../common/constants'; import { filterPropertiesForTooltip } from '../../util'; +import { i18n } from '@kbn/i18n'; +import { getDataSourceLabel } from '../../../../../common/i18n_getters'; const COUNT_PROP_LABEL = 'count'; const COUNT_PROP_NAME = 'doc_count'; @@ -51,8 +53,12 @@ const aggSchemas = new Schemas([ export class ESGeoGridSource extends AbstractESSource { static type = ES_GEO_GRID; - static title = 'Grid aggregation'; - static description = 'Geospatial data grouped in grids with metrics for each gridded cell'; + static title = i18n.translate('xpack.maps.source.esGridTitle', { + defaultMessage: 'Grid aggregation' + }); + static description = i18n.translate('xpack.maps.source.esGridDescription', { + defaultMessage: 'Geospatial data grouped in grids with metrics for each gridded cell' + }); static createDescriptor({ indexPatternId, geoField, requestType, resolution }) { return { @@ -102,10 +108,27 @@ export class ESGeoGridSource extends AbstractESSource { } return [ - { label: 'Data source', value: ESGeoGridSource.title }, - { label: 'Index pattern', value: indexPatternTitle }, - { label: 'Geospatial field', value: this._descriptor.geoField }, - { label: 'Show as', value: this._descriptor.requestType }, + { + label: getDataSourceLabel(), + value: ESGeoGridSource.title + }, + { + label: i18n.translate('xpack.maps.source.esGrid.indexPatternLabel', { + defaultMessage: 'Index pattern' + }), + value: indexPatternTitle }, + { + label: i18n.translate('xpack.maps.source.esGrid.geospatialFieldLabel', { + defaultMessage: 'Geospatial field' + }), + value: this._descriptor.geoField + }, + { + label: i18n.translate('xpack.maps.source.esGrid.showasFieldLabel', { + defaultMessage: 'Show as' + }), + value: this._descriptor.requestType + }, ]; } @@ -145,7 +168,12 @@ export class ESGeoGridSource extends AbstractESSource { return 4; } - throw new Error(`Grid resolution param not recognized: ${this._descriptor.resolution}`); + throw new Error(i18n.translate('xpack.maps.source.esGrid.resolutionParamErrorMessage', { + defaultMessage: `Grid resolution param not recognized: {resolution}`, + values: { + resolution: this._descriptor.resolution + } + })); } async getGeoJsonWithMeta(layerName, searchFilters) { @@ -172,7 +200,9 @@ export class ESGeoGridSource extends AbstractESSource { const searchSource = await this._makeSearchSource(searchFilters, 0); const aggConfigs = new AggConfigs(indexPattern, this._makeAggConfigs(searchFilters.geogridPrecision), aggSchemas.all); searchSource.setField('aggs', aggConfigs.toDsl()); - const esResponse = await this._runEsQuery(layerName, searchSource, 'Elasticsearch geohash_grid aggregation request'); + const esResponse = await this._runEsQuery(layerName, searchSource, i18n.translate('xpack.maps.source.esGrid.inspectorDescription', { + defaultMessage: 'Elasticsearch geo grid aggregation request' + })); const tabifiedResp = tabifyAggResponse(aggConfigs, esResponse); const { featureCollection } = convertToGeoJson({ diff --git a/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/resolution_editor.js b/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/resolution_editor.js index 16ea2c9e9b7dbc..fded85cc2fd49a 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/resolution_editor.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/resolution_editor.js @@ -12,12 +12,29 @@ import { EuiFlexItem, EuiFormLabel } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; const OPTIONS = [ - { value: GRID_RESOLUTION.COARSE, inputDisplay: 'coarse' }, - { value: GRID_RESOLUTION.FINE, inputDisplay: 'fine' }, - { value: GRID_RESOLUTION.MOST_FINE, inputDisplay: 'finest' } + { + value: GRID_RESOLUTION.COARSE, + inputDisplay: i18n.translate('xpack.maps.source.esGrid.coarseDropdownOption', { + defaultMessage: 'coarse' + }) + }, + { value: GRID_RESOLUTION.FINE, + inputDisplay: i18n.translate('xpack.maps.source.esGrid.fineDropdownOption', { + defaultMessage: 'fine' + }) + + }, + { + value: GRID_RESOLUTION.MOST_FINE, + inputDisplay: i18n.translate('xpack.maps.source.esGrid.finestDropdownOption', { + defaultMessage: 'finest' + }) + } ]; export function ResolutionEditor({ resolution, onChange }) { @@ -26,7 +43,10 @@ export function ResolutionEditor({ resolution, onChange }) { - Grid resolution + diff --git a/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/update_source_editor.js b/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/update_source_editor.js index 1293fc3f5db2d0..a876216b2b7d6d 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/update_source_editor.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/es_geo_grid_source/update_source_editor.js @@ -10,6 +10,7 @@ import { RENDER_AS } from './render_as'; import { MetricsEditor } from '../../../components/metrics_editor'; import { indexPatternService } from '../../../../kibana_services'; import { ResolutionEditor } from './resolution_editor'; +import { i18n } from '@kbn/i18n'; export class UpdateSourceEditor extends Component { @@ -33,7 +34,12 @@ export class UpdateSourceEditor extends Component { } catch (err) { if (this._isMounted) { this.setState({ - loadError: `Unable to find Index pattern ${this.props.indexPatternId}` + loadError: i18n.translate('xpack.maps.source.esGrid.noIndexPatternErrorMessage', { + defaultMessage: `Unable to find Index pattern {id}`, + values: { + id: this.props.indexPatternId + } + }) }); } return; diff --git a/x-pack/plugins/maps/public/shared/layers/sources/es_join_source.js b/x-pack/plugins/maps/public/shared/layers/sources/es_join_source.js index ded6824ea45253..3af36a696da13f 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/es_join_source.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/es_join_source.js @@ -14,6 +14,7 @@ import { } from '../../../kibana_services'; import { AggConfigs } from 'ui/vis/agg_configs'; import { timefilter } from 'ui/timefilter/timefilter'; +import { i18n } from '@kbn/i18n'; const TERMS_AGG_NAME = 'join'; @@ -62,6 +63,7 @@ export class ESJoinSource extends AbstractESSource { static renderEditor({}) { + //no need to localize. this editor is never rendered. return `
editor details
`; } @@ -123,7 +125,12 @@ export class ESJoinSource extends AbstractESSource { requestDesc: this.getJoinDescription(leftSourceName, leftFieldName), }); } catch (error) { - throw new Error(`Elasticsearch search request failed, error: ${error.message}`); + throw new Error(i18n.translate('xpack.maps.source.esJoin.errorMessage', { + defaultMessage: `Elasticsearch search request failed, error: {message}`, + values: { + message: error.message + } + })); } const metricPropertyNames = configStates @@ -154,10 +161,21 @@ export class ESJoinSource extends AbstractESSource { return metric.type !== 'count' ? `${metric.type} ${metric.field}` : 'count'; }); const joinStatement = []; - joinStatement.push(`Join ${leftSourceName}:${leftFieldName} with`); + joinStatement.push(i18n.translate('xpack.maps.source.esJoin.joinLeftDescription', { + defaultMessage: `Join {leftSourceName}:{leftFieldName} with`, + values: { leftSourceName, leftFieldName } + })); joinStatement.push(`${this._descriptor.indexPatternTitle}:${this._descriptor.term}`); - joinStatement.push(`for metrics ${metrics.join(',')}`); - return `Elasticsearch terms aggregation request for ${joinStatement.join(' ')}`; + joinStatement.push(i18n.translate('xpack.maps.source.esJoin.joinMetricsDescription', { + defaultMessage: `for metrics {metrics}`, + values: { metrics: metrics.join(',') } + })); + return i18n.translate('xpack.maps.source.esJoin.joinDescription', { + defaultMessage: `Elasticsearch terms aggregation request for {description}`, + values: { + description: joinStatement.join(' ') + } + }); } _makeAggConfigs() { @@ -191,6 +209,7 @@ export class ESJoinSource extends AbstractESSource { } async getDisplayName() { + //no need to localize. this is never rendered. return `es_table ${this._descriptor.indexPatternId}`; } } diff --git a/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/create_source_editor.js b/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/create_source_editor.js index 7d385daf83e6b9..d806fd95d316e6 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/create_source_editor.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/create_source_editor.js @@ -13,6 +13,7 @@ import { IndexPatternSelect } from 'ui/index_patterns/components/index_pattern_s import { SingleFieldSelect } from '../../../components/single_field_select'; import { indexPatternService } from '../../../../kibana_services'; import { NoIndexPatternCallout } from '../../../components/no_index_pattern_callout'; +import { i18n } from '@kbn/i18n'; function filterGeoField(field) { return ['geo_point', 'geo_shape'].includes(field.type); @@ -22,14 +23,14 @@ export class CreateSourceEditor extends Component { static propTypes = { onSelect: PropTypes.func.isRequired, - } + }; state = { isLoadingIndexPattern: false, indexPatternId: '', geoField: '', noGeoIndexPatternsExist: false, - } + }; componentWillUnmount() { this._isMounted = false; @@ -52,7 +53,7 @@ export class CreateSourceEditor extends Component { indexPattern: undefined, geoField: undefined, }, this.debouncedLoad.bind(null, indexPatternId)); - } + }; debouncedLoad = _.debounce(async (indexPatternId) => { if (!indexPatternId || indexPatternId.length === 0) { @@ -126,10 +127,14 @@ export class CreateSourceEditor extends Component { return ( diff --git a/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/es_search_source.js b/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/es_search_source.js index c8b9b74a49a2c2..91c323868c563a 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/es_search_source.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/es_search_source.js @@ -13,14 +13,20 @@ import { hitsToGeoJson } from '../../../../elasticsearch_geo_utils'; import { CreateSourceEditor } from './create_source_editor'; import { UpdateSourceEditor } from './update_source_editor'; import { ES_SEARCH } from '../../../../../common/constants'; +import { i18n } from '@kbn/i18n'; +import { getDataSourceLabel } from '../../../../../common/i18n_getters'; const DEFAULT_LIMIT = 2048; export class ESSearchSource extends AbstractESSource { static type = ES_SEARCH; - static title = 'Documents'; - static description = 'Geospatial data from a Kibana index pattern'; + static title = i18n.translate('xpack.maps.source.esSearchTitle', { + defaultMessage: 'Documents' + }); + static description = i18n.translate('xpack.maps.source.esSearchDescription', { + defaultMessage: 'Geospatial data from a Kibana index pattern' + }); static renderEditor({ onPreviewSource, inspectorAdapters }) { const onSelect = (sourceConfig) => { @@ -96,10 +102,28 @@ export class ESSearchSource extends AbstractESSource { } return [ - { label: 'Data source', value: ESSearchSource.title }, - { label: 'Index pattern', value: indexPatternTitle }, - { label: 'Geospatial field', value: this._descriptor.geoField }, - { label: 'Geospatial field type', value: geoFieldType }, + { + label: getDataSourceLabel(), + value: ESSearchSource.title + }, + { + label: i18n.translate('xpack.maps.source.esSearch.indexPatternLabel', { + defaultMessage: `Index pattern`, + }), + value: indexPatternTitle + }, + { + label: i18n.translate('xpack.maps.source.esSearch.geoFieldLabel', { + defaultMessage: 'Geospatial field', + }), + value: this._descriptor.geoField + }, + { + label: i18n.translate('xpack.maps.source.esSearch.geoFieldTypeLabel', { + defaultMessage: 'Geospatial field type', + }), + value: geoFieldType + }, ]; } diff --git a/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/update_source_editor.js b/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/update_source_editor.js index 7aec6c1714f036..596ae7b763ea7e 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/update_source_editor.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/es_search_source/update_source_editor.js @@ -13,6 +13,7 @@ import { import { MultiFieldSelect } from '../../../components/multi_field_select'; import { indexPatternService } from '../../../../kibana_services'; +import { i18n } from '@kbn/i18n'; export class UpdateSourceEditor extends Component { @@ -43,7 +44,12 @@ export class UpdateSourceEditor extends Component { } catch (err) { if (this._isMounted) { this.setState({ - loadError: `Unable to find Index pattern ${this.props.indexPatternId}` + loadError: i18n.translate('xpack.maps.source.esSearch.loadErrorMessage', { + defaultMessage: `Unable to find Index pattern {id}`, + values: { + id: this.props.indexPatternId + } + }) }); } return; @@ -68,10 +74,17 @@ export class UpdateSourceEditor extends Component { return ( diff --git a/x-pack/plugins/maps/public/shared/layers/sources/es_source.js b/x-pack/plugins/maps/public/shared/layers/sources/es_source.js index d31d668341d15a..24a6fc932f4e85 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/es_source.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/es_source.js @@ -14,6 +14,7 @@ import { createExtentFilter } from '../../../elasticsearch_geo_utils'; import { timefilter } from 'ui/timefilter/timefilter'; import _ from 'lodash'; import { AggConfigs } from 'ui/vis/agg_configs'; +import { i18n } from '@kbn/i18n'; export class AbstractESSource extends AbstractVectorSource { @@ -87,7 +88,10 @@ export class AbstractESSource extends AbstractVectorSource { requestDesc: requestDescription }); } catch(error) { - throw new Error(`Elasticsearch search request failed, error: ${error.message}`); + throw new Error('xpack.maps.source.esSource.requestFailedErrorMessage', { + defaultMessage: `Elasticsearch search request failed, error: {message}`, + values: { message: error.message } + }); } } @@ -174,7 +178,10 @@ export class AbstractESSource extends AbstractVectorSource { this.indexPattern = await indexPatternService.get(this._descriptor.indexPatternId); return this.indexPattern; } catch (error) { - throw new Error(`Unable to find Index pattern for id: ${this._descriptor.indexPatternId}`); + throw new Error(i18n.translate('xpack.maps.source.esSource.noIndexPatternErrorMessage', { + defaultMessage: `Unable to find Index pattern for id: {indexPatternId}`, + values: { indexPatternId: this._descriptor.indexPatternId } + })); } } @@ -194,7 +201,10 @@ export class AbstractESSource extends AbstractVectorSource { const indexPattern = await this._getIndexPattern(); const geoField = indexPattern.fields.byName[this._descriptor.geoField]; if (!geoField) { - throw new Error(`Index pattern ${indexPattern.title} no longer contains the geo field ${this._descriptor.geoField}`); + throw new Error(i18n.translate('xpack.maps.source.esSource.noGeoFieldErrorMessage', { + defaultMessage: `Index pattern {indexPatternTitle} no longer contains the geo field {geoField}`, + values: { indexPatternTitle: indexPattern.title, geoField: this._descriptor.geoField } + })); } return geoField; } diff --git a/x-pack/plugins/maps/public/shared/layers/sources/kibana_regionmap_source/create_source_editor.js b/x-pack/plugins/maps/public/shared/layers/sources/kibana_regionmap_source/create_source_editor.js index c740df0129ad69..c7b7fbf71bb7f9 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/kibana_regionmap_source/create_source_editor.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/kibana_regionmap_source/create_source_editor.js @@ -11,10 +11,7 @@ import { EuiFormRow, } from '@elastic/eui'; import { getKibanaRegionList } from '../../../../meta'; - -const NO_REGIONMAP_LAYERS_MSG = - 'No vector layers are available.' + - ' Ask your system administrator to set "map.regionmap" in kibana.yml.'; +import { i18n } from '@kbn/i18n'; export class CreateSourceEditor extends React.Component { @@ -42,8 +39,6 @@ export class CreateSourceEditor extends React.Component { render() { - - const onChange = ({ target }) => { const selectedName = target.options[target.selectedIndex].text; this.props.onSelect({ name: selectedName }); @@ -58,8 +53,15 @@ export class CreateSourceEditor extends React.Component { return ( source.name === this._descriptor.name); if (!meta) { - throw new Error(`Unable to find map.regionmap configuration for ${this._descriptor.name}`); + throw new Error(i18n.translate('xpack.maps.source.kbnRegionMap.noConfigErrorMessage', { + defaultMessage: `Unable to find map.regionmap configuration for {name}`, + values: { + name: this._descriptor.name + } + }) + ); } return meta; } diff --git a/x-pack/plugins/maps/public/shared/layers/sources/kibana_tilemap_source/create_source_editor.js b/x-pack/plugins/maps/public/shared/layers/sources/kibana_tilemap_source/create_source_editor.js index b5b2b6130ac2cc..858bec1b855e1f 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/kibana_tilemap_source/create_source_editor.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/kibana_tilemap_source/create_source_editor.js @@ -12,12 +12,7 @@ import { } from '@elastic/eui'; import { getKibanaTileMap } from '../../../../meta'; - -const NO_TILEMAP_LAYER_MSG = - 'No tilemap layer is available.' + - ' Ask your system administrator to set "map.tilemap.url" in kibana.yml.'; - - +import { i18n } from '@kbn/i18n'; export class CreateSourceEditor extends Component { @@ -56,8 +51,15 @@ export class CreateSourceEditor extends Component { return ( this._handleServiceUrlChange(e)} /> - + this._handleLayersChange(e)} /> - + this._handleStylesChange(e)} /> diff --git a/x-pack/plugins/maps/public/shared/layers/sources/xyz_tms_source.js b/x-pack/plugins/maps/public/shared/layers/sources/xyz_tms_source.js index ed78374727b82e..dac1d4b7aeba6c 100644 --- a/x-pack/plugins/maps/public/shared/layers/sources/xyz_tms_source.js +++ b/x-pack/plugins/maps/public/shared/layers/sources/xyz_tms_source.js @@ -13,12 +13,18 @@ import { import { AbstractTMSSource } from './tms_source'; import { TileLayer } from '../tile_layer'; +import { i18n } from '@kbn/i18n'; +import { getDataSourceLabel, getUrlLabel } from '../../../../common/i18n_getters'; export class XYZTMSSource extends AbstractTMSSource { static type = 'EMS_XYZ'; - static title = 'Tile Map Service from URL'; - static description = 'Map tiles from a URL that includes the XYZ coordinates'; + static title = i18n.translate('xpack.maps.source.ems_xyzTitle', { + defaultMessage: 'Tile Map Service from URL' + }); + static description = i18n.translate('xpack.maps.source.ems_xyzDescription', { + defaultMessage: 'Map tiles from a URL that includes the XYZ coordinates' + }); static icon = 'grid'; static createDescriptor(urlTemplate) { @@ -39,8 +45,8 @@ export class XYZTMSSource extends AbstractTMSSource { async getImmutableProperties() { return [ - { label: 'Data source', value: XYZTMSSource.title }, - { label: 'Url', value: this._descriptor.urlTemplate }, + { label: getDataSourceLabel(), value: XYZTMSSource.title }, + { label: getUrlLabel(), value: this._descriptor.urlTemplate }, ]; } @@ -92,7 +98,7 @@ class XYZTMSEditor extends React.Component { return ( this._handleTMSInputChange(e)} /> diff --git a/x-pack/plugins/maps/public/shared/layers/styles/components/static_dynamic_style_row.js b/x-pack/plugins/maps/public/shared/layers/styles/components/static_dynamic_style_row.js index d1e8ac6b8e26a3..f4ef285e94b9c8 100644 --- a/x-pack/plugins/maps/public/shared/layers/styles/components/static_dynamic_style_row.js +++ b/x-pack/plugins/maps/public/shared/layers/styles/components/static_dynamic_style_row.js @@ -7,6 +7,7 @@ import React from 'react'; import { VectorStyle } from '../vector_style'; import _ from 'lodash'; +import { i18n } from '@kbn/i18n'; import { EuiFlexGroup, @@ -93,7 +94,13 @@ export class StaticDynamicStyleRow extends React.Component { render() { const isDynamic = this._isDynamic(); const dynamicTooltipContent = - isDynamic ? 'Use static styling properties to symbolize features.' : 'Use property values to symbolize features.'; + isDynamic ? + i18n.translate('xpack.maps.styles.staticDynamic.staticDescription', { + defaultMessage: 'Use static styling properties to symbolize features.' + }) : + i18n.translate('xpack.maps.styles.staticDynamic.dynamicDescription', { + defaultMessage: 'Use property values to symbolize features.' + }); return ( diff --git a/x-pack/plugins/maps/public/shared/layers/styles/components/vector/field_select.js b/x-pack/plugins/maps/public/shared/layers/styles/components/vector/field_select.js index 5163a2fe46d23c..47ee4277236bdf 100644 --- a/x-pack/plugins/maps/public/shared/layers/styles/components/vector/field_select.js +++ b/x-pack/plugins/maps/public/shared/layers/styles/components/vector/field_select.js @@ -9,6 +9,7 @@ import React from 'react'; import { EuiComboBox } from '@elastic/eui'; import { SOURCE_DATA_ID_ORIGIN } from '../../../../../../common/constants'; +import { i18n } from '@kbn/i18n'; export function FieldSelect({ fields, selectedField, onChange }) { @@ -64,7 +65,11 @@ export function FieldSelect({ fields, selectedField, onChange }) { singleSelection={{ asPlainText: true }} isClearable={false} fullWidth - placeholder="Select a field" + placeholder={ + i18n.translate('xpack.maps.styles.vector.selectFieldPlaceholder', { + defaultMessage: 'Select a field' + }) + } /> ); } diff --git a/x-pack/plugins/maps/public/shared/layers/styles/components/vector/size/size_range_selector.js b/x-pack/plugins/maps/public/shared/layers/styles/components/vector/size/size_range_selector.js index 88b5926e2cf366..0ebb46495308f4 100644 --- a/x-pack/plugins/maps/public/shared/layers/styles/components/vector/size/size_range_selector.js +++ b/x-pack/plugins/maps/public/shared/layers/styles/components/vector/size/size_range_selector.js @@ -12,6 +12,7 @@ import { EuiFlexItem, } from '@elastic/eui'; import { ValidatedRange } from '../../../../../components/validated_range'; +import { i18n } from '@kbn/i18n'; import { DEFAULT_MIN_SIZE, DEFAULT_MAX_SIZE } from '../../../vector_style_defaults'; export function SizeRangeSelector({ minSize, maxSize, onChange }) { @@ -35,7 +36,11 @@ export function SizeRangeSelector({ minSize, maxSize, onChange }) { { + return [ + { + 'id': '2c9c1f60-1909-11e9-919b-ffe5949a18d2', + 'type': 'map', + 'updated_at': '2019-01-15T21:12:56.253Z', + 'version': 5, + 'references': [ + { + 'name': 'layer_1_join_0_index_pattern', + 'type': 'index-pattern', + 'id': 'ff959d40-b880-11e8-a6d9-e546fe2bba5f' + }, + { + 'name': 'layer_2_join_0_index_pattern', + 'type': 'index-pattern', + 'id': 'ff959d40-b880-11e8-a6d9-e546fe2bba5f' + }, + { + 'name': 'layer_3_join_0_index_pattern', + 'type': 'index-pattern', + 'id': 'ff959d40-b880-11e8-a6d9-e546fe2bba5f' + }, + { + 'name': 'layer_4_join_0_index_pattern', + 'type': 'index-pattern', + 'id': 'ff959d40-b880-11e8-a6d9-e546fe2bba5f' + }, + { + 'name': 'layer_5_source_index_pattern', + 'type': 'index-pattern', + 'id': 'ff959d40-b880-11e8-a6d9-e546fe2bba5f' + }, + { + 'name': 'layer_6_source_index_pattern', + 'type': 'index-pattern', + 'id': 'ff959d40-b880-11e8-a6d9-e546fe2bba5f' + } + ], + 'migrationVersion': { + 'map': '7.1.0' + }, + 'attributes': { + 'title': i18n.translate('xpack.maps.sampleData.ecommerceSpec.mapsTitle', { + defaultMessage: '[eCommerce] Orders by Country', + }), + 'description': '', + 'mapStateJSON': '{"zoom":2.11,"center":{"lon":-15.07605,"lat":45.88578},"timeFilters":{"from":"now-7d","to":"now"},"refreshConfig":{"isPaused":true,"interval":0},"query":{"query":"","language":"kuery"}}', + 'layerListJSON': '[{"id":"0hmz5","alpha":1,"sourceDescriptor":{"type":"EMS_TMS","id":"road_map"},"visible":true,"style":{"type":"TILE","properties":{}},"type":"TILE","minZoom":0,"maxZoom":24},{"id":"7ameq","label":null,"minZoom":0,"maxZoom":24,"alpha":1,"sourceDescriptor":{"type":"EMS_FILE","id":"world_countries"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"count of kibana_sample_data_ecommerce:geoip.country_iso_code","name":"__kbnjoin__count_groupby_kibana_sample_data_ecommerce.geoip.country_iso_code","origin":"join"},"color":"Green to Red"}},"lineColor":{"type":"STATIC","options":{"color":"#FFFFFF"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"STATIC","options":{"size":10}}}},"type":"VECTOR","joins":[{"leftField":"iso2","right":{"id":"741db9c6-8ebb-4ea9-9885-b6b4ac019d14","indexPatternTitle":"kibana_sample_data_ecommerce","term":"geoip.country_iso_code","indexPatternRefName":"layer_1_join_0_index_pattern"}}]},{"id":"jmtgf","label":"United States","minZoom":0,"maxZoom":24,"alpha":1,"sourceDescriptor":{"type":"EMS_FILE","id":"usa_states"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"count of kibana_sample_data_ecommerce:geoip.region_name","name":"__kbnjoin__count_groupby_kibana_sample_data_ecommerce.geoip.region_name","origin":"join"},"color":"Blues"}},"lineColor":{"type":"STATIC","options":{"color":"#FFFFFF"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"STATIC","options":{"size":10}}}},"type":"VECTOR","joins":[{"leftField":"name","right":{"id":"30a0ec24-49b6-476a-b4ed-6c1636333695","indexPatternTitle":"kibana_sample_data_ecommerce","term":"geoip.region_name","indexPatternRefName":"layer_2_join_0_index_pattern"}}]},{"id":"ui5f8","label":"France","minZoom":0,"maxZoom":24,"alpha":1,"sourceDescriptor":{"type":"EMS_FILE","id":"france_departments"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"count of kibana_sample_data_ecommerce:geoip.region_name","name":"__kbnjoin__count_groupby_kibana_sample_data_ecommerce.geoip.region_name","origin":"join"},"color":"Blues"}},"lineColor":{"type":"STATIC","options":{"color":"#FFFFFF"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"STATIC","options":{"size":10}}}},"type":"VECTOR","joins":[{"leftField":"label_en","right":{"id":"e325c9da-73fa-4b3b-8b59-364b99370826","indexPatternTitle":"kibana_sample_data_ecommerce","term":"geoip.region_name","indexPatternRefName":"layer_3_join_0_index_pattern"}}]},{"id":"y3fjb","label":"United Kingdom","minZoom":0,"maxZoom":24,"alpha":1,"sourceDescriptor":{"type":"EMS_FILE","id":"uk_subdivisions"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"count of kibana_sample_data_ecommerce:geoip.region_name","name":"__kbnjoin__count_groupby_kibana_sample_data_ecommerce.geoip.region_name","origin":"join"},"color":"Blues"}},"lineColor":{"type":"STATIC","options":{"color":"#FFFFFF"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"STATIC","options":{"size":10}}}},"type":"VECTOR","joins":[{"leftField":"label_en","right":{"id":"612d805d-8533-43a9-ac0e-cbf51fe63dcd","indexPatternTitle":"kibana_sample_data_ecommerce","term":"geoip.region_name","indexPatternRefName":"layer_4_join_0_index_pattern"}}]},{"id":"c54wk","label":"Sales","minZoom":9,"maxZoom":24,"alpha":1,"sourceDescriptor":{"id":"04c983b0-8cfa-4e6a-a64b-52c10b7008fe","type":"ES_SEARCH","geoField":"geoip.location","limit":2048,"filterByMapBounds":true,"tooltipProperties":["category","customer_gender","manufacturer","order_id","total_quantity","total_unique_products","taxful_total_price","order_date","geoip.region_name","geoip.country_iso_code"],"indexPatternRefName":"layer_5_source_index_pattern"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"taxful_total_price","name":"taxful_total_price","origin":"source"},"color":"Greens"}},"lineColor":{"type":"STATIC","options":{"color":"#FFFFFF"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"STATIC","options":{"size":10}}}},"type":"VECTOR"},{"id":"qvhh3","label":"Total Sales Revenue","minZoom":0,"maxZoom":9,"alpha":1,"sourceDescriptor":{"type":"ES_GEO_GRID","resolution":"COARSE","id":"aa7f87b8-9dc5-42be-b19e-1a2fa09b6cad","geoField":"geoip.location","requestType":"point","metrics":[{"type":"count"},{"type":"sum","field":"taxful_total_price"}],"indexPatternRefName":"layer_6_source_index_pattern"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"Count","name":"doc_count","origin":"source"},"color":"Greens"}},"lineColor":{"type":"STATIC","options":{"color":"#cccccc"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"DYNAMIC","options":{"field":{"label":"sum of taxful_total_price","name":"sum_of_taxful_total_price","origin":"source"},"minSize":1,"maxSize":20}}}},"type":"VECTOR"}]', + 'uiStateJSON': '{"isDarkMode":false}', + 'bounds': { 'type': 'envelope', 'coordinates': [[-117.50707, 72.64116], [87.35497, -4.16541]] } + } + } + ]; +}; diff --git a/x-pack/plugins/maps/server/sample_data/ecommerce_saved_objects.json b/x-pack/plugins/maps/server/sample_data/ecommerce_saved_objects.json deleted file mode 100644 index 60082162e605bf..00000000000000 --- a/x-pack/plugins/maps/server/sample_data/ecommerce_saved_objects.json +++ /dev/null @@ -1,51 +0,0 @@ -[ - { - "id":"2c9c1f60-1909-11e9-919b-ffe5949a18d2", - "type":"map", - "updated_at":"2019-01-15T21:12:56.253Z", - "version":5, - "references" : [ - { - "name" : "layer_1_join_0_index_pattern", - "type" : "index-pattern", - "id" : "ff959d40-b880-11e8-a6d9-e546fe2bba5f" - }, - { - "name" : "layer_2_join_0_index_pattern", - "type" : "index-pattern", - "id" : "ff959d40-b880-11e8-a6d9-e546fe2bba5f" - }, - { - "name" : "layer_3_join_0_index_pattern", - "type" : "index-pattern", - "id" : "ff959d40-b880-11e8-a6d9-e546fe2bba5f" - }, - { - "name" : "layer_4_join_0_index_pattern", - "type" : "index-pattern", - "id" : "ff959d40-b880-11e8-a6d9-e546fe2bba5f" - }, - { - "name" : "layer_5_source_index_pattern", - "type" : "index-pattern", - "id" : "ff959d40-b880-11e8-a6d9-e546fe2bba5f" - }, - { - "name" : "layer_6_source_index_pattern", - "type" : "index-pattern", - "id" : "ff959d40-b880-11e8-a6d9-e546fe2bba5f" - } - ], - "migrationVersion" : { - "map" : "7.1.0" - }, - "attributes":{ - "title":"[eCommerce] Orders by Country", - "description":"", - "mapStateJSON":"{\"zoom\":2.11,\"center\":{\"lon\":-15.07605,\"lat\":45.88578},\"timeFilters\":{\"from\":\"now-7d\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":true,\"interval\":0},\"query\":{\"query\":\"\",\"language\":\"kuery\"}}", - "layerListJSON" : "[{\"id\":\"0hmz5\",\"alpha\":1,\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\",\"minZoom\":0,\"maxZoom\":24},{\"id\":\"7ameq\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":1,\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"world_countries\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"count of kibana_sample_data_ecommerce:geoip.country_iso_code\",\"name\":\"__kbnjoin__count_groupby_kibana_sample_data_ecommerce.geoip.country_iso_code\",\"origin\":\"join\"},\"color\":\"Green to Red\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\",\"joins\":[{\"leftField\":\"iso2\",\"right\":{\"id\":\"741db9c6-8ebb-4ea9-9885-b6b4ac019d14\",\"indexPatternTitle\":\"kibana_sample_data_ecommerce\",\"term\":\"geoip.country_iso_code\",\"indexPatternRefName\":\"layer_1_join_0_index_pattern\"}}]},{\"id\":\"jmtgf\",\"label\":\"United States\",\"minZoom\":0,\"maxZoom\":24,\"alpha\":1,\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"usa_states\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"count of kibana_sample_data_ecommerce:geoip.region_name\",\"name\":\"__kbnjoin__count_groupby_kibana_sample_data_ecommerce.geoip.region_name\",\"origin\":\"join\"},\"color\":\"Blues\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\",\"joins\":[{\"leftField\":\"name\",\"right\":{\"id\":\"30a0ec24-49b6-476a-b4ed-6c1636333695\",\"indexPatternTitle\":\"kibana_sample_data_ecommerce\",\"term\":\"geoip.region_name\",\"indexPatternRefName\":\"layer_2_join_0_index_pattern\"}}]},{\"id\":\"ui5f8\",\"label\":\"France\",\"minZoom\":0,\"maxZoom\":24,\"alpha\":1,\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"france_departments\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"count of kibana_sample_data_ecommerce:geoip.region_name\",\"name\":\"__kbnjoin__count_groupby_kibana_sample_data_ecommerce.geoip.region_name\",\"origin\":\"join\"},\"color\":\"Blues\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\",\"joins\":[{\"leftField\":\"label_en\",\"right\":{\"id\":\"e325c9da-73fa-4b3b-8b59-364b99370826\",\"indexPatternTitle\":\"kibana_sample_data_ecommerce\",\"term\":\"geoip.region_name\",\"indexPatternRefName\":\"layer_3_join_0_index_pattern\"}}]},{\"id\":\"y3fjb\",\"label\":\"United Kingdom\",\"minZoom\":0,\"maxZoom\":24,\"alpha\":1,\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"uk_subdivisions\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"count of kibana_sample_data_ecommerce:geoip.region_name\",\"name\":\"__kbnjoin__count_groupby_kibana_sample_data_ecommerce.geoip.region_name\",\"origin\":\"join\"},\"color\":\"Blues\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\",\"joins\":[{\"leftField\":\"label_en\",\"right\":{\"id\":\"612d805d-8533-43a9-ac0e-cbf51fe63dcd\",\"indexPatternTitle\":\"kibana_sample_data_ecommerce\",\"term\":\"geoip.region_name\",\"indexPatternRefName\":\"layer_4_join_0_index_pattern\"}}]},{\"id\":\"c54wk\",\"label\":\"Sales\",\"minZoom\":9,\"maxZoom\":24,\"alpha\":1,\"sourceDescriptor\":{\"id\":\"04c983b0-8cfa-4e6a-a64b-52c10b7008fe\",\"type\":\"ES_SEARCH\",\"geoField\":\"geoip.location\",\"limit\":2048,\"filterByMapBounds\":true,\"tooltipProperties\":[\"category\",\"customer_gender\",\"manufacturer\",\"order_id\",\"total_quantity\",\"total_unique_products\",\"taxful_total_price\",\"order_date\",\"geoip.region_name\",\"geoip.country_iso_code\"],\"indexPatternRefName\":\"layer_5_source_index_pattern\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"taxful_total_price\",\"name\":\"taxful_total_price\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\"},{\"id\":\"qvhh3\",\"label\":\"Total Sales Revenue\",\"minZoom\":0,\"maxZoom\":9,\"alpha\":1,\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"resolution\":\"COARSE\",\"id\":\"aa7f87b8-9dc5-42be-b19e-1a2fa09b6cad\",\"geoField\":\"geoip.location\",\"requestType\":\"point\",\"metrics\":[{\"type\":\"count\"},{\"type\":\"sum\",\"field\":\"taxful_total_price\"}],\"indexPatternRefName\":\"layer_6_source_index_pattern\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#cccccc\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"sum of taxful_total_price\",\"name\":\"sum_of_taxful_total_price\",\"origin\":\"source\"},\"minSize\":1,\"maxSize\":20}}}},\"type\":\"VECTOR\"}]", - "uiStateJSON":"{\"isDarkMode\":false}", - "bounds":{"type":"envelope","coordinates":[[-117.50707,72.64116],[87.35497,-4.16541]]} - } - } -] diff --git a/x-pack/plugins/maps/server/sample_data/flights_saved_objects.js b/x-pack/plugins/maps/server/sample_data/flights_saved_objects.js new file mode 100644 index 00000000000000..b05690bb0d5fee --- /dev/null +++ b/x-pack/plugins/maps/server/sample_data/flights_saved_objects.js @@ -0,0 +1,50 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +/* eslint-disable max-len */ + +import { i18n } from '@kbn/i18n'; + +export const getFlightsSavedObjects = () => { + return [ + { + 'id': '5dd88580-1906-11e9-919b-ffe5949a18d2', + 'type': 'map', + 'updated_at': '2019-01-15T20:44:54.767Z', + 'version': 2, + 'references': [ + { + 'name': 'layer_1_source_index_pattern', + 'type': 'index-pattern', + 'id': 'd3d7af60-4c81-11e8-b3d7-01146121b73d' + }, + { + 'name': 'layer_2_source_index_pattern', + 'type': 'index-pattern', + 'id': 'd3d7af60-4c81-11e8-b3d7-01146121b73d' + }, + { + 'name': 'layer_3_source_index_pattern', + 'type': 'index-pattern', + 'id': 'd3d7af60-4c81-11e8-b3d7-01146121b73d' + } + ], + 'migrationVersion': { + 'map': '7.1.0' + }, + 'attributes': { + 'title': i18n.translate('xpack.maps.sampleData.flightaSpec.mapsTitle', { + defaultMessage: '[Flights] Origin and Destination Flight Time' + }), + 'description': '', + 'mapStateJSON': '{"zoom":3.14,"center":{"lon":-89.58746,"lat":38.38637},"timeFilters":{"from":"now-7d","to":"now"},"refreshConfig":{"isPaused":true,"interval":0},"query":{"query":"","language":"kuery"}}', + 'layerListJSON': '[{"id":"0hmz5","alpha":1,"sourceDescriptor":{"type":"EMS_TMS","id":"road_map"},"visible":true,"style":{"type":"TILE","properties":{}},"type":"TILE","minZoom":0,"maxZoom":24},{"id":"jzppx","label":"Flights","minZoom":9,"maxZoom":24,"alpha":1,"sourceDescriptor":{"id":"040e0f25-9687-4569-a1e0-76f1a108da56","type":"ES_SEARCH","geoField":"DestLocation","limit":2048,"filterByMapBounds":true,"tooltipProperties":["Carrier","DestCityName","DestCountry","OriginCityName","OriginCountry","FlightDelayMin","FlightTimeMin","DistanceMiles","AvgTicketPrice","FlightDelay"],"indexPatternRefName":"layer_1_source_index_pattern"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"FlightTimeMin","name":"FlightTimeMin","origin":"source"},"color":"Greens"}},"lineColor":{"type":"STATIC","options":{"color":"#FFFFFF"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"DYNAMIC","options":{"field":{"label":"DistanceMiles","name":"DistanceMiles","origin":"source"},"minSize":1,"maxSize":32}}}},"type":"VECTOR"},{"id":"y4jsz","label":"Flight Origin Location","minZoom":0,"maxZoom":9,"alpha":1,"sourceDescriptor":{"type":"ES_GEO_GRID","resolution":"COARSE","id":"fe893f84-388e-4865-8df4-650748533a77","geoField":"OriginLocation","requestType":"point","metrics":[{"type":"count"},{"type":"avg","field":"FlightTimeMin"}],"indexPatternRefName":"layer_2_source_index_pattern"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"Count","name":"doc_count","origin":"source"},"color":"Blues"}},"lineColor":{"type":"STATIC","options":{"color":"#110081"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"DYNAMIC","options":{"field":{"label":"avg of FlightTimeMin","name":"avg_of_FlightTimeMin","origin":"source"},"minSize":1,"maxSize":32}}}},"type":"VECTOR"},{"id":"x8xpo","label":"Flight Destination Location","minZoom":0,"maxZoom":9,"alpha":1,"sourceDescriptor":{"type":"ES_GEO_GRID","resolution":"COARSE","id":"60a7346a-8c5f-4c03-b7d1-e8b36e847551","geoField":"DestLocation","requestType":"point","metrics":[{"type":"count"},{"type":"avg","field":"FlightDelayMin"}],"indexPatternRefName":"layer_3_source_index_pattern"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"Count","name":"doc_count","origin":"source"},"color":"Reds"}},"lineColor":{"type":"STATIC","options":{"color":"#af0303"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"DYNAMIC","options":{"field":{"label":"avg of FlightDelayMin","name":"avg_of_FlightDelayMin","origin":"source"},"minSize":1,"maxSize":32}}}},"type":"VECTOR"}]', + 'uiStateJSON': '{"isDarkMode":false}', + 'bounds': { + 'type': 'envelope', 'coordinates': [[-139.83779, 56.64828], [-39.33713, 14.04811]] } + } + } + ]; +}; diff --git a/x-pack/plugins/maps/server/sample_data/flights_saved_objects.json b/x-pack/plugins/maps/server/sample_data/flights_saved_objects.json deleted file mode 100644 index 333a529b9d927e..00000000000000 --- a/x-pack/plugins/maps/server/sample_data/flights_saved_objects.json +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "id":"5dd88580-1906-11e9-919b-ffe5949a18d2", - "type":"map", - "updated_at":"2019-01-15T20:44:54.767Z", - "version":2, - "references" : [ - { - "name" : "layer_1_source_index_pattern", - "type" : "index-pattern", - "id" : "d3d7af60-4c81-11e8-b3d7-01146121b73d" - }, - { - "name" : "layer_2_source_index_pattern", - "type" : "index-pattern", - "id" : "d3d7af60-4c81-11e8-b3d7-01146121b73d" - }, - { - "name" : "layer_3_source_index_pattern", - "type" : "index-pattern", - "id" : "d3d7af60-4c81-11e8-b3d7-01146121b73d" - } - ], - "migrationVersion" : { - "map" : "7.1.0" - }, - "attributes":{ - "title":"[Flights] Origin and Destination Flight Time", - "description":"", - "mapStateJSON":"{\"zoom\":3.14,\"center\":{\"lon\":-89.58746,\"lat\":38.38637},\"timeFilters\":{\"from\":\"now-7d\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":true,\"interval\":0},\"query\":{\"query\":\"\",\"language\":\"kuery\"}}", - "layerListJSON" : "[{\"id\":\"0hmz5\",\"alpha\":1,\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\",\"minZoom\":0,\"maxZoom\":24},{\"id\":\"jzppx\",\"label\":\"Flights\",\"minZoom\":9,\"maxZoom\":24,\"alpha\":1,\"sourceDescriptor\":{\"id\":\"040e0f25-9687-4569-a1e0-76f1a108da56\",\"type\":\"ES_SEARCH\",\"geoField\":\"DestLocation\",\"limit\":2048,\"filterByMapBounds\":true,\"tooltipProperties\":[\"Carrier\",\"DestCityName\",\"DestCountry\",\"OriginCityName\",\"OriginCountry\",\"FlightDelayMin\",\"FlightTimeMin\",\"DistanceMiles\",\"AvgTicketPrice\",\"FlightDelay\"],\"indexPatternRefName\":\"layer_1_source_index_pattern\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"FlightTimeMin\",\"name\":\"FlightTimeMin\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"DistanceMiles\",\"name\":\"DistanceMiles\",\"origin\":\"source\"},\"minSize\":1,\"maxSize\":32}}}},\"type\":\"VECTOR\"},{\"id\":\"y4jsz\",\"label\":\"Flight Origin Location\",\"minZoom\":0,\"maxZoom\":9,\"alpha\":1,\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"resolution\":\"COARSE\",\"id\":\"fe893f84-388e-4865-8df4-650748533a77\",\"geoField\":\"OriginLocation\",\"requestType\":\"point\",\"metrics\":[{\"type\":\"count\"},{\"type\":\"avg\",\"field\":\"FlightTimeMin\"}],\"indexPatternRefName\":\"layer_2_source_index_pattern\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Blues\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#110081\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"avg of FlightTimeMin\",\"name\":\"avg_of_FlightTimeMin\",\"origin\":\"source\"},\"minSize\":1,\"maxSize\":32}}}},\"type\":\"VECTOR\"},{\"id\":\"x8xpo\",\"label\":\"Flight Destination Location\",\"minZoom\":0,\"maxZoom\":9,\"alpha\":1,\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"resolution\":\"COARSE\",\"id\":\"60a7346a-8c5f-4c03-b7d1-e8b36e847551\",\"geoField\":\"DestLocation\",\"requestType\":\"point\",\"metrics\":[{\"type\":\"count\"},{\"type\":\"avg\",\"field\":\"FlightDelayMin\"}],\"indexPatternRefName\":\"layer_3_source_index_pattern\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Reds\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#af0303\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"avg of FlightDelayMin\",\"name\":\"avg_of_FlightDelayMin\",\"origin\":\"source\"},\"minSize\":1,\"maxSize\":32}}}},\"type\":\"VECTOR\"}]", - "uiStateJSON":"{\"isDarkMode\":false}", - "bounds":{"type":"envelope","coordinates":[[-139.83779,56.64828],[-39.33713,14.04811]]} - } - } -] diff --git a/x-pack/plugins/maps/server/sample_data/web_logs_saved_objects.js b/x-pack/plugins/maps/server/sample_data/web_logs_saved_objects.js new file mode 100644 index 00000000000000..5d7ea053b66dac --- /dev/null +++ b/x-pack/plugins/maps/server/sample_data/web_logs_saved_objects.js @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +/* eslint-disable max-len */ + +import { i18n } from '@kbn/i18n'; + +export const getWebLogsSavedObjects = () => { + return [ + { + 'id': 'de71f4f0-1902-11e9-919b-ffe5949a18d2', + 'type': 'map', + 'updated_at': '2019-01-15T20:30:25.436Z', + 'version': 5, + 'references': [ + { + 'name': 'layer_1_join_0_index_pattern', + 'type': 'index-pattern', + 'id': '90943e30-9a47-11e8-b64d-95841ca0b247' + }, + { + 'name': 'layer_2_source_index_pattern', + 'type': 'index-pattern', + 'id': '90943e30-9a47-11e8-b64d-95841ca0b247' + }, + { + 'name': 'layer_3_source_index_pattern', + 'type': 'index-pattern', + 'id': '90943e30-9a47-11e8-b64d-95841ca0b247' + } + ], + 'migrationVersion': { + 'map': '7.1.0' + }, + 'attributes': { + 'title': i18n.translate('xpack.maps.sampleData.flightaSpec.logsTitle', { + defaultMessage: '[Logs] Total Requests and Bytes' + }), + 'description': '', + 'mapStateJSON': '{"zoom":3.64,"center":{"lon":-88.92107,"lat":42.16337},"timeFilters":{"from":"now-7d","to":"now"},"refreshConfig":{"isPaused":true,"interval":0},"query":{"language":"kuery","query":""}}', + 'layerListJSON': '[{"id":"0hmz5","alpha":1,"sourceDescriptor":{"type":"EMS_TMS","id":"road_map"},"visible":true,"style":{"type":"TILE","properties":{}},"type":"TILE","minZoom":0,"maxZoom":24},{"id":"edh66","label":"Total Requests by Country","minZoom":0,"maxZoom":24,"alpha":0.5,"sourceDescriptor":{"type":"EMS_FILE","id":"world_countries"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"count of kibana_sample_data_logs:geo.src","name":"__kbnjoin__count_groupby_kibana_sample_data_logs.geo.src","origin":"join"},"color":"Greys"}},"lineColor":{"type":"STATIC","options":{"color":"#FFFFFF"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"STATIC","options":{"size":10}}}},"type":"VECTOR","joins":[{"leftField":"iso2","right":{"id":"673ff994-fc75-4c67-909b-69fcb0e1060e","indexPatternTitle":"kibana_sample_data_logs","term":"geo.src","indexPatternRefName":"layer_1_join_0_index_pattern"}}]},{"id":"gaxya","label":"Actual Requests","minZoom":9,"maxZoom":24,"alpha":1,"sourceDescriptor":{"id":"b7486535-171b-4d3b-bb2e-33c1a0a2854c","type":"ES_SEARCH","geoField":"geo.coordinates","limit":2048,"filterByMapBounds":true,"tooltipProperties":["clientip","timestamp","host","request","response","machine.os","agent","bytes"],"indexPatternRefName":"layer_2_source_index_pattern"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"STATIC","options":{"color":"#2200ff"}},"lineColor":{"type":"STATIC","options":{"color":"#FFFFFF"}},"lineWidth":{"type":"STATIC","options":{"size":2}},"iconSize":{"type":"DYNAMIC","options":{"field":{"label":"bytes","name":"bytes","origin":"source"},"minSize":1,"maxSize":23}}}},"type":"VECTOR"},{"id":"tfi3f","label":"Total Requests and Bytes","minZoom":0,"maxZoom":9,"alpha":1,"sourceDescriptor":{"type":"ES_GEO_GRID","resolution":"COARSE","id":"8aaa65b5-a4e9-448b-9560-c98cb1c5ac5b","geoField":"geo.coordinates","requestType":"point","metrics":[{"type":"count"},{"type":"sum","field":"bytes"}],"indexPatternRefName":"layer_3_source_index_pattern"},"visible":true,"style":{"type":"VECTOR","properties":{"fillColor":{"type":"DYNAMIC","options":{"field":{"label":"Count","name":"doc_count","origin":"source"},"color":"Blues"}},"lineColor":{"type":"STATIC","options":{"color":"#cccccc"}},"lineWidth":{"type":"STATIC","options":{"size":1}},"iconSize":{"type":"DYNAMIC","options":{"field":{"label":"sum of bytes","name":"sum_of_bytes","origin":"source"},"minSize":1,"maxSize":25}}}},"type":"VECTOR"}]', + 'uiStateJSON': '{"isDarkMode":false}', + 'bounds': { 'type': 'envelope', 'coordinates': [[-124.45342, 54.91445], [-53.38872, 26.21461]] } + } + } + ]; +}; diff --git a/x-pack/plugins/maps/server/sample_data/web_logs_saved_objects.json b/x-pack/plugins/maps/server/sample_data/web_logs_saved_objects.json deleted file mode 100644 index f446931792bb0f..00000000000000 --- a/x-pack/plugins/maps/server/sample_data/web_logs_saved_objects.json +++ /dev/null @@ -1,36 +0,0 @@ -[ - { - "id":"de71f4f0-1902-11e9-919b-ffe5949a18d2", - "type":"map", - "updated_at":"2019-01-15T20:30:25.436Z", - "version":5, - "references" : [ - { - "name" : "layer_1_join_0_index_pattern", - "type" : "index-pattern", - "id" : "90943e30-9a47-11e8-b64d-95841ca0b247" - }, - { - "name" : "layer_2_source_index_pattern", - "type" : "index-pattern", - "id" : "90943e30-9a47-11e8-b64d-95841ca0b247" - }, - { - "name" : "layer_3_source_index_pattern", - "type" : "index-pattern", - "id" : "90943e30-9a47-11e8-b64d-95841ca0b247" - } - ], - "migrationVersion" : { - "map" : "7.1.0" - }, - "attributes":{ - "title":"[Logs] Total Requests and Bytes", - "description":"", - "mapStateJSON":"{\"zoom\":3.64,\"center\":{\"lon\":-88.92107,\"lat\":42.16337},\"timeFilters\":{\"from\":\"now-7d\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":true,\"interval\":0},\"query\":{\"language\":\"kuery\",\"query\":\"\"}}", - "layerListJSON" : "[{\"id\":\"0hmz5\",\"alpha\":1,\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\",\"minZoom\":0,\"maxZoom\":24},{\"id\":\"edh66\",\"label\":\"Total Requests by Country\",\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.5,\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"world_countries\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"count of kibana_sample_data_logs:geo.src\",\"name\":\"__kbnjoin__count_groupby_kibana_sample_data_logs.geo.src\",\"origin\":\"join\"},\"color\":\"Greys\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\",\"joins\":[{\"leftField\":\"iso2\",\"right\":{\"id\":\"673ff994-fc75-4c67-909b-69fcb0e1060e\",\"indexPatternTitle\":\"kibana_sample_data_logs\",\"term\":\"geo.src\",\"indexPatternRefName\":\"layer_1_join_0_index_pattern\"}}]},{\"id\":\"gaxya\",\"label\":\"Actual Requests\",\"minZoom\":9,\"maxZoom\":24,\"alpha\":1,\"sourceDescriptor\":{\"id\":\"b7486535-171b-4d3b-bb2e-33c1a0a2854c\",\"type\":\"ES_SEARCH\",\"geoField\":\"geo.coordinates\",\"limit\":2048,\"filterByMapBounds\":true,\"tooltipProperties\":[\"clientip\",\"timestamp\",\"host\",\"request\",\"response\",\"machine.os\",\"agent\",\"bytes\"],\"indexPatternRefName\":\"layer_2_source_index_pattern\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#2200ff\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":2}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"bytes\",\"name\":\"bytes\",\"origin\":\"source\"},\"minSize\":1,\"maxSize\":23}}}},\"type\":\"VECTOR\"},{\"id\":\"tfi3f\",\"label\":\"Total Requests and Bytes\",\"minZoom\":0,\"maxZoom\":9,\"alpha\":1,\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"resolution\":\"COARSE\",\"id\":\"8aaa65b5-a4e9-448b-9560-c98cb1c5ac5b\",\"geoField\":\"geo.coordinates\",\"requestType\":\"point\",\"metrics\":[{\"type\":\"count\"},{\"type\":\"sum\",\"field\":\"bytes\"}],\"indexPatternRefName\":\"layer_3_source_index_pattern\"},\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Blues\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#cccccc\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"sum of bytes\",\"name\":\"sum_of_bytes\",\"origin\":\"source\"},\"minSize\":1,\"maxSize\":25}}}},\"type\":\"VECTOR\"}]", - "uiStateJSON":"{\"isDarkMode\":false}", - "bounds":{"type":"envelope","coordinates":[[-124.45342,54.91445],[-53.38872,26.21461]]} - } - } -]