Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client - Create new map page workflow #246

Merged
merged 35 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
39e4b7c
conf proxy
luorlandini Mar 24, 2021
0e14896
Merge remote-tracking branch 'upstream/master'
luorlandini Apr 1, 2021
a284a3c
Merge remote-tracking branch 'upstream/master'
luorlandini Apr 7, 2021
213a635
Merge remote-tracking branch 'upstream/master'
luorlandini Apr 12, 2021
42d8965
Merge remote-tracking branch 'upstream/master'
luorlandini Apr 15, 2021
2cb0c3a
Merge remote-tracking branch 'upstream/master'
luorlandini Apr 16, 2021
67fe726
Merge remote-tracking branch 'upstream/master'
luorlandini Apr 16, 2021
efc1bcd
Merge remote-tracking branch 'upstream/master'
luorlandini Apr 20, 2021
2e4ebe3
Merge remote-tracking branch 'upstream/master'
luorlandini Apr 20, 2021
37f6ae8
Merge remote-tracking branch 'upstream/master'
luorlandini Apr 26, 2021
e56da8b
Merge remote-tracking branch 'upstream/master'
luorlandini May 3, 2021
d384237
Merge remote-tracking branch 'upstream/master'
luorlandini May 3, 2021
8cfb1ca
Merge remote-tracking branch 'upstream/master'
luorlandini May 6, 2021
19be961
Merge remote-tracking branch 'upstream/master'
luorlandini May 10, 2021
7a646a3
Merge remote-tracking branch 'upstream/master'
luorlandini May 12, 2021
0ff1b62
Merge remote-tracking branch 'upstream/master'
luorlandini May 17, 2021
f328a01
Merge remote-tracking branch 'upstream/master'
luorlandini May 19, 2021
7ae2c74
Merge remote-tracking branch 'upstream/master'
luorlandini May 24, 2021
8381427
Merge remote-tracking branch 'upstream/master'
luorlandini May 24, 2021
73330c2
Merge remote-tracking branch 'upstream/master'
luorlandini May 25, 2021
2b7c30c
Merge remote-tracking branch 'upstream/master'
luorlandini May 25, 2021
936768e
Merge remote-tracking branch 'upstream/master'
luorlandini May 26, 2021
b0af8c8
host
luorlandini Jun 9, 2021
9555c61
Merge remote-tracking branch 'upstream/master'
luorlandini Jun 10, 2021
547cd95
Merge remote-tracking branch 'upstream/master'
luorlandini Jun 10, 2021
48cb586
Merge remote-tracking branch 'upstream/master'
luorlandini Jun 11, 2021
27af765
Merge remote-tracking branch 'upstream/master'
luorlandini Jun 16, 2021
0a5a976
add action create map
luorlandini Jun 16, 2021
fae0834
action create map in viewer
luorlandini Jun 16, 2021
3597054
add catalogServices
luorlandini Jun 16, 2021
038493b
create new map epic
luorlandini Jun 16, 2021
de10b4f
test mapConfig
luorlandini Jun 16, 2021
dcfa4a7
new create map url
luorlandini Jun 16, 2021
7852038
rm console
luorlandini Jun 16, 2021
84850c5
defaul host
luorlandini Jun 16, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions geonode_mapstore_client/client/js/actions/gnviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

export const REQUEST_LAYER_CONFIG = 'GEONODE_VIEWER:REQUEST_LAYER_CONFIG';
export const REQUEST_MAP_CONFIG = 'GEONODE_VIEWER:REQUEST_MAP_CONFIG';
export const REQUEST_NEW_MAP_CONFIG = 'GEONODE_VIEWER:REQUEST_NEW_MAP_CONFIG';
export const REQUEST_GEOSTORY_CONFIG = 'GEONODE_VIEWER:REQUEST_GEOSTORY_CONFIG';
export const REQUEST_DOCUMENT_CONFIG = 'GEONODE_VIEWER:REQUEST_DOCUMENT_CONFIG';


export function requestLayerConfig(pk) {
return {
type: REQUEST_LAYER_CONFIG,
Expand All @@ -25,6 +27,13 @@ export function requestMapConfig(pk) {
};
}

export function requestNewMapConfig() {
return {
type: REQUEST_NEW_MAP_CONFIG
};
}


export function requestGeoStoryConfig(pk) {
return {
type: REQUEST_GEOSTORY_CONFIG,
Expand Down
41 changes: 41 additions & 0 deletions geonode_mapstore_client/client/js/epics/__tests__/gnviewer-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import expect from 'expect';
import { gnViewerRequestNewMapConfig } from '@js/epics/gnviewer';

import { requestNewMapConfig } from '@js/actions/gnviewer';
import MockAdapter from 'axios-mock-adapter';
import axios from '@mapstore/framework/libs/ajax';
import { testEpic } from '@mapstore/framework/epics/__tests__/epicTestUtils';
let mockAxios;

describe("gnviewer epics", () => {
beforeEach(done => {
mockAxios = new MockAdapter(axios);
setTimeout(done);
});
afterEach(done => {
delete global.__DEVTOOLS__;
mockAxios.restore();
setTimeout(done);
});


it("should call mapConfig", (done) => {
mockAxios.onGet().reply(() => [200, {}]);
const NUM_ACTIONS = 1;
testEpic(
gnViewerRequestNewMapConfig,
NUM_ACTIONS,
requestNewMapConfig(),
(actions) => {
try {
expect(actions.map(({ type }) => type)).toEqual(["MAP_CONFIG_LOADED"]);
done();
} catch (error) {
done(error);
}
},
{ security: { user: { perms: ["add_resource"] } } });

});

});
16 changes: 15 additions & 1 deletion geonode_mapstore_client/client/js/epics/gnviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
REQUEST_LAYER_CONFIG,
REQUEST_MAP_CONFIG,
REQUEST_GEOSTORY_CONFIG,
REQUEST_DOCUMENT_CONFIG
REQUEST_DOCUMENT_CONFIG,
REQUEST_NEW_MAP_CONFIG
} from '@js/actions/gnviewer';
import { getBaseMapConfiguration } from '@js/api/geonode/config';
import {
Expand Down Expand Up @@ -122,6 +123,18 @@ export const gnViewerRequestMapConfig = (action$) =>
});
});

export const gnViewerRequestNewMapConfig = (action$) =>
action$.ofType(REQUEST_NEW_MAP_CONFIG)
.switchMap(() => {
return Observable.defer(getBaseMapConfiguration
).switchMap((response) => {
return Observable.of(configureMap(response));
}).catch(() => {
// TODO: implement various error cases
return Observable.empty();
});
});

export const gnViewerRequestGeoStoryConfig = (action$) =>
action$.ofType(REQUEST_GEOSTORY_CONFIG)
.switchMap(({ pk }) => {
Expand Down Expand Up @@ -165,6 +178,7 @@ export const gnViewerRequestDocumentConfig = (action$) =>
export default {
gnViewerRequestLayerConfig,
gnViewerRequestMapConfig,
gnViewerRequestNewMapConfig,
gnViewerRequestGeoStoryConfig,
gnViewerRequestDocumentConfig
};
12 changes: 7 additions & 5 deletions geonode_mapstore_client/client/js/routes/MapViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { getMonitoredState } from '@mapstore/framework/utils/PluginsUtils';
import { getConfigProp } from '@mapstore/framework/utils/ConfigUtils';
import PluginsContainer from '@mapstore/framework/components/plugins/PluginsContainer';
import useLazyPlugins from '@js/hooks/useLazyPlugins';
import { requestMapConfig } from '@js/actions/gnviewer';
import { requestMapConfig, requestNewMapConfig } from '@js/actions/gnviewer';

const urlQuery = url.parse(window.location.href, true).query;

Expand All @@ -33,6 +33,7 @@ function MapViewerRoute({
pluginsConfig: propPluginsConfig,
params,
onUpdate,
onCreate = () => {},
loaderComponent,
lazyPlugins,
plugins,
Expand All @@ -47,10 +48,9 @@ function MapViewerRoute({
pluginsEntries: lazyPlugins,
pluginsConfig
});

useEffect(() => {
if (!loading) {
onUpdate(pk);
if (!loading && pk !== undefined) {
(pk === "new") ? onCreate() : onUpdate(pk);
}
}, [loading, pk]);

Expand Down Expand Up @@ -80,7 +80,9 @@ MapViewerRoute.propTypes = {
const ConnectedMapViewerRoute = connect(
createSelector([], () => ({})),
{
onUpdate: requestMapConfig
onUpdate: requestMapConfig,
onCreate: requestNewMapConfig

}
)(MapViewerRoute);

Expand Down
2 changes: 1 addition & 1 deletion geonode_mapstore_client/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
"proxyTargetHost": "localhost:8000",
"protocol": "http"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
"labelId": "gnhome.map",
"value": "map",
"type": "link",
"href": "/maps/new",
"href": "/viewer/#/map/new",
"authenticated": true,
"perms": [{ "type": "user", "value": "add_resource" }]
},
Expand Down Expand Up @@ -536,7 +536,7 @@
},
{
"type": "link",
"href": "/maps/new",
"href": "/viewer/#/map/new",
"labelId": "gnhome.createMap",
"authenticated": true,
"permissions": [],
Expand Down
14 changes: 14 additions & 0 deletions geonode_mapstore_client/client/static/mapstore/configs/map.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
{
"version": 2,
"catalogServices": {
"selectedService": "GeoNode Catalogue",
"services": {
"GeoNode Catalogue": {
"autoload": true,
"layerOptions": {
"tileSize": 512
},
"title": "GeoNode Catalogue",
"type": "csw",
"url": "/catalogue/csw"
}
}
},
"map": {
"projection": "EPSG:900913",
"units": "m",
Expand Down