Skip to content

Commit

Permalink
Add config layer basic component (#54)
Browse files Browse the repository at this point in the history
Signed-off-by: Junqiu Lei <[email protected]>
  • Loading branch information
junqiu-lei authored Oct 5, 2022
1 parent 74f01cb commit 9d8b5a1
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 79 deletions.
7 changes: 7 additions & 0 deletions src/plugins/maps_dashboards/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ export const MAP_INITIAL_STATE = {
export const APP_PATH = {
CREATE_MAP: '/create-map',
};

export enum LAYER_TYPE {
BASE_MAP = 'base map',
CLUSTER_MAP = 'cluster',
CHOROPLETH_MAP = 'choropleth',
WEB_MAP_SERVICE = 'wms',
}
5 changes: 5 additions & 0 deletions src/plugins/maps_dashboards/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

.addLayer__button {
padding: $euiSizeM $euiSizeM
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,35 @@ import {
EuiKeyPadMenuItem,
} from '@elastic/eui';
import './add_layer_panel.scss';
import { LAYER_TYPE } from '../../../common';

export const AddLayerPanel = () => {
// TODO: replace it once layers model ready
const layers = ['Base maps', 'Region', 'Coordinate', 'WMS'];
interface Props {
setIsLayerConfigVisible: Function;
}

const selectLayers = layers.map((layerItem, index) => {
export const AddLayerPanel = ({ setIsLayerConfigVisible }: Props) => {
const [isAddNewLayerModalVisible, setIsAddNewLayerModalVisible] = useState(false);

const availableLayers = Object.values(LAYER_TYPE).map((layerItem, index) => {
return (
<EuiFlexItem key={index}>
<EuiKeyPadMenuItem label={`${layerItem}`} aria-label={`${layerItem}`}>
<EuiIcon type="visMapRegion" size="xxl" color="primary" />
<EuiIcon
type="visMapRegion"
size="xxl"
color="primary"
onClick={() => {
setIsAddNewLayerModalVisible(false);
setIsLayerConfigVisible(true);
}}
/>
</EuiKeyPadMenuItem>
</EuiFlexItem>
);
});

const [isModalVisible, setIsModalVisible] = useState(false);

const closeModal = () => setIsModalVisible(false);
const showModal = () => setIsModalVisible(true);
const closeModal = () => setIsAddNewLayerModalVisible(false);
const showModal = () => setIsAddNewLayerModalVisible(true);

const tabs = [
{
Expand All @@ -46,7 +56,7 @@ export const AddLayerPanel = () => {
content: (
<Fragment>
<EuiSpacer />
<EuiFlexGroup gutterSize="l">{selectLayers}</EuiFlexGroup>
<EuiFlexGroup gutterSize="l">{availableLayers}</EuiFlexGroup>
</Fragment>
),
},
Expand All @@ -71,7 +81,7 @@ export const AddLayerPanel = () => {
+ Add layer
</EuiButton>
</EuiFlexItem>
{isModalVisible && (
{isAddNewLayerModalVisible && (
<EuiModal onClose={closeModal}>
<EuiModalHeader>
<EuiModalHeaderTitle>
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/maps_dashboards/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import React from 'react';
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
import { I18nProvider } from '@osd/i18n/react';
import { MapsList, Map } from '../pages/';
import { MapsList } from './maps_list';
import { MapContainer } from './map_container';
import { CoreStart } from '../../../../src/core/public';
import { NavigationPublicPluginStart } from '../../../../src/plugins/navigation/public';
import { APP_PATH } from '../../common/index';
Expand All @@ -25,7 +26,7 @@ export const MapsDashboardsApp = ({ basename, notifications, http }: MapsDashboa
<I18nProvider>
<div>
<Switch>
<Route path={APP_PATH.CREATE_MAP} render={(props) => <Map />} />
<Route path={APP_PATH.CREATE_MAP} render={(props) => <MapContainer />} />
<Route
exact
path="/"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { LayerConfigPanel } from './layer_config_panel';
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import {
EuiButton,
EuiFlyout,
EuiFlyoutBody,
EuiFlyoutFooter,
EuiFlyoutHeader,
EuiCodeBlock,
EuiTitle,
} from '@elastic/eui';
import { ILayerConfig } from '../../model/ILayerConfig';

interface Props {
setIsLayerConfigVisible: Function;
selectedLayerConfig: ILayerConfig;
}

export const LayerConfigPanel = ({ setIsLayerConfigVisible, selectedLayerConfig }: Props) => {
return (
<EuiFlyout type="push" size="s" onClose={() => setIsLayerConfigVisible(false)}>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="m">
<h2>{selectedLayerConfig.name}</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiCodeBlock
language="js"
fontSize="m"
paddingSize="m"
color="dark"
overflowHeight={300}
isCopyable
>
{JSON.stringify(selectedLayerConfig)}
</EuiCodeBlock>
</EuiFlyoutBody>
<EuiFlyoutFooter>
<EuiButton onClick={() => setIsLayerConfigVisible(false)}>Close</EuiButton>
</EuiFlyoutFooter>
</EuiFlyout>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.layerControlPanel {
.layerControlPanel--show {
pointer-events: auto;

width: $euiSizeL * 10;

.layerControlPanel__title {
Expand All @@ -12,3 +11,13 @@
width: $euiSizeL;
}
}

.layerControlPanel--hide {
pointer-events: auto;

.layerControlPanel__visButton {
background-color: $euiColorEmptyShade;
color: $euiTextColor;
border-color: $euiColorLightShade;
}
}
Loading

0 comments on commit 9d8b5a1

Please sign in to comment.