Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps][Draft] Migrate embeddable functionality and supporting architecture to NP #55138

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
EmbeddableFactory,
ErrorEmbeddable,
} from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
import { setup } from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy';
import { MapEmbeddable } from './map_embeddable';
import { indexPatternService } from '../kibana_services';

Expand Down Expand Up @@ -146,5 +145,3 @@ export class MapEmbeddableFactory extends EmbeddableFactory {
);
}
}

setup.registerEmbeddableFactory(MAP_SAVED_OBJECT_TYPE, new MapEmbeddableFactory());
8 changes: 7 additions & 1 deletion x-pack/legacy/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { wrapInI18nContext } from 'ui/i18n';
import { MapListing } from './components/map_listing';
// @ts-ignore
import { setLicenseId, setInspector } from './kibana_services';
// @ts-ignore
import { MapEmbeddableFactory } from './embeddable/map_embeddable_factory.js';
// @ts-ignore
import { MAP_SAVED_OBJECT_TYPE } from '../common/constants';

/**
* These are the interfaces with your public contracts. You should export these
Expand All @@ -25,9 +29,11 @@ export class MapsPlugin implements Plugin<MapsPluginSetup, MapsPluginStart> {
public setup(core: any, plugins: any) {
const {
__LEGACY: { uiModules },
np: { licensing },
np: { licensing, embeddable },
} = plugins;

embeddable.registerEmbeddableFactory(MAP_SAVED_OBJECT_TYPE, new MapEmbeddableFactory());

uiModules
.get('app/maps', ['ngRoute', 'react'])
.directive('mapListing', function(reactDirective: any) {
Expand Down
160 changes: 160 additions & 0 deletions x-pack/plugins/maps/common/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* 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 const EMS_CATALOGUE_PATH = 'ems/catalogue';

export const EMS_FILES_CATALOGUE_PATH = 'ems/files';
export const EMS_FILES_API_PATH = 'ems/files';
export const EMS_FILES_DEFAULT_JSON_PATH = 'file';
export const EMS_GLYPHS_PATH = 'fonts';
export const EMS_SPRITES_PATH = 'sprites';

export const EMS_TILES_CATALOGUE_PATH = 'ems/tiles';
export const EMS_TILES_API_PATH = 'ems/tiles';
export const EMS_TILES_RASTER_STYLE_PATH = 'raster/style';
export const EMS_TILES_RASTER_TILE_PATH = 'raster/tile';

export const EMS_TILES_VECTOR_STYLE_PATH = 'vector/style';
export const EMS_TILES_VECTOR_SOURCE_PATH = 'vector/source';
export const EMS_TILES_VECTOR_TILE_PATH = 'vector/tile';

export const MAP_SAVED_OBJECT_TYPE = 'map';
export const APP_ID = 'maps';
export const APP_ICON = 'gisApp';
export const TELEMETRY_TYPE = 'maps-telemetry';

export const MAP_APP_PATH = `app/${APP_ID}`;
export const GIS_API_PATH = `api/${APP_ID}`;
export const INDEX_SETTINGS_API_PATH = `${GIS_API_PATH}/indexSettings`;

export const MAP_BASE_URL = `/${MAP_APP_PATH}#/${MAP_SAVED_OBJECT_TYPE}`;

export function createMapPath(id) {
return `${MAP_BASE_URL}/${id}`;
}

export const LAYER_TYPE = {
TILE: 'TILE',
VECTOR: 'VECTOR',
VECTOR_TILE: 'VECTOR_TILE',
HEATMAP: 'HEATMAP',
};

export const SORT_ORDER = {
ASC: 'asc',
DESC: 'desc',
};

export const EMS_TMS = 'EMS_TMS';
export const EMS_FILE = 'EMS_FILE';
export const ES_GEO_GRID = 'ES_GEO_GRID';
export const ES_SEARCH = 'ES_SEARCH';
export const ES_PEW_PEW = 'ES_PEW_PEW';

export const FIELD_ORIGIN = {
SOURCE: 'source',
JOIN: 'join',
};

export const SOURCE_DATA_ID_ORIGIN = 'source';
export const META_ID_ORIGIN_SUFFIX = 'meta';
export const SOURCE_META_ID_ORIGIN = `${SOURCE_DATA_ID_ORIGIN}_${META_ID_ORIGIN_SUFFIX}`;
export const FORMATTERS_ID_ORIGIN_SUFFIX = 'formatters';
export const SOURCE_FORMATTERS_ID_ORIGIN = `${SOURCE_DATA_ID_ORIGIN}_${FORMATTERS_ID_ORIGIN_SUFFIX}`;

export const GEOJSON_FILE = 'GEOJSON_FILE';

export const MIN_ZOOM = 0;
export const MAX_ZOOM = 24;

export const DECIMAL_DEGREES_PRECISION = 5; // meters precision
export const ZOOM_PRECISION = 2;
export const DEFAULT_MAX_RESULT_WINDOW = 10000;
export const DEFAULT_MAX_INNER_RESULT_WINDOW = 100;
export const DEFAULT_MAX_BUCKETS_LIMIT = 10000;

export const FEATURE_ID_PROPERTY_NAME = '__kbn__feature_id__';
export const FEATURE_VISIBLE_PROPERTY_NAME = '__kbn_isvisibleduetojoin__';

export const MB_SOURCE_ID_LAYER_ID_PREFIX_DELIMITER = '_';

export const ES_GEO_FIELD_TYPE = {
GEO_POINT: 'geo_point',
GEO_SHAPE: 'geo_shape',
};

export const ES_SPATIAL_RELATIONS = {
INTERSECTS: 'INTERSECTS',
DISJOINT: 'DISJOINT',
WITHIN: 'WITHIN',
};

export const GEO_JSON_TYPE = {
POINT: 'Point',
MULTI_POINT: 'MultiPoint',
LINE_STRING: 'LineString',
MULTI_LINE_STRING: 'MultiLineString',
POLYGON: 'Polygon',
MULTI_POLYGON: 'MultiPolygon',
GEOMETRY_COLLECTION: 'GeometryCollection',
};

export const POLYGON_COORDINATES_EXTERIOR_INDEX = 0;
export const LON_INDEX = 0;
export const LAT_INDEX = 1;

export const EMPTY_FEATURE_COLLECTION = {
type: 'FeatureCollection',
features: [],
};

export const DRAW_TYPE = {
BOUNDS: 'BOUNDS',
POLYGON: 'POLYGON',
};

export const METRIC_TYPE = {
AVG: 'avg',
COUNT: 'count',
MAX: 'max',
MIN: 'min',
SUM: 'sum',
UNIQUE_COUNT: 'cardinality',
};

export const COUNT_AGG_TYPE = METRIC_TYPE.COUNT;
export const COUNT_PROP_LABEL = i18n.translate('xpack.maps.aggs.defaultCountLabel', {
defaultMessage: 'count',
});

export const COUNT_PROP_NAME = 'doc_count';

export const STYLE_TYPE = {
STATIC: 'STATIC',
DYNAMIC: 'DYNAMIC',
};

export const LAYER_STYLE_TYPE = {
VECTOR: 'VECTOR',
HEATMAP: 'HEATMAP',
};

export const COLOR_MAP_TYPE = {
CATEGORICAL: 'CATEGORICAL',
ORDINAL: 'ORDINAL',
};

export const COLOR_PALETTE_MAX_SIZE = 10;

export const CATEGORICAL_DATA_TYPES = ['string', 'ip', 'boolean'];

export const SYMBOLIZE_AS_TYPES = {
CIRCLE: 'circle',
ICON: 'icon',
};

export const DEFAULT_ICON = 'airfield';
50 changes: 50 additions & 0 deletions x-pack/plugins/maps/common/i18n_getters.js
Original file line number Diff line number Diff line change
@@ -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.
*/

import { i18n } from '@kbn/i18n';

import { ES_SPATIAL_RELATIONS } from './constants';

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',
});
}

export function getEsSpatialRelationLabel(spatialRelation) {
switch (spatialRelation) {
case ES_SPATIAL_RELATIONS.INTERSECTS:
return i18n.translate('xpack.maps.common.esSpatialRelation.intersectsLabel', {
defaultMessage: 'intersects',
});
case ES_SPATIAL_RELATIONS.DISJOINT:
return i18n.translate('xpack.maps.common.esSpatialRelation.disjointLabel', {
defaultMessage: 'disjoint',
});
case ES_SPATIAL_RELATIONS.WITHIN:
return i18n.translate('xpack.maps.common.esSpatialRelation.withinLabel', {
defaultMessage: 'within',
});
case ES_SPATIAL_RELATIONS.CONTAINS:
return i18n.translate('xpack.maps.common.esSpatialRelation.containsLabel', {
defaultMessage: 'contains',
});
default:
return spatialRelation;
}
}
22 changes: 22 additions & 0 deletions x-pack/plugins/maps/common/parse_xml_string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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 { parseString } from 'xml2js';

// promise based wrapper around parseString
export async function parseXmlString(xmlString) {
const parsePromise = new Promise((resolve, reject) => {
parseString(xmlString, (error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});

return await parsePromise;
}
16 changes: 16 additions & 0 deletions x-pack/plugins/maps/common/parse_xml_string.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 { parseXmlString } from './parse_xml_string';

describe('parseXmlString', () => {
it('Should parse xml string into JS object', async () => {
const xmlAsObject = await parseXmlString('<foo>bar</foo>');
expect(xmlAsObject).toEqual({
foo: 'bar',
});
});
});
8 changes: 8 additions & 0 deletions x-pack/plugins/maps/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "maps",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": ["xpack", "maps"],
"requiredPlugins": ["embeddable", "data"],
"ui": true
}
Loading