Skip to content

Commit

Permalink
Add map as embeddable to dashboard (#231)
Browse files Browse the repository at this point in the history
* Add map as embeddable to dashboard

Signed-off-by: Junqiu Lei <junqiu@amazon.com>

* Create new map from dashboard visualization and save return

Signed-off-by: Junqiu Lei <junqiu@amazon.com>

* Enable interval refresh in dashboard

Signed-off-by: Junqiu Lei <junqiu@amazon.com>

* Enable filters in dashboard

Signed-off-by: Junqiu Lei <junqiu@amazon.com>

* Enable query in dashboard

Signed-off-by: Junqiu Lei <junqiu@amazon.com>

* Add cypress test

Signed-off-by: Junqiu Lei <junqiu@amazon.com>

* Fix maps listing in visualization listing page

Signed-off-by: Junqiu Lei <junqiu@amazon.com>

* Refactor controller

Signed-off-by: Junqiu Lei <junqiu@amazon.com>

* Resolve feedback

Signed-off-by: Junqiu Lei <junqiu@amazon.com>

---------

Signed-off-by: Junqiu Lei <junqiu@amazon.com>
  • Loading branch information
junqiu-lei committed Feb 20, 2023
1 parent 73be418 commit e48407b
Show file tree
Hide file tree
Showing 24 changed files with 1,090 additions and 205 deletions.
4 changes: 2 additions & 2 deletions common/constants/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ export const MAX_FILE_PAYLOAD_SIZE_IN_MB = 25;
export const MAX_FILE_PAYLOAD_SIZE = fromMBtoBytes(MAX_FILE_PAYLOAD_SIZE_IN_MB);
export const PLUGIN_ID = 'customImportMap';
export const PLUGIN_NAME = 'customImportMap';
export const PLUGIN_NAVIGATION_BAR_TILE = 'Maps';
export const PLUGIN_NAVIGATION_BAR_ID = 'maps-dashboards';
export const MAPS_APP_DISPLAY_NAME = 'Maps';
export const MAPS_APP_ID = 'maps-dashboards';
8 changes: 6 additions & 2 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
MAX_FILE_PAYLOAD_SIZE,
MAX_FILE_PAYLOAD_SIZE_IN_MB,
PLUGIN_ID,
PLUGIN_NAVIGATION_BAR_ID,
MAPS_APP_ID,
PLUGIN_NAME,
} from './constants/shared';

Expand All @@ -19,7 +19,7 @@ export {
MAX_FILE_PAYLOAD_SIZE,
MAX_FILE_PAYLOAD_SIZE_IN_MB,
PLUGIN_ID,
PLUGIN_NAVIGATION_BAR_ID,
MAPS_APP_ID,
PLUGIN_NAME,
};

Expand All @@ -44,6 +44,10 @@ export const MAX_LAYER_NAME_LIMIT = 35;
export const MAX_LONGITUDE = 180;
export const MIN_LONGITUDE = -180;
export const NEW_MAP_LAYER_DEFAULT_PREFIX = 'New layer';
export const MAP_SAVED_OBJECT_TYPE = 'map';
// TODO: Replace with actual app icon
export const MAPS_APP_ICON = 'gisApp';
export const MAPS_VISUALIZATION_DESCRIPTION = 'Create map visualization with multiple layers';

// Starting position [lng, lat] and zoom
export const MAP_INITIAL_STATE = {
Expand Down
36 changes: 36 additions & 0 deletions cypress/integration/add_map_to_dashboard.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { BASE_PATH } from '../utils/constants';

describe('Add map to dashboard', () => {
before(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, {
retryOnStatusCodeFailure: true,
timeout: 60000,
});
cy.get('div[data-test-subj="sampleDataSetCardflights"]', { timeout: 60000 })
.contains(/(Add|View) data/)
.click();
cy.wait(60000);
});

it('Add new map to dashboard', () => {
const testMapName = 'saved-map-' + Date.now().toString();
cy.visit(`${BASE_PATH}/app/dashboards`);
cy.get('button[data-test-subj="newItemButton"]').click();
cy.get('button[data-test-subj="dashboardAddNewPanelButton"]').click();
cy.get('button[data-test-subj="visType-customImportMap"]').click();
cy.wait(5000).get('button[data-test-subj="mapSaveButton"]').click();
cy.wait(5000).get('[data-test-subj="savedObjectTitle"]').type(testMapName);
cy.wait(5000).get('[data-test-subj="confirmSaveSavedObjectButton"]').click();
cy.get('.embPanel__titleText').should('contain', testMapName);
});

after(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`);
cy.get('button[data-test-subj="removeSampleDataSetflights"]').should('be.visible').click();
});
});
2 changes: 1 addition & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"opensearchDashboardsVersion": "3.0.0",
"server": true,
"ui": true,
"requiredPlugins": ["regionMap", "opensearchDashboardsReact", "navigation", "savedObjects", "data"],
"requiredPlugins": ["regionMap", "opensearchDashboardsReact", "opensearchDashboardsUtils", "navigation", "savedObjects", "data", "embeddable", "visualizations"],
"optionalPlugins": ["home"]
}
249 changes: 249 additions & 0 deletions package-lock.json

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

16 changes: 7 additions & 9 deletions public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ export const MapsDashboardsApp = ({ mapConfig }: Props) => {
return (
<Router history={appBasePath}>
<I18nProvider>
<div>
<Switch>
<Route
path={[APP_PATH.CREATE_MAP, APP_PATH.EDIT_MAP]}
render={() => <MapPage mapConfig={mapConfig} />}
/>
<Route exact path={APP_PATH.LANDING_PAGE_PATH} render={() => <MapsList />} />
</Switch>
</div>
<Switch>
<Route
path={[APP_PATH.CREATE_MAP, APP_PATH.EDIT_MAP]}
render={() => <MapPage mapConfig={mapConfig} />}
/>
<Route exact path={APP_PATH.LANDING_PAGE_PATH} render={() => <MapsList />} />
</Switch>
</I18nProvider>
</Router>
);
Expand Down
Loading

0 comments on commit e48407b

Please sign in to comment.