forked from opensearch-project/dashboards-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merging the customImportMap and maps layer plugin into 1 single plugi…
…n. (opensearch-project#166) * Merging the customImportMap and maps layer plugin into 1 single plugin. Signed-off-by: Navneet Verma <[email protected]> Signed-off-by: Navneet Verma <[email protected]>
- Loading branch information
Showing
61 changed files
with
6,145 additions
and
14 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['@elastic/eslint-config-kibana', 'plugin:@elastic/eui/recommended'], | ||
rules: { | ||
'@osd/eslint/require-license-header': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"prefix": "customImportMap", | ||
"paths": { | ||
"customImportMap": "." | ||
}, | ||
"translations": ["translations/ja-JP.json"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { SavedObjectAttributes } from 'opensearch-dashboards/server'; | ||
|
||
export interface MapSavedObjectAttributes extends SavedObjectAttributes { | ||
/** Title of the map */ | ||
title: string; | ||
/** Description of the map */ | ||
description?: string; | ||
/** State of the map, which could include current zoom level, lat, lng etc. */ | ||
mapState?: string; | ||
/** Maps-dashboards layers of the map */ | ||
layerList?: string; | ||
/** UI state of the map */ | ||
uiState?: string; | ||
/** Version is used to track version differences in saved object mapping */ | ||
version: number; | ||
/** SearchSourceFields is used to reference other saved objects */ | ||
searchSourceFields?: { | ||
index?: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"id": "customImportMap", | ||
"version": "3.0.0.0", | ||
"opensearchDashboardsVersion": "2.4.1", | ||
"opensearchDashboardsVersion": "3.0.0", | ||
"server": true, | ||
"ui": true, | ||
"requiredPlugins": ["regionMap", "opensearchDashboardsReact"], | ||
"requiredPlugins": ["regionMap", "opensearchDashboardsReact", "navigation", "savedObjects", "data"], | ||
"optionalPlugins": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
$mapHeaderOffset: 154px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { AppMountParameters } from '../../../src/core/public'; | ||
import { MapServices } from './types'; | ||
import { MapsDashboardsApp } from './components/app'; | ||
import { OpenSearchDashboardsContextProvider } from '../../../src/plugins/opensearch_dashboards_react/public'; | ||
|
||
export const renderApp = ({ element }: AppMountParameters, services: MapServices) => { | ||
ReactDOM.render( | ||
<OpenSearchDashboardsContextProvider services={services}> | ||
<MapsDashboardsApp /> | ||
</OpenSearchDashboardsContextProvider>, | ||
element | ||
); | ||
|
||
return () => ReactDOM.unmountComponentAtNode(element); | ||
}; |
12 changes: 12 additions & 0 deletions
12
custom_import_map/public/components/add_layer_panel/add_layer_panel.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
.addLayer__button { | ||
padding: $euiSizeM $euiSizeM; | ||
} | ||
|
||
.addLayerDialog__description { | ||
width: 272px; | ||
} |
153 changes: 153 additions & 0 deletions
153
custom_import_map/public/components/add_layer_panel/add_layer_panel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiModal, | ||
EuiModalBody, | ||
EuiModalHeader, | ||
EuiModalHeaderTitle, | ||
EuiHorizontalRule, | ||
EuiTitle, | ||
EuiButton, | ||
EuiIcon, | ||
EuiKeyPadMenuItem, | ||
EuiSpacer, | ||
EuiText, | ||
} from '@elastic/eui'; | ||
import './add_layer_panel.scss'; | ||
import { | ||
DOCUMENTS, | ||
OPENSEARCH_MAP_LAYER, | ||
CUSTOM_MAP, | ||
Layer, | ||
NEW_MAP_LAYER_DEFAULT_PREFIX, | ||
} from '../../../common'; | ||
import { getLayerConfigMap } from '../../utils/getIntialConfig'; | ||
|
||
interface Props { | ||
setIsLayerConfigVisible: Function; | ||
setSelectedLayerConfig: Function; | ||
IsLayerConfigVisible: boolean; | ||
addLayer: Function; | ||
setIsNewLayer: Function; | ||
newLayerIndex: number; | ||
} | ||
|
||
export const AddLayerPanel = ({ | ||
setIsLayerConfigVisible, | ||
setSelectedLayerConfig, | ||
IsLayerConfigVisible, | ||
addLayer, | ||
setIsNewLayer, | ||
newLayerIndex, | ||
}: Props) => { | ||
const [isAddNewLayerModalVisible, setIsAddNewLayerModalVisible] = useState(false); | ||
const [highlightItem, setHighlightItem] = useState<Layer | null>(null); | ||
|
||
function onClickAddNewLayer(layerType: string) { | ||
const initLayerConfig = getLayerConfigMap()[layerType]; | ||
initLayerConfig.name = NEW_MAP_LAYER_DEFAULT_PREFIX + ' ' + newLayerIndex; | ||
setSelectedLayerConfig(initLayerConfig); | ||
setIsAddNewLayerModalVisible(false); | ||
setIsLayerConfigVisible(true); | ||
setIsNewLayer(true); | ||
addLayer(initLayerConfig); | ||
} | ||
|
||
const dataLayers = [DOCUMENTS]; | ||
const dataLayerItems = Object.values(dataLayers).map((layerItem, index) => { | ||
return ( | ||
<EuiKeyPadMenuItem | ||
key={layerItem.name} | ||
label={layerItem.name} | ||
onClick={() => onClickAddNewLayer(layerItem.type)} | ||
onFocus={() => setHighlightItem(layerItem)} | ||
onMouseEnter={() => setHighlightItem(layerItem)} | ||
onMouseLeave={() => setHighlightItem(null)} | ||
onBlur={() => setHighlightItem(null)} | ||
> | ||
<EuiIcon type={layerItem.icon} size="xl" color="secondary" /> | ||
</EuiKeyPadMenuItem> | ||
); | ||
}); | ||
|
||
const referenceLayers = [OPENSEARCH_MAP_LAYER, CUSTOM_MAP]; | ||
const referenceLayersItems = Object.values(referenceLayers).map((layerItem, index) => { | ||
return ( | ||
<EuiKeyPadMenuItem | ||
key={index} | ||
label={layerItem.name} | ||
aria-label={layerItem.name} | ||
onClick={() => onClickAddNewLayer(layerItem.type)} | ||
onFocus={() => setHighlightItem(layerItem)} | ||
onMouseEnter={() => setHighlightItem(layerItem)} | ||
onMouseLeave={() => setHighlightItem(null)} | ||
onBlur={() => setHighlightItem(null)} | ||
> | ||
<EuiIcon type={layerItem.icon} size="xl" color="secondary" /> | ||
</EuiKeyPadMenuItem> | ||
); | ||
}); | ||
|
||
const closeModal = () => setIsAddNewLayerModalVisible(false); | ||
const showModal = () => setIsAddNewLayerModalVisible(true); | ||
|
||
return ( | ||
<div className="addLayer"> | ||
<EuiFlexItem className="addLayer__button"> | ||
<EuiButton | ||
size="s" | ||
fill | ||
onClick={showModal} | ||
aria-label="Add layer" | ||
isDisabled={IsLayerConfigVisible} | ||
> | ||
Add layer | ||
</EuiButton> | ||
</EuiFlexItem> | ||
{isAddNewLayerModalVisible && ( | ||
<EuiModal onClose={closeModal}> | ||
<EuiModalHeader> | ||
<EuiModalHeaderTitle> | ||
<h2>Add layer</h2> | ||
</EuiModalHeaderTitle> | ||
</EuiModalHeader> | ||
<EuiModalBody> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiTitle size="s"> | ||
<h6>Data layer</h6> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
<EuiFlexGroup gutterSize="xs">{dataLayerItems}</EuiFlexGroup> | ||
<EuiSpacer size="s" /> | ||
<EuiHorizontalRule margin="xs" /> | ||
<EuiTitle size="s"> | ||
<h6>Reference layer</h6> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
<EuiFlexGroup gutterSize="xs">{referenceLayersItems}</EuiFlexGroup> | ||
</EuiFlexItem> | ||
<EuiFlexItem className="addLayerDialog__description"> | ||
<EuiTitle size="s"> | ||
<h6>{highlightItem?.name ? highlightItem.name : 'Select a layer type'}</h6> | ||
</EuiTitle> | ||
<EuiSpacer size="m" /> | ||
<EuiText> | ||
{highlightItem?.description | ||
? highlightItem.description | ||
: 'Start creating your map by selecting a layer type.'} | ||
</EuiText> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiModalBody> | ||
</EuiModal> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { AddLayerPanel } from './add_layer_panel'; |
Oops, something went wrong.