Skip to content

Commit

Permalink
added options to disable zoom, hide tool tips, widgets/overlays in em…
Browse files Browse the repository at this point in the history
…beddable maps
  • Loading branch information
shahzad31 committed Nov 14, 2019
1 parent 0af6ea3 commit 47b971b
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 185 deletions.
23 changes: 13 additions & 10 deletions src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface Props {
notifications: CoreStart['notifications'];
inspector: InspectorStartContract;
SavedObjectFinder: React.ComponentType<any>;
hideHeader: boolean;
}

interface State {
Expand Down Expand Up @@ -164,16 +165,18 @@ export class EmbeddablePanel extends React.Component<Props, State> {
role="figure"
aria-labelledby={headerId}
>
<PanelHeader
getActionContextMenuPanel={this.getActionContextMenuPanel}
hidePanelTitles={this.state.hidePanelTitles}
isViewMode={viewOnlyMode}
closeContextMenu={this.state.closeContextMenu}
title={title}
badges={this.state.badges}
embeddable={this.props.embeddable}
headerId={headerId}
/>
{!this.props.hideHeader && (
<PanelHeader
getActionContextMenuPanel={this.getActionContextMenuPanel}
hidePanelTitles={this.state.hidePanelTitles}
isViewMode={viewOnlyMode}
closeContextMenu={this.state.closeContextMenu}
title={title}
badges={this.state.badges}
embeddable={this.props.embeddable}
headerId={headerId}
/>
)}
<div className="embPanel__content" ref={this.embeddableRoot} />
</EuiPanel>
);
Expand Down
10 changes: 10 additions & 0 deletions x-pack/legacy/plugins/maps/public/actions/map_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export const SET_TOOLTIP_STATE = 'SET_TOOLTIP_STATE';
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_ZOOM = 'SET_ZOOM';
export const DISABLE_TOOLTIP_CONTROL = 'DISABLE_TOOLTIP_CONTROL';

function getLayerLoadingCallbacks(dispatch, layerId) {
return {
Expand Down Expand Up @@ -829,3 +831,11 @@ export function updateDrawState(drawState) {
});
};
}

export function disableZoom() {
return { type: SET_ZOOM, disableZoom: true };
}

export function disableTooltipControl() {
return { type: DISABLE_TOOLTIP_CONTROL, disableTooltipControl: true };
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ import uuid from 'uuid/v4';
const RENDER_COMPLETE_EVENT = 'renderComplete';

export class GisMap extends Component {

state = {
isInitialLoadRenderTimeoutComplete: false,
domId: uuid(),
geoFields: [],
}
};

componentDidMount() {
this._isMounted = true;
Expand Down Expand Up @@ -65,9 +64,9 @@ export class GisMap extends Component {
if (el) {
el.dispatchEvent(new CustomEvent(RENDER_COMPLETE_EVENT, { bubbles: true }));
}
}
};

_loadGeoFields = async (nextIndexPatternIds) => {
_loadGeoFields = async nextIndexPatternIds => {
if (_.isEqual(nextIndexPatternIds, this._prevIndexPatternIds)) {
// all ready loaded index pattern ids
return;
Expand All @@ -78,19 +77,22 @@ export class GisMap extends Component {
const geoFields = [];
try {
const indexPatterns = await getIndexPatternsFromIds(nextIndexPatternIds);
indexPatterns.forEach((indexPattern) => {
indexPatterns.forEach(indexPattern => {
indexPattern.fields.forEach(field => {
if (field.type === ES_GEO_FIELD_TYPE.GEO_POINT || field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE) {
if (
field.type === ES_GEO_FIELD_TYPE.GEO_POINT ||
field.type === ES_GEO_FIELD_TYPE.GEO_SHAPE
) {
geoFields.push({
geoFieldName: field.name,
geoFieldType: field.type,
indexPatternTitle: indexPattern.title,
indexPatternId: indexPattern.id
indexPatternId: indexPattern.id,
});
}
});
});
} catch(e) {
} catch (e) {
// swallow errors.
// the Layer-TOC will indicate which layers are disfunctional on a per-layer basis
}
Expand All @@ -100,7 +102,7 @@ export class GisMap extends Component {
}

this.setState({ geoFields });
}
};

_setRefreshTimer = () => {
const { isPaused, interval } = this.props.refreshConfig;
Expand All @@ -116,12 +118,9 @@ export class GisMap extends Component {
this._clearRefreshTimer();

if (!isPaused && interval > 0) {
this.refreshTimerId = setInterval(
() => {
this.props.triggerRefreshTimer();
},
interval
);
this.refreshTimerId = setInterval(() => {
this.props.triggerRefreshTimer();
}, interval);
}
};

Expand All @@ -134,16 +133,13 @@ export class GisMap extends Component {
// Mapbox does not provide any feedback when rendering is complete.
// Temporary solution is just to wait set period of time after data has loaded.
_startInitialLoadRenderTimer = () => {
setTimeout(
() => {
if (this._isMounted) {
this.setState({ isInitialLoadRenderTimeoutComplete: true });
this._onInitialLoadRenderComplete();
}
},
5000
);
}
setTimeout(() => {
if (this._isMounted) {
this.setState({ isInitialLoadRenderTimeoutComplete: true });
this._onInitialLoadRenderComplete();
}
}, 5000);
};

render() {
const {
Expand All @@ -164,14 +160,12 @@ export class GisMap extends Component {
<div data-render-complete data-shared-item>
<EuiCallOut
title={i18n.translate('xpack.maps.map.initializeErrorTitle', {
defaultMessage: 'Unable to initialize map'
defaultMessage: 'Unable to initialize map',
})}
color="danger"
iconType="cross"
>
<p>
{mapInitError}
</p>
<p>{mapInitError}</p>
</EuiCallOut>
</div>
);
Expand All @@ -183,21 +177,15 @@ export class GisMap extends Component {
currentPanel = null;
} else if (addLayerVisible) {
currentPanelClassName = 'mapMapLayerPanel-isVisible';
currentPanel = <AddLayerPanel/>;
currentPanel = <AddLayerPanel />;
} else if (layerDetailsVisible) {
currentPanelClassName = 'mapMapLayerPanel-isVisible';
currentPanel = (
<LayerPanel/>
);
currentPanel = <LayerPanel />;
}

let exitFullScreenButton;
if (isFullScreen) {
exitFullScreenButton = (
<ExitFullScreenButton
onExitFullScreenMode={exitFullScreen}
/>
);
exitFullScreenButton = <ExitFullScreenButton onExitFullScreenMode={exitFullScreen} />;
}
return (
<EuiFlexGroup
Expand All @@ -213,11 +201,10 @@ export class GisMap extends Component {
geoFields={this.state.geoFields}
renderTooltipContent={renderTooltipContent}
/>
<ToolbarOverlay
addFilters={addFilters}
geoFields={this.state.geoFields}
/>
<WidgetOverlay/>
{!this.props.hideToolbarOverlay && (
<ToolbarOverlay addFilters={addFilters} geoFields={this.state.geoFields} />
)}
{!this.props.hideWidgetOverlay && <WidgetOverlay />}
</EuiFlexItem>

<EuiFlexItem className={`mapMapLayerPanel ${currentPanelClassName}`} grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import {
getLayerList,
getMapReady,
getGoto,
getScrollZoom
getScrollZoom,
isZoomDisabled,
isTooltipControlDisabled,
} from '../../../selectors/map_selectors';
import { getInspectorAdapters } from '../../../reducers/non_serializable_instances';

Expand All @@ -31,7 +33,9 @@ function mapStateToProps(state = {}) {
goto: getGoto(state),
inspectorAdapters: getInspectorAdapters(state),
tooltipState: getTooltipState(state),
scrollZoom: getScrollZoom(state)
scrollZoom: getScrollZoom(state),
disableZoom: isZoomDisabled(state),
disableTooltipControl: isTooltipControlDisabled(state)
};
}

Expand Down
Loading

0 comments on commit 47b971b

Please sign in to comment.