mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Typescript map embeddable (#61264)
* typescript map embeddable * Address code review comments and update some usages in SIEM and uptime to the new types * More clean up - carry over some of the SIEM types to maps for render tool tip * Address more review comments
This commit is contained in:
parent
207428a332
commit
65452bddf9
24 changed files with 353 additions and 111 deletions
|
@ -4,8 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
// @ts-ignore
|
||||
import { MAP_SAVED_OBJECT_TYPE } from '../../../maps/common/constants';
|
||||
import { MAP_SAVED_OBJECT_TYPE } from '../../../../../plugins/maps/public';
|
||||
import { VISUALIZE_EMBEDDABLE_TYPE } from '../../../../../../src/legacy/core_plugins/visualizations/public';
|
||||
import { LENS_EMBEDDABLE_TYPE } from '../../../../../plugins/lens/common/constants';
|
||||
import { SEARCH_EMBEDDABLE_TYPE } from '../../../../../../src/legacy/core_plugins/kibana/public/discover/np_ready/embeddable/constants';
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
/* eslint-disable @typescript-eslint/consistent-type-definitions */
|
||||
|
||||
import { Filter, Query } from 'src/plugins/data/public';
|
||||
import { AnyAction } from 'redux';
|
||||
import { LAYER_TYPE } from '../../common/constants';
|
||||
import { DataMeta, MapFilters } from '../../common/descriptor_types';
|
||||
|
||||
|
@ -24,3 +26,45 @@ export function updateSourceProp(
|
|||
value: unknown,
|
||||
newLayerType?: LAYER_TYPE
|
||||
): void;
|
||||
|
||||
export interface MapCenter {
|
||||
lat: number;
|
||||
lon: number;
|
||||
zoom: number;
|
||||
}
|
||||
|
||||
export function setGotoWithCenter(config: MapCenter): AnyAction;
|
||||
|
||||
export function replaceLayerList(layerList: unknown[]): AnyAction;
|
||||
|
||||
export interface QueryGroup {
|
||||
filters: Filter[];
|
||||
query?: Query;
|
||||
timeFilters: unknown;
|
||||
refresh: unknown;
|
||||
}
|
||||
|
||||
export function setQuery(query: QueryGroup): AnyAction;
|
||||
|
||||
export interface RefreshConfig {
|
||||
isPaused: boolean;
|
||||
interval: number;
|
||||
}
|
||||
|
||||
export function setRefreshConfig(config: RefreshConfig): AnyAction;
|
||||
|
||||
export function disableScrollZoom(): AnyAction;
|
||||
|
||||
export function disableInteractive(): AnyAction;
|
||||
|
||||
export function disableTooltipControl(): AnyAction;
|
||||
|
||||
export function hideToolbarOverlay(): AnyAction;
|
||||
|
||||
export function hideLayerControl(): AnyAction;
|
||||
|
||||
export function hideViewControl(): AnyAction;
|
||||
|
||||
export function setHiddenLayers(hiddenLayerIds: string[]): AnyAction;
|
||||
|
||||
export function addLayerWithoutDataSync(layerDescriptor: unknown): AnyAction;
|
||||
|
|
13
x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts
vendored
Normal file
13
x-pack/legacy/plugins/maps/public/actions/ui_actions.d.ts
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* 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 { AnyAction } from 'redux';
|
||||
|
||||
export function setOpenTOCDetails(layerIds?: string[]): AnyAction;
|
||||
|
||||
export function setIsLayerTOCOpen(open: boolean): AnyAction;
|
||||
|
||||
export function setReadOnly(readOnly: boolean): AnyAction;
|
7
x-pack/legacy/plugins/maps/public/angular/get_initial_layers.d.ts
vendored
Normal file
7
x-pack/legacy/plugins/maps/public/angular/get_initial_layers.d.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export function getInitialLayers(layerListJSON?: string, initialLayers?: unknown[]): unknown[];
|
14
x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.d.ts
vendored
Normal file
14
x-pack/legacy/plugins/maps/public/connected_components/gis_map/index.d.ts
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* 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 React from 'react';
|
||||
import { Filter } from 'src/plugins/data/public';
|
||||
import { RenderToolTipContent } from '../../layers/tooltips/tooltip_property';
|
||||
|
||||
export const GisMap: React.ComponentType<{
|
||||
addFilters: ((filters: Filter[]) => void) | null;
|
||||
renderTooltipContent?: RenderToolTipContent;
|
||||
}>;
|
8
x-pack/legacy/plugins/maps/public/embeddable/index.ts
Normal file
8
x-pack/legacy/plugins/maps/public/embeddable/index.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export * from './map_embeddable';
|
||||
export * from './map_embeddable_factory';
|
|
@ -10,16 +10,29 @@ import { Provider } from 'react-redux';
|
|||
import { render, unmountComponentAtNode } from 'react-dom';
|
||||
import 'mapbox-gl/dist/mapbox-gl.css';
|
||||
|
||||
import { Embeddable } from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
|
||||
import { APPLY_FILTER_TRIGGER } from '../../../../../../src/plugins/ui_actions/public';
|
||||
import { esFilters } from '../../../../../../src/plugins/data/public';
|
||||
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { Unsubscribe } from 'redux';
|
||||
import {
|
||||
Embeddable,
|
||||
IContainer,
|
||||
EmbeddableInput,
|
||||
EmbeddableOutput,
|
||||
} from '../../../../../../src/plugins/embeddable/public';
|
||||
import { APPLY_FILTER_TRIGGER } from '../../../../../../src/plugins/ui_actions/public';
|
||||
import {
|
||||
esFilters,
|
||||
IIndexPattern,
|
||||
TimeRange,
|
||||
Filter,
|
||||
Query,
|
||||
RefreshInterval,
|
||||
} from '../../../../../../src/plugins/data/public';
|
||||
|
||||
import { GisMap } from '../connected_components/gis_map';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { createMapStore } from '../../../../../plugins/maps/public/reducers/store';
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { createMapStore, MapStore } from '../../../../../plugins/maps/public/reducers/store';
|
||||
import {
|
||||
setGotoWithCenter,
|
||||
replaceLayerList,
|
||||
|
@ -32,21 +45,72 @@ import {
|
|||
hideLayerControl,
|
||||
hideViewControl,
|
||||
setHiddenLayers,
|
||||
MapCenter,
|
||||
} from '../actions/map_actions';
|
||||
import { setReadOnly, setIsLayerTOCOpen, setOpenTOCDetails } from '../actions/ui_actions';
|
||||
import { getIsLayerTOCOpen, getOpenTOCDetails } from '../selectors/ui_selectors';
|
||||
import {
|
||||
getInspectorAdapters,
|
||||
setEventHandlers,
|
||||
EventHandlers,
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
} from '../../../../../plugins/maps/public/reducers/non_serializable_instances';
|
||||
import { getMapCenter, getMapZoom, getHiddenLayerIds } from '../selectors/map_selectors';
|
||||
import { MAP_SAVED_OBJECT_TYPE } from '../../common/constants';
|
||||
import { RenderToolTipContent } from '../layers/tooltips/tooltip_property';
|
||||
|
||||
export class MapEmbeddable extends Embeddable {
|
||||
interface MapEmbeddableConfig {
|
||||
editUrl?: string;
|
||||
indexPatterns: IIndexPattern[];
|
||||
editable: boolean;
|
||||
title?: string;
|
||||
layerList: unknown[];
|
||||
}
|
||||
|
||||
export interface MapEmbeddableInput extends EmbeddableInput {
|
||||
timeRange?: TimeRange;
|
||||
filters: Filter[];
|
||||
query?: Query;
|
||||
refresh?: unknown;
|
||||
refreshConfig: RefreshInterval;
|
||||
isLayerTOCOpen: boolean;
|
||||
openTOCDetails?: string[];
|
||||
disableTooltipControl?: boolean;
|
||||
disableInteractive?: boolean;
|
||||
hideToolbarOverlay?: boolean;
|
||||
hideLayerControl?: boolean;
|
||||
hideViewControl?: boolean;
|
||||
mapCenter?: MapCenter;
|
||||
hiddenLayers?: string[];
|
||||
hideFilterActions?: boolean;
|
||||
}
|
||||
|
||||
export interface MapEmbeddableOutput extends EmbeddableOutput {
|
||||
indexPatterns: IIndexPattern[];
|
||||
}
|
||||
|
||||
export class MapEmbeddable extends Embeddable<MapEmbeddableInput, MapEmbeddableOutput> {
|
||||
type = MAP_SAVED_OBJECT_TYPE;
|
||||
|
||||
constructor(config, initialInput, parent, renderTooltipContent, eventHandlers) {
|
||||
private _renderTooltipContent?: RenderToolTipContent;
|
||||
private _eventHandlers?: EventHandlers;
|
||||
private _layerList: unknown[];
|
||||
private _store: MapStore;
|
||||
private _subscription: Subscription;
|
||||
private _prevTimeRange?: TimeRange;
|
||||
private _prevQuery?: Query;
|
||||
private _prevRefreshConfig?: RefreshInterval;
|
||||
private _prevFilters?: Filter[];
|
||||
private _domNode?: HTMLElement;
|
||||
private _unsubscribeFromStore?: Unsubscribe;
|
||||
|
||||
constructor(
|
||||
config: MapEmbeddableConfig,
|
||||
initialInput: MapEmbeddableInput,
|
||||
parent?: IContainer,
|
||||
renderTooltipContent?: RenderToolTipContent,
|
||||
eventHandlers?: EventHandlers
|
||||
) {
|
||||
super(
|
||||
initialInput,
|
||||
{
|
||||
|
@ -70,7 +134,7 @@ export class MapEmbeddable extends Embeddable {
|
|||
return getInspectorAdapters(this._store.getState());
|
||||
}
|
||||
|
||||
onContainerStateChanged(containerState) {
|
||||
onContainerStateChanged(containerState: MapEmbeddableInput) {
|
||||
if (
|
||||
!_.isEqual(containerState.timeRange, this._prevTimeRange) ||
|
||||
!_.isEqual(containerState.query, this._prevQuery) ||
|
||||
|
@ -84,7 +148,12 @@ export class MapEmbeddable extends Embeddable {
|
|||
}
|
||||
}
|
||||
|
||||
_dispatchSetQuery({ query, timeRange, filters, refresh }) {
|
||||
_dispatchSetQuery({
|
||||
query,
|
||||
timeRange,
|
||||
filters,
|
||||
refresh,
|
||||
}: Pick<MapEmbeddableInput, 'query' | 'timeRange' | 'filters' | 'refresh'>) {
|
||||
this._prevTimeRange = timeRange;
|
||||
this._prevQuery = query;
|
||||
this._prevFilters = filters;
|
||||
|
@ -98,7 +167,7 @@ export class MapEmbeddable extends Embeddable {
|
|||
);
|
||||
}
|
||||
|
||||
_dispatchSetRefreshConfig({ refreshConfig }) {
|
||||
_dispatchSetRefreshConfig({ refreshConfig }: Pick<MapEmbeddableInput, 'refreshConfig'>) {
|
||||
this._prevRefreshConfig = refreshConfig;
|
||||
this._store.dispatch(
|
||||
setRefreshConfig({
|
||||
|
@ -113,7 +182,7 @@ export class MapEmbeddable extends Embeddable {
|
|||
* @param {HTMLElement} domNode
|
||||
* @param {ContainerState} containerState
|
||||
*/
|
||||
render(domNode) {
|
||||
render(domNode: HTMLElement) {
|
||||
this._store.dispatch(setEventHandlers(this._eventHandlers));
|
||||
this._store.dispatch(setReadOnly(true));
|
||||
this._store.dispatch(disableScrollZoom());
|
||||
|
@ -127,23 +196,22 @@ export class MapEmbeddable extends Embeddable {
|
|||
}
|
||||
|
||||
if (_.has(this.input, 'disableInteractive') && this.input.disableInteractive) {
|
||||
this._store.dispatch(disableInteractive(this.input.disableInteractive));
|
||||
this._store.dispatch(disableInteractive());
|
||||
}
|
||||
|
||||
if (_.has(this.input, 'disableTooltipControl') && this.input.disableTooltipControl) {
|
||||
this._store.dispatch(disableTooltipControl(this.input.disableTooltipControl));
|
||||
this._store.dispatch(disableTooltipControl());
|
||||
}
|
||||
|
||||
if (_.has(this.input, 'hideToolbarOverlay') && this.input.hideToolbarOverlay) {
|
||||
this._store.dispatch(hideToolbarOverlay(this.input.hideToolbarOverlay));
|
||||
this._store.dispatch(hideToolbarOverlay());
|
||||
}
|
||||
|
||||
if (_.has(this.input, 'hideLayerControl') && this.input.hideLayerControl) {
|
||||
this._store.dispatch(hideLayerControl(this.input.hideLayerControl));
|
||||
this._store.dispatch(hideLayerControl());
|
||||
}
|
||||
|
||||
if (_.has(this.input, 'hideViewControl') && this.input.hideViewControl) {
|
||||
this._store.dispatch(hideViewControl(this.input.hideViewControl));
|
||||
this._store.dispatch(hideViewControl());
|
||||
}
|
||||
|
||||
if (this.input.mapCenter) {
|
||||
|
@ -182,12 +250,12 @@ export class MapEmbeddable extends Embeddable {
|
|||
});
|
||||
}
|
||||
|
||||
async setLayerList(layerList) {
|
||||
async setLayerList(layerList: unknown[]) {
|
||||
this._layerList = layerList;
|
||||
return await this._store.dispatch(replaceLayerList(this._layerList));
|
||||
}
|
||||
|
||||
addFilters = filters => {
|
||||
addFilters = (filters: Filter[]) => {
|
||||
npStart.plugins.uiActions.executeTriggerActions(APPLY_FILTER_TRIGGER, {
|
||||
embeddable: this,
|
||||
filters,
|
||||
|
@ -213,7 +281,7 @@ export class MapEmbeddable extends Embeddable {
|
|||
this._dispatchSetQuery({
|
||||
query: this._prevQuery,
|
||||
timeRange: this._prevTimeRange,
|
||||
filters: this._prevFilters,
|
||||
filters: this._prevFilters ?? [],
|
||||
refresh: true,
|
||||
});
|
||||
}
|
||||
|
@ -222,7 +290,7 @@ export class MapEmbeddable extends Embeddable {
|
|||
const center = getMapCenter(this._store.getState());
|
||||
const zoom = getMapZoom(this._store.getState());
|
||||
|
||||
const mapCenter = this.input.mapCenter || {};
|
||||
const mapCenter = this.input.mapCenter || undefined;
|
||||
if (
|
||||
!mapCenter ||
|
||||
mapCenter.lat !== center.lat ||
|
||||
|
@ -233,7 +301,7 @@ export class MapEmbeddable extends Embeddable {
|
|||
mapCenter: {
|
||||
lat: center.lat,
|
||||
lon: center.lon,
|
||||
zoom: zoom,
|
||||
zoom,
|
||||
},
|
||||
});
|
||||
}
|
|
@ -8,12 +8,16 @@ import _ from 'lodash';
|
|||
import chrome from 'ui/chrome';
|
||||
import { capabilities } from 'ui/capabilities';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
import { SavedObjectLoader } from 'src/plugins/saved_objects/public';
|
||||
import { IIndexPattern } from 'src/plugins/data/public';
|
||||
import {
|
||||
EmbeddableFactory,
|
||||
ErrorEmbeddable,
|
||||
IContainer,
|
||||
} 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 { MapEmbeddable, MapEmbeddableInput } from './map_embeddable';
|
||||
import { getIndexPatternService } from '../kibana_services';
|
||||
|
||||
import { createMapPath, MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants';
|
||||
|
@ -25,7 +29,11 @@ import { getInitialLayers } from '../angular/get_initial_layers';
|
|||
import { mergeInputWithSavedMap } from './merge_input_with_saved_map';
|
||||
import '../angular/services/gis_map_saved_object_loader';
|
||||
import { bindSetupCoreAndPlugins, bindStartCoreAndPlugins } from '../plugin';
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
import { RenderToolTipContent } from '../layers/tooltips/tooltip_property';
|
||||
import {
|
||||
EventHandlers,
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
} from '../../../../../plugins/maps/public/reducers/non_serializable_instances';
|
||||
|
||||
export class MapEmbeddableFactory extends EmbeddableFactory {
|
||||
type = MAP_SAVED_OBJECT_TYPE;
|
||||
|
@ -44,8 +52,9 @@ export class MapEmbeddableFactory extends EmbeddableFactory {
|
|||
bindSetupCoreAndPlugins(npSetup.core, npSetup.plugins);
|
||||
bindStartCoreAndPlugins(npStart.core, npStart.plugins);
|
||||
}
|
||||
isEditable() {
|
||||
return capabilities.get().maps.save;
|
||||
|
||||
async isEditable() {
|
||||
return capabilities.get().maps.save as boolean;
|
||||
}
|
||||
|
||||
// Not supported yet for maps types.
|
||||
|
@ -59,12 +68,12 @@ export class MapEmbeddableFactory extends EmbeddableFactory {
|
|||
});
|
||||
}
|
||||
|
||||
async _getIndexPatterns(layerList) {
|
||||
async _getIndexPatterns(layerList: unknown[]): Promise<IIndexPattern[]> {
|
||||
// Need to extract layerList from store to get queryable index pattern ids
|
||||
const store = createMapStore();
|
||||
let queryableIndexPatternIds;
|
||||
try {
|
||||
layerList.forEach(layerDescriptor => {
|
||||
layerList.forEach((layerDescriptor: unknown) => {
|
||||
store.dispatch(addLayerWithoutDataSync(layerDescriptor));
|
||||
});
|
||||
queryableIndexPatternIds = getQueryableUniqueIndexPatternIds(store.getState());
|
||||
|
@ -86,16 +95,20 @@ export class MapEmbeddableFactory extends EmbeddableFactory {
|
|||
}
|
||||
});
|
||||
const indexPatterns = await Promise.all(promises);
|
||||
return _.compact(indexPatterns);
|
||||
return _.compact(indexPatterns) as IIndexPattern[];
|
||||
}
|
||||
|
||||
async _fetchSavedMap(savedObjectId) {
|
||||
async _fetchSavedMap(savedObjectId: string) {
|
||||
const $injector = await chrome.dangerouslyGetActiveInjector();
|
||||
const savedObjectLoader = $injector.get('gisMapSavedObjectLoader');
|
||||
const savedObjectLoader = $injector.get<SavedObjectLoader>('gisMapSavedObjectLoader');
|
||||
return await savedObjectLoader.get(savedObjectId);
|
||||
}
|
||||
|
||||
async createFromSavedObject(savedObjectId, input, parent) {
|
||||
async createFromSavedObject(
|
||||
savedObjectId: string,
|
||||
input: MapEmbeddableInput,
|
||||
parent?: IContainer
|
||||
) {
|
||||
const savedMap = await this._fetchSavedMap(savedObjectId);
|
||||
const layerList = getInitialLayers(savedMap.layerListJSON);
|
||||
const indexPatterns = await this._getIndexPatterns(layerList);
|
||||
|
@ -106,7 +119,7 @@ export class MapEmbeddableFactory extends EmbeddableFactory {
|
|||
title: savedMap.title,
|
||||
editUrl: chrome.addBasePath(createMapPath(savedObjectId)),
|
||||
indexPatterns,
|
||||
editable: this.isEditable(),
|
||||
editable: await this.isEditable(),
|
||||
},
|
||||
input,
|
||||
parent
|
||||
|
@ -125,7 +138,13 @@ export class MapEmbeddableFactory extends EmbeddableFactory {
|
|||
return embeddable;
|
||||
}
|
||||
|
||||
async createFromState(state, input, parent, renderTooltipContent, eventHandlers) {
|
||||
async createFromState(
|
||||
state: { title?: string; layerList?: unknown[] },
|
||||
input: MapEmbeddableInput,
|
||||
parent: IContainer,
|
||||
renderTooltipContent: RenderToolTipContent,
|
||||
eventHandlers: EventHandlers
|
||||
) {
|
||||
const layerList = state && state.layerList ? state.layerList : getInitialLayers();
|
||||
const indexPatterns = await this._getIndexPatterns(layerList);
|
||||
|
||||
|
@ -133,7 +152,6 @@ export class MapEmbeddableFactory extends EmbeddableFactory {
|
|||
{
|
||||
layerList,
|
||||
title: state && state.title ? state.title : '',
|
||||
editUrl: null,
|
||||
indexPatterns,
|
||||
editable: false,
|
||||
},
|
||||
|
@ -144,7 +162,7 @@ export class MapEmbeddableFactory extends EmbeddableFactory {
|
|||
);
|
||||
}
|
||||
|
||||
async create(input) {
|
||||
async create(input: MapEmbeddableInput) {
|
||||
window.location.href = chrome.addBasePath(createMapPath(''));
|
||||
return new ErrorEmbeddable(
|
||||
'Maps can only be created with createFromSavedObject or createFromState',
|
12
x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.d.ts
vendored
Normal file
12
x-pack/legacy/plugins/maps/public/embeddable/merge_input_with_saved_map.d.ts
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* 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 { MapEmbeddableInput } from './map_embeddable';
|
||||
|
||||
export function mergeInputWithSavedMap(
|
||||
input: MapEmbeddableInput,
|
||||
savedmap: unknown
|
||||
): Partial<MapEmbeddableInput>;
|
|
@ -25,3 +25,6 @@ import { MapsPlugin } from './plugin';
|
|||
export const plugin = (initializerContext: PluginInitializerContext) => {
|
||||
return new MapsPlugin();
|
||||
};
|
||||
|
||||
export { RenderTooltipContentParams, ITooltipProperty } from './layers/tooltips/tooltip_property';
|
||||
export { MapEmbeddable, MapEmbeddableInput } from './embeddable';
|
||||
|
|
23
x-pack/legacy/plugins/maps/public/kibana_services.d.ts
vendored
Normal file
23
x-pack/legacy/plugins/maps/public/kibana_services.d.ts
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* 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 { IIndexPattern } from 'src/plugins/data/public';
|
||||
|
||||
export function getIndexPatternService(): {
|
||||
get: (id: string) => IIndexPattern | undefined;
|
||||
};
|
||||
|
||||
export function setLicenseId(args: unknown): void;
|
||||
export function setInspector(args: unknown): void;
|
||||
export function setFileUpload(args: unknown): void;
|
||||
export function setIndexPatternSelect(args: unknown): void;
|
||||
export function setHttp(args: unknown): void;
|
||||
export function setTimeFilter(args: unknown): void;
|
||||
export function setUiSettings(args: unknown): void;
|
||||
export function setInjectedVarFunc(args: unknown): void;
|
||||
export function setToasts(args: unknown): void;
|
||||
export function setIndexPatternService(args: unknown): void;
|
||||
export function setAutocompleteService(args: unknown): void;
|
|
@ -16,10 +16,37 @@ export interface ITooltipProperty {
|
|||
getESFilters(): Promise<PhraseFilter[]>;
|
||||
}
|
||||
|
||||
export interface MapFeature {
|
||||
id: number;
|
||||
layerId: string;
|
||||
}
|
||||
|
||||
export interface LoadFeatureProps {
|
||||
layerId: string;
|
||||
featureId: number;
|
||||
}
|
||||
|
||||
export interface FeatureGeometry {
|
||||
coordinates: [number];
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface RenderTooltipContentParams {
|
||||
addFilters(filter: object): void;
|
||||
closeTooltip(): void;
|
||||
features: MapFeature[];
|
||||
isLocked: boolean;
|
||||
getLayerName(layerId: string): Promise<string>;
|
||||
loadFeatureProperties({ layerId, featureId }: LoadFeatureProps): Promise<ITooltipProperty[]>;
|
||||
loadFeatureGeometry({ layerId, featureId }: LoadFeatureProps): FeatureGeometry;
|
||||
}
|
||||
|
||||
export type RenderToolTipContent = (params: RenderTooltipContentParams) => JSX.Element;
|
||||
|
||||
export class TooltipProperty implements ITooltipProperty {
|
||||
private readonly _propertyKey: string;
|
||||
private readonly _propertyName: string;
|
||||
private readonly _rawValue: string | undefined;
|
||||
private readonly _propertyName: string;
|
||||
|
||||
constructor(propertyKey: string, propertyName: string, rawValue: string | undefined) {
|
||||
this._propertyKey = propertyKey;
|
||||
|
|
|
@ -24,7 +24,6 @@ import {
|
|||
setToasts,
|
||||
setIndexPatternService,
|
||||
setAutocompleteService,
|
||||
// @ts-ignore
|
||||
} from './kibana_services';
|
||||
// @ts-ignore
|
||||
import { setInjectedVarFunc as npSetInjectedVarFunc } from '../../../../plugins/maps/public/kibana_services'; // eslint-disable-line @kbn/eslint/no-restricted-paths
|
||||
|
|
16
x-pack/legacy/plugins/maps/public/selectors/map_selectors.d.ts
vendored
Normal file
16
x-pack/legacy/plugins/maps/public/selectors/map_selectors.d.ts
vendored
Normal file
|
@ -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 { AnyAction } from 'redux';
|
||||
import { MapCenter } from '../actions/map_actions';
|
||||
|
||||
export function getHiddenLayerIds(state: unknown): string[];
|
||||
|
||||
export function getMapZoom(state: unknown): number;
|
||||
|
||||
export function getMapCenter(state: unknown): MapCenter;
|
||||
|
||||
export function getQueryableUniqueIndexPatternIds(state: unknown): string[];
|
9
x-pack/legacy/plugins/maps/public/selectors/ui_selectors.d.ts
vendored
Normal file
9
x-pack/legacy/plugins/maps/public/selectors/ui_selectors.d.ts
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export function getOpenTOCDetails(state: unknown): string[];
|
||||
|
||||
export function getIsLayerTOCOpen(state: unknown): boolean;
|
|
@ -22,7 +22,8 @@ import { createEmbeddable, findMatchingIndexPatterns } from './embedded_map_help
|
|||
import { IndexPatternsMissingPrompt } from './index_patterns_missing_prompt';
|
||||
import { MapToolTip } from './map_tool_tip/map_tool_tip';
|
||||
import * as i18n from './translations';
|
||||
import { MapEmbeddable, SetQuery } from './types';
|
||||
import { SetQuery } from './types';
|
||||
import { MapEmbeddable } from '../../../../../plugins/maps/public';
|
||||
import { Query, Filter } from '../../../../../../../src/plugins/data/public';
|
||||
import { useKibana, useUiSetting$ } from '../../lib/kibana';
|
||||
import { getSavedObjectFinder } from '../../../../../../../src/plugins/saved_objects/public';
|
||||
|
|
|
@ -9,10 +9,10 @@ import React from 'react';
|
|||
import { OutPortal, PortalNode } from 'react-reverse-portal';
|
||||
import minimatch from 'minimatch';
|
||||
import { ViewMode } from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
|
||||
import { IndexPatternMapping, MapEmbeddable, RenderTooltipContentParams, SetQuery } from './types';
|
||||
import { IndexPatternMapping, SetQuery } from './types';
|
||||
import { getLayerList } from './map_config';
|
||||
// @ts-ignore Missing type defs as maps moves to Typescript
|
||||
import { MAP_SAVED_OBJECT_TYPE } from '../../../../maps/common/constants';
|
||||
import { MAP_SAVED_OBJECT_TYPE } from '../../../../../../plugins/maps/public';
|
||||
import { MapEmbeddable, RenderTooltipContentParams } from '../../../../maps/public';
|
||||
import * as i18n from './translations';
|
||||
import { Query, Filter } from '../../../../../../../src/plugins/data/public';
|
||||
import { EmbeddableStart } from '../../../../../../../src/plugins/embeddable/public';
|
||||
|
|
|
@ -64,7 +64,7 @@ export const MapToolTipComponent = ({
|
|||
getLayerName(layerId),
|
||||
]);
|
||||
|
||||
setFeatureProps(featureProperties);
|
||||
setFeatureProps((featureProperties as unknown) as FeatureProperty[]);
|
||||
setFeatureGeometry(featureGeo);
|
||||
setLayerName(layerNameString);
|
||||
} catch (e) {
|
||||
|
|
|
@ -4,26 +4,8 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { TimeRange } from 'src/plugins/data/public';
|
||||
import {
|
||||
EmbeddableInput,
|
||||
EmbeddableOutput,
|
||||
IEmbeddable,
|
||||
} from '../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
|
||||
import { RenderTooltipContentParams } from '../../../../maps/public';
|
||||
import { inputsModel } from '../../store/inputs';
|
||||
import { Query, Filter } from '../../../../../../../src/plugins/data/public';
|
||||
|
||||
export interface MapEmbeddableInput extends EmbeddableInput {
|
||||
filters: Filter[];
|
||||
query: Query;
|
||||
refreshConfig: {
|
||||
isPaused: boolean;
|
||||
interval: number;
|
||||
};
|
||||
timeRange?: TimeRange;
|
||||
}
|
||||
|
||||
export type MapEmbeddable = IEmbeddable<MapEmbeddableInput, EmbeddableOutput>;
|
||||
|
||||
export interface IndexPatternMapping {
|
||||
title: string;
|
||||
|
@ -73,14 +55,4 @@ export interface FeatureGeometry {
|
|||
type: string;
|
||||
}
|
||||
|
||||
export interface RenderTooltipContentParams {
|
||||
addFilters(filter: object): void;
|
||||
closeTooltip(): void;
|
||||
features: MapFeature[];
|
||||
isLocked: boolean;
|
||||
getLayerName(layerId: string): Promise<string>;
|
||||
loadFeatureProperties({ layerId, featureId }: LoadFeatureProps): Promise<FeatureProperty[]>;
|
||||
loadFeatureGeometry({ layerId, featureId }: LoadFeatureProps): FeatureGeometry;
|
||||
}
|
||||
|
||||
export type MapToolTipProps = Partial<RenderTooltipContentParams>;
|
||||
|
|
|
@ -8,13 +8,13 @@ import React, { useEffect, useState, useContext, useRef } from 'react';
|
|||
import uuid from 'uuid';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { ViewMode } from '../../../../../../../../../src/plugins/embeddable/public';
|
||||
import { start } from '../../../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public/legacy';
|
||||
import * as i18n from './translations';
|
||||
// @ts-ignore
|
||||
import { MAP_SAVED_OBJECT_TYPE } from '../../../../../../maps/common/constants';
|
||||
import { MapEmbeddable, MapEmbeddableInput } from '../../../../../../maps/public';
|
||||
import { MAP_SAVED_OBJECT_TYPE } from '../../../../../../../../plugins/maps/public';
|
||||
import { Location } from '../../../../../common/runtime_types';
|
||||
|
||||
import { MapEmbeddable } from './types';
|
||||
import { getLayerList } from './map_config';
|
||||
import { UptimeThemeContext } from '../../../../contexts';
|
||||
|
||||
|
@ -49,7 +49,7 @@ export const EmbeddedMap = React.memo(({ upPoints, downPoints }: EmbeddedMapProp
|
|||
const embeddableRoot: React.RefObject<HTMLDivElement> = useRef<HTMLDivElement>(null);
|
||||
const factory = start.getEmbeddableFactory(MAP_SAVED_OBJECT_TYPE);
|
||||
|
||||
const input = {
|
||||
const input: MapEmbeddableInput = {
|
||||
id: uuid.v4(),
|
||||
filters: [],
|
||||
hidePanelTitles: true,
|
||||
|
@ -57,7 +57,7 @@ export const EmbeddedMap = React.memo(({ upPoints, downPoints }: EmbeddedMapProp
|
|||
value: 0,
|
||||
pause: false,
|
||||
},
|
||||
viewMode: 'view',
|
||||
viewMode: ViewMode.VIEW,
|
||||
isLayerTOCOpen: false,
|
||||
hideFilterActions: true,
|
||||
// Zoom Lat/Lon values are set to make sure map is in center in the panel
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* 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 { Query } from 'src/plugins/data/common';
|
||||
import { TimeRange } from 'src/plugins/data/public';
|
||||
import {
|
||||
EmbeddableInput,
|
||||
EmbeddableOutput,
|
||||
IEmbeddable,
|
||||
} from '../../../../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
|
||||
|
||||
import { Filter } from '../../../../../../../../../src/plugins/data/public';
|
||||
|
||||
export interface MapEmbeddableInput extends EmbeddableInput {
|
||||
filters: Filter[];
|
||||
query: Query;
|
||||
refreshConfig: {
|
||||
isPaused: boolean;
|
||||
interval: number;
|
||||
};
|
||||
timeRange?: TimeRange;
|
||||
}
|
||||
|
||||
export interface CustomProps {
|
||||
setLayerList: Function;
|
||||
}
|
||||
|
||||
export type MapEmbeddable = IEmbeddable<MapEmbeddableInput, EmbeddableOutput> & CustomProps;
|
|
@ -10,3 +10,5 @@ import { MapsPlugin, MapsPluginSetup, MapsPluginStart } from './plugin';
|
|||
export const plugin: PluginInitializer<MapsPluginSetup, MapsPluginStart> = () => {
|
||||
return new MapsPlugin();
|
||||
};
|
||||
|
||||
export { MAP_SAVED_OBJECT_TYPE } from '../common/constants';
|
||||
|
|
27
x-pack/plugins/maps/public/reducers/non_serializable_instances.d.ts
vendored
Normal file
27
x-pack/plugins/maps/public/reducers/non_serializable_instances.d.ts
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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 { Adapters } from 'src/plugins/inspector/public';
|
||||
import { AnyAction } from 'redux';
|
||||
|
||||
interface EventHandlers {
|
||||
/**
|
||||
* Take action on data load.
|
||||
*/
|
||||
onDataLoad: (layerId: string, dataId: string) => void;
|
||||
/**
|
||||
* Take action on data load end.
|
||||
*/
|
||||
onDataLoadEnd: (layerId: string, dataId: string, resultMeta: object) => void;
|
||||
/**
|
||||
* Take action on data load error.
|
||||
*/
|
||||
onDataLoadError: (layerId: string, dataId: string, errorMessage: string) => void;
|
||||
}
|
||||
|
||||
export function setEventHandlers(eventHandlers?: EventHandlers): AnyAction;
|
||||
|
||||
export function getInspectorAdapters(args: unknown): Adapters | undefined;
|
11
x-pack/plugins/maps/public/reducers/store.d.ts
vendored
Normal file
11
x-pack/plugins/maps/public/reducers/store.d.ts
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* 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 { Store } from 'redux';
|
||||
|
||||
export type MapStore = Store;
|
||||
|
||||
export function createMapStore(): MapStore;
|
Loading…
Add table
Add a link
Reference in a new issue