Skip to content

Commit

Permalink
Review feedback. Remove redundant portions. Export from NP where poss…
Browse files Browse the repository at this point in the history
…ible. General clean up
  • Loading branch information
Aaron Caldwell committed Mar 11, 2020
1 parent ab35a74 commit 25ec8f1
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 336 deletions.
182 changes: 2 additions & 180 deletions x-pack/legacy/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,183 +4,5 @@
* you may not use this file except in compliance with the Elastic License.
*/

// NP Migration
// Temporarily redundant with x-pack/plugins/maps/common/constants.ts
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: string) {
return `${MAP_BASE_URL}/${id}`;
}

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

export enum 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 EMS_XYZ = 'EMS_XYZ'; // identifies a custom TMS source. Name is a little unfortunate.

export enum 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 enum AGG_TYPE {
AVG = 'avg',
COUNT = 'count',
MAX = 'max',
MIN = 'min',
SUM = 'sum',
TERMS = 'terms',
UNIQUE_COUNT = 'cardinality',
}

export enum RENDER_AS {
HEATMAP = 'heatmap',
POINT = 'point',
GRID = 'grid',
}

export enum GRID_RESOLUTION {
COARSE = 'COARSE',
FINE = 'FINE',
MOST_FINE = 'MOST_FINE',
}

export const TOP_TERM_PERCENTAGE_SUFFIX = '__percentage';

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 ORDINAL_DATA_TYPES = ['number', 'date'];

export enum SYMBOLIZE_AS_TYPES {
CIRCLE = 'circle',
ICON = 'icon',
}

export enum LABEL_BORDER_SIZES {
NONE = 'NONE',
SMALL = 'SMALL',
MEDIUM = 'MEDIUM',
LARGE = 'LARGE',
}

export const DEFAULT_ICON = 'airfield';
// End temporary redundancy
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
export * from '../../../../plugins/maps/common/constants';
51 changes: 2 additions & 49 deletions x-pack/legacy/plugins/maps/common/i18n_getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,5 @@
* you may not use this file except in compliance with the Elastic License.
*/

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

import { $Values } from '@kbn/utility-types';
import { ES_SPATIAL_RELATIONS } from './constants';

// NP Migration
// Temporarily redundant with x-pack/plugins/maps/common/i18n_getters.ts
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: $Values<typeof ES_SPATIAL_RELATIONS>) {
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',
});
// @ts-ignore
case ES_SPATIAL_RELATIONS.CONTAINS:
return i18n.translate('xpack.maps.common.esSpatialRelation.containsLabel', {
defaultMessage: 'contains',
});
default:
return spatialRelation;
}
}
// End temporary redundancy
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
export * from '../../../../plugins/maps/common/i18n_getters';
21 changes: 2 additions & 19 deletions x-pack/legacy/plugins/maps/common/parse_xml_string.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,5 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { parseString } from 'xml2js';

// NP Migration
// Temporarily redundant with x-pack/plugins/maps/common/parse_xml_string.js
// 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;
}
// End temporary redundancy
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
export * from '../../../../plugins/maps/common/parse_xml_string';
91 changes: 46 additions & 45 deletions x-pack/legacy/plugins/maps/public/actions/map_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,51 +36,52 @@ import {
SOURCE_DATA_ID_ORIGIN,
} from '../../common/constants';

// NP Migration
// Temporarily redundant with x-pack/plugins/maps/public/actions/map_actions.js
export const SET_SELECTED_LAYER = 'SET_SELECTED_LAYER';
export const SET_TRANSIENT_LAYER = 'SET_TRANSIENT_LAYER';
export const UPDATE_LAYER_ORDER = 'UPDATE_LAYER_ORDER';
export const ADD_LAYER = 'ADD_LAYER';
export const SET_LAYER_ERROR_STATUS = 'SET_LAYER_ERROR_STATUS';
export const ADD_WAITING_FOR_MAP_READY_LAYER = 'ADD_WAITING_FOR_MAP_READY_LAYER';
export const CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST = 'CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST';
export const REMOVE_LAYER = 'REMOVE_LAYER';
export const SET_LAYER_VISIBILITY = 'SET_LAYER_VISIBILITY';
export const MAP_EXTENT_CHANGED = 'MAP_EXTENT_CHANGED';
export const MAP_READY = 'MAP_READY';
export const MAP_DESTROYED = 'MAP_DESTROYED';
export const LAYER_DATA_LOAD_STARTED = 'LAYER_DATA_LOAD_STARTED';
export const LAYER_DATA_LOAD_ENDED = 'LAYER_DATA_LOAD_ENDED';
export const LAYER_DATA_LOAD_ERROR = 'LAYER_DATA_LOAD_ERROR';
export const UPDATE_SOURCE_DATA_REQUEST = 'UPDATE_SOURCE_DATA_REQUEST';
export const SET_JOINS = 'SET_JOINS';
export const SET_QUERY = 'SET_QUERY';
export const TRIGGER_REFRESH_TIMER = 'TRIGGER_REFRESH_TIMER';
export const UPDATE_LAYER_PROP = 'UPDATE_LAYER_PROP';
export const UPDATE_LAYER_STYLE = 'UPDATE_LAYER_STYLE';
export const SET_LAYER_STYLE_META = 'SET_LAYER_STYLE_META';
export const TOUCH_LAYER = 'TOUCH_LAYER';
export const UPDATE_SOURCE_PROP = 'UPDATE_SOURCE_PROP';
export const SET_REFRESH_CONFIG = 'SET_REFRESH_CONFIG';
export const SET_MOUSE_COORDINATES = 'SET_MOUSE_COORDINATES';
export const CLEAR_MOUSE_COORDINATES = 'CLEAR_MOUSE_COORDINATES';
export const SET_GOTO = 'SET_GOTO';
export const CLEAR_GOTO = 'CLEAR_GOTO';
export const TRACK_CURRENT_LAYER_STATE = 'TRACK_CURRENT_LAYER_STATE';
export const ROLLBACK_TO_TRACKED_LAYER_STATE = 'ROLLBACK_TO_TRACKED_LAYER_STATE';
export const REMOVE_TRACKED_LAYER_STATE = 'REMOVE_TRACKED_LAYER_STATE';
export const SET_OPEN_TOOLTIPS = 'SET_OPEN_TOOLTIPS';
export const UPDATE_DRAW_STATE = 'UPDATE_DRAW_STATE';
export const SET_SCROLL_ZOOM = 'SET_SCROLL_ZOOM';
export const SET_MAP_INIT_ERROR = 'SET_MAP_INIT_ERROR';
export const SET_INTERACTIVE = 'SET_INTERACTIVE';
export const DISABLE_TOOLTIP_CONTROL = 'DISABLE_TOOLTIP_CONTROL';
export const HIDE_TOOLBAR_OVERLAY = 'HIDE_TOOLBAR_OVERLAY';
export const HIDE_LAYER_CONTROL = 'HIDE_LAYER_CONTROL';
export const HIDE_VIEW_CONTROL = 'HIDE_VIEW_CONTROL';
export const SET_WAITING_FOR_READY_HIDDEN_LAYERS = 'SET_WAITING_FOR_READY_HIDDEN_LAYERS';
// End temporary redundancy
import {
SET_SELECTED_LAYER,
SET_TRANSIENT_LAYER,
UPDATE_LAYER_ORDER,
ADD_LAYER,
SET_LAYER_ERROR_STATUS,
ADD_WAITING_FOR_MAP_READY_LAYER,
CLEAR_WAITING_FOR_MAP_READY_LAYER_LIST,
REMOVE_LAYER,
SET_LAYER_VISIBILITY,
MAP_EXTENT_CHANGED,
MAP_READY,
MAP_DESTROYED,
LAYER_DATA_LOAD_STARTED,
LAYER_DATA_LOAD_ENDED,
LAYER_DATA_LOAD_ERROR,
UPDATE_SOURCE_DATA_REQUEST,
SET_JOINS,
SET_QUERY,
TRIGGER_REFRESH_TIMER,
UPDATE_LAYER_PROP,
UPDATE_LAYER_STYLE,
SET_LAYER_STYLE_META,
UPDATE_SOURCE_PROP,
SET_REFRESH_CONFIG,
SET_MOUSE_COORDINATES,
CLEAR_MOUSE_COORDINATES,
SET_GOTO,
CLEAR_GOTO,
TRACK_CURRENT_LAYER_STATE,
ROLLBACK_TO_TRACKED_LAYER_STATE,
REMOVE_TRACKED_LAYER_STATE,
SET_OPEN_TOOLTIPS,
UPDATE_DRAW_STATE,
SET_SCROLL_ZOOM,
SET_MAP_INIT_ERROR,
SET_INTERACTIVE,
DISABLE_TOOLTIP_CONTROL,
HIDE_TOOLBAR_OVERLAY,
HIDE_LAYER_CONTROL,
HIDE_VIEW_CONTROL,
SET_WAITING_FOR_READY_HIDDEN_LAYERS,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../plugins/maps/public/actions/map_actions';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
export * from '../../../../../plugins/maps/public/actions/map_actions';

function getLayerLoadingCallbacks(dispatch, getState, layerId) {
return {
Expand Down
28 changes: 15 additions & 13 deletions x-pack/legacy/plugins/maps/public/actions/ui_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@
* you may not use this file except in compliance with the Elastic License.
*/

// NP Migration
// Temporarily redundant with x-pack/plugins/maps/public/actions/ui_actions.js
export const UPDATE_FLYOUT = 'UPDATE_FLYOUT';
export const CLOSE_SET_VIEW = 'CLOSE_SET_VIEW';
export const OPEN_SET_VIEW = 'OPEN_SET_VIEW';
export const SET_IS_LAYER_TOC_OPEN = 'SET_IS_LAYER_TOC_OPEN';
export const SET_FULL_SCREEN = 'SET_FULL_SCREEN';
export const SET_READ_ONLY = 'SET_READ_ONLY';
export const SET_OPEN_TOC_DETAILS = 'SET_OPEN_TOC_DETAILS';
export const SHOW_TOC_DETAILS = 'SHOW_TOC_DETAILS';
export const HIDE_TOC_DETAILS = 'HIDE_TOC_DETAILS';
export const UPDATE_INDEXING_STAGE = 'UPDATE_INDEXING_STAGE';
// End temporary redundancy
import {
UPDATE_FLYOUT,
CLOSE_SET_VIEW,
OPEN_SET_VIEW,
SET_IS_LAYER_TOC_OPEN,
SET_FULL_SCREEN,
SET_READ_ONLY,
SET_OPEN_TOC_DETAILS,
SHOW_TOC_DETAILS,
HIDE_TOC_DETAILS,
UPDATE_INDEXING_STAGE,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../plugins/maps/public/actions/ui_actions';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
export * from '../../../../../plugins/maps/public/actions/ui_actions';

export function exitFullScreen() {
return {
Expand Down
Loading

0 comments on commit 25ec8f1

Please sign in to comment.