@eeacms/volto-eea-map 0.1.2 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/cypress.config.js +36 -0
- package/package.json +5 -4
- package/src/components/Blocks/EEAMap/Edit.jsx +0 -1
- package/src/components/Blocks/EEAMap/Schema.js +25 -1
- package/src/components/Blocks/EEAMap/components/Webmap.jsx +28 -23
- package/src/components/Blocks/EEAMap/components/widgets/ExtraViews.jsx +19 -9
- package/src/components/Blocks/EEAMap/components/widgets/LayerSelectWidget.jsx +32 -31
- package/src/components/Blocks/EEAMap/components/widgets/LayersPanel.jsx +3 -1
- package/src/components/Blocks/EEAMap/components/widgets/LegendWidget.jsx +56 -20
- package/src/components/Blocks/EEAMap/components/widgets/MapEditorWidget.jsx +13 -4
- package/src/components/Blocks/EEAMap/components/widgets/ObjectTypesWidget.jsx +2 -2
- package/src/components/Blocks/EEAMap/components/widgets/panelsSchema.js +98 -128
- package/src/index.js +15 -0
- package/cypress.json +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,49 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
#### [0.1.5](https://github.com/eea/volto-eea-map/compare/0.1.4...0.1.5)
|
|
8
|
+
|
|
9
|
+
- Center on extent only on map load [`b63f586`](https://github.com/eea/volto-eea-map/commit/b63f586e0df68faa755bb0d25e297530e36ef7c9)
|
|
10
|
+
- Configure proxy for all map subdomains [`0f19030`](https://github.com/eea/volto-eea-map/commit/0f19030569e1f77b1ff7657669e876519712840f)
|
|
11
|
+
- Prevent unnecessary rerenders of ma [`8752384`](https://github.com/eea/volto-eea-map/commit/8752384b3bbd7b564a25b3e4347c47692106f556)
|
|
12
|
+
- Prevent unnecessary rerenders of map [`00a3e64`](https://github.com/eea/volto-eea-map/commit/00a3e64585748a36ef476b2d75540bdd43778486)
|
|
13
|
+
- Clear print schema [`29ed979`](https://github.com/eea/volto-eea-map/commit/29ed9795812d6673f8fb91ac73e53e4e132ed55a)
|
|
14
|
+
- Move zoom & print in general tab [`06c4996`](https://github.com/eea/volto-eea-map/commit/06c499651217715e1793d2a75fb72668dc1de223)
|
|
15
|
+
- Clear [`9aa7bf1`](https://github.com/eea/volto-eea-map/commit/9aa7bf1591b22a2941ce0f269ef133d687affc15)
|
|
16
|
+
- Disable url for screenshot atm [`1ef18fc`](https://github.com/eea/volto-eea-map/commit/1ef18fc8b7516c88c743cffb10b5eb340161d58d)
|
|
17
|
+
|
|
18
|
+
#### [0.1.4](https://github.com/eea/volto-eea-map/compare/0.1.3...0.1.4)
|
|
19
|
+
|
|
20
|
+
> 3 August 2022
|
|
21
|
+
|
|
22
|
+
- Map updates [`#4`](https://github.com/eea/volto-eea-map/pull/4)
|
|
23
|
+
- Configure Privacy protection screenshot data [`49097c0`](https://github.com/eea/volto-eea-map/commit/49097c0b7aa8657e626d5a49dd0eed84f5e71e78)
|
|
24
|
+
- Expandable Legend [`6edda2f`](https://github.com/eea/volto-eea-map/commit/6edda2fafd8a2a61f3f1f10c47a9ca5bb35a0355)
|
|
25
|
+
- Catch for no data [`7cef4e6`](https://github.com/eea/volto-eea-map/commit/7cef4e641650ede23e37ca9116130db1ef0a18db)
|
|
26
|
+
|
|
27
|
+
#### [0.1.3](https://github.com/eea/volto-eea-map/compare/0.1.2...0.1.3)
|
|
28
|
+
|
|
29
|
+
> 2 August 2022
|
|
30
|
+
|
|
31
|
+
- Center map on first layer [`#3`](https://github.com/eea/volto-eea-map/pull/3)
|
|
32
|
+
- Icons & download/viewer change [`321f538`](https://github.com/eea/volto-eea-map/commit/321f538e9582f9a12db3f64beb26588616e867e2)
|
|
33
|
+
- Inline inputs actions & styles [`1f4787e`](https://github.com/eea/volto-eea-map/commit/1f4787e3b3f0dc1328ff23cca2459db816188e3a)
|
|
34
|
+
- more updates for cy10 [`4d5c6a1`](https://github.com/eea/volto-eea-map/commit/4d5c6a1925413b44acc70b5ad3753378830dba2d)
|
|
35
|
+
- updates for cy10 [`30e0293`](https://github.com/eea/volto-eea-map/commit/30e0293ed79cad3cf3f62bcacd3c14a5627543bd)
|
|
36
|
+
- upgrade to cypress 10 [`fe9ca3e`](https://github.com/eea/volto-eea-map/commit/fe9ca3e6a98dd02c6b774f931fe73f18712e0e7b)
|
|
37
|
+
- padding & menu dimension [`da27ccd`](https://github.com/eea/volto-eea-map/commit/da27ccd2b0b42fb5c325a76bdde63e92216b1c93)
|
|
38
|
+
- general tab settings move to block schema [`075baed`](https://github.com/eea/volto-eea-map/commit/075baed1629964b40d355c8612498e02a16eedfc)
|
|
39
|
+
- enable conditional editor schema [`801f3c1`](https://github.com/eea/volto-eea-map/commit/801f3c1999b9b7373d1093d3835d62df8bd2fbca)
|
|
40
|
+
- run cypress on latest alpha [`0935ace`](https://github.com/eea/volto-eea-map/commit/0935aceedb0963b770aa9579c2c21a4f543513c3)
|
|
41
|
+
- Clear schema [`4b22f0a`](https://github.com/eea/volto-eea-map/commit/4b22f0aee58cca2bbcd2a8bee9864a01d65e7738)
|
|
42
|
+
- Center on extent control [`9e8b13d`](https://github.com/eea/volto-eea-map/commit/9e8b13dfd5bbfa5eb2419c54444a15fefa384de4)
|
|
43
|
+
- Clear consoles [`798bc2f`](https://github.com/eea/volto-eea-map/commit/798bc2fbf6f77ffadcedcf1e4666b315bc71ea6c)
|
|
44
|
+
|
|
7
45
|
#### [0.1.2](https://github.com/eea/volto-eea-map/compare/0.1.1...0.1.2)
|
|
8
46
|
|
|
47
|
+
> 29 July 2022
|
|
48
|
+
|
|
49
|
+
- Develop [`#2`](https://github.com/eea/volto-eea-map/pull/2)
|
|
9
50
|
- Legend only selected layer [`3474d79`](https://github.com/eea/volto-eea-map/commit/3474d7989321f656397c292bddc289f8f6329a8e)
|
|
10
51
|
- Query layer by existing fields [`52363f5`](https://github.com/eea/volto-eea-map/commit/52363f57a9ab4e49c7418e883bdf0c5bb30c1734)
|
|
11
52
|
- Cleanup [`d4e07b2`](https://github.com/eea/volto-eea-map/commit/d4e07b2fb89a5a27f5e4411047cb43e1c8add769)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const { defineConfig } = require('cypress');
|
|
2
|
+
|
|
3
|
+
module.exports = defineConfig({
|
|
4
|
+
viewportWidth: 1280,
|
|
5
|
+
defaultCommandTimeout: 8888,
|
|
6
|
+
chromeWebSecurity: false,
|
|
7
|
+
reporter: 'junit',
|
|
8
|
+
video: true,
|
|
9
|
+
|
|
10
|
+
retries: {
|
|
11
|
+
runMode: 8,
|
|
12
|
+
openMode: 0,
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
reporterOptions: {
|
|
16
|
+
mochaFile: 'cypress/reports/cypress-[hash].xml',
|
|
17
|
+
jenkinsMode: true,
|
|
18
|
+
toConsole: true,
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
e2e: {
|
|
22
|
+
// We've imported your old cypress plugins here.
|
|
23
|
+
// You may want to clean this up later by importing these.
|
|
24
|
+
// setupNodeEvents(on, config) {
|
|
25
|
+
// return require('./cypress/plugins/index.js')(on, config);
|
|
26
|
+
// },
|
|
27
|
+
baseUrl: 'http://localhost:3000',
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
component: {
|
|
31
|
+
devServer: {
|
|
32
|
+
framework: 'react',
|
|
33
|
+
bundler: 'webpack',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-eea-map",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "@eeacms/volto-eea-map: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -21,14 +21,15 @@
|
|
|
21
21
|
"volto-slate"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"esri-loader": "3.5.0",
|
|
25
|
-
"@plone/scripts": "*",
|
|
26
24
|
"@eeacms/volto-embed": "^2.0.1",
|
|
25
|
+
"@plone/scripts": "*",
|
|
26
|
+
"esri-loader": "3.5.0",
|
|
27
27
|
"volto-slate": "*"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@cypress/code-coverage": "^3.9.5",
|
|
31
|
-
"babel-plugin-transform-class-properties": "^6.24.1"
|
|
31
|
+
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
32
|
+
"cypress": "10.3.1"
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
|
34
35
|
"release": "release-it",
|
|
@@ -5,7 +5,15 @@ export const Schema = () => {
|
|
|
5
5
|
{
|
|
6
6
|
id: 'default',
|
|
7
7
|
title: 'Default',
|
|
8
|
-
fields: [
|
|
8
|
+
fields: [
|
|
9
|
+
'description',
|
|
10
|
+
'height',
|
|
11
|
+
'map_data',
|
|
12
|
+
'show_sources',
|
|
13
|
+
'show_legend',
|
|
14
|
+
'show_download',
|
|
15
|
+
'show_viewer',
|
|
16
|
+
],
|
|
9
17
|
},
|
|
10
18
|
],
|
|
11
19
|
properties: {
|
|
@@ -22,6 +30,22 @@ export const Schema = () => {
|
|
|
22
30
|
description: 'Open the map customization interface',
|
|
23
31
|
widget: 'map_edit_widget',
|
|
24
32
|
},
|
|
33
|
+
show_sources: {
|
|
34
|
+
title: 'Show sources',
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
},
|
|
37
|
+
show_legend: {
|
|
38
|
+
title: 'Show legend',
|
|
39
|
+
type: 'boolean',
|
|
40
|
+
},
|
|
41
|
+
show_download: {
|
|
42
|
+
title: 'Show download',
|
|
43
|
+
type: 'boolean',
|
|
44
|
+
},
|
|
45
|
+
show_viewer: {
|
|
46
|
+
title: 'Show web viewer',
|
|
47
|
+
type: 'boolean',
|
|
48
|
+
},
|
|
25
49
|
},
|
|
26
50
|
required: [],
|
|
27
51
|
};
|
|
@@ -15,15 +15,11 @@ const MODULES = [
|
|
|
15
15
|
];
|
|
16
16
|
|
|
17
17
|
const Webmap = (props) => {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
legend = {},
|
|
24
|
-
print = {},
|
|
25
|
-
zoom = {},
|
|
26
|
-
} = data;
|
|
18
|
+
const { editMode, height } = props;
|
|
19
|
+
|
|
20
|
+
const data = React.useMemo(() => props.data || {}, [props.data]);
|
|
21
|
+
|
|
22
|
+
const { base = {}, layers = {}, id, legend = {}, general = {} } = data;
|
|
27
23
|
|
|
28
24
|
const { base_layer = '' } = base;
|
|
29
25
|
|
|
@@ -39,6 +35,7 @@ const Webmap = (props) => {
|
|
|
39
35
|
|
|
40
36
|
const mapRef = React.useRef();
|
|
41
37
|
const [modules, setModules] = React.useState({});
|
|
38
|
+
|
|
42
39
|
const modules_loaded = React.useRef(false);
|
|
43
40
|
|
|
44
41
|
React.useEffect(() => {
|
|
@@ -114,13 +111,6 @@ const Webmap = (props) => {
|
|
|
114
111
|
return mapLayer;
|
|
115
112
|
});
|
|
116
113
|
|
|
117
|
-
// //this next layer will be used to filter country and intersect with existing layer
|
|
118
|
-
// const allCountriesLayer = new FeatureLayer({
|
|
119
|
-
// url:
|
|
120
|
-
// 'https://trial.discomap.eea.europa.eu/arcgis/rest/services/CLMS/WorldCountries/MapServer/1',
|
|
121
|
-
// definitionExpression: `(CNTR_ID = 'BG')`,
|
|
122
|
-
// });
|
|
123
|
-
|
|
124
114
|
const map = new Map({
|
|
125
115
|
basemap: base_layer || 'hybrid',
|
|
126
116
|
layers,
|
|
@@ -129,15 +119,28 @@ const Webmap = (props) => {
|
|
|
129
119
|
const view = new MapView({
|
|
130
120
|
container: mapRef.current,
|
|
131
121
|
map,
|
|
132
|
-
center:
|
|
133
|
-
|
|
122
|
+
center:
|
|
123
|
+
general?.long && general?.lat ? [general.long, general.lat] : [0, 40],
|
|
124
|
+
zoom: general?.zoom_level ? general?.zoom_level : 2,
|
|
134
125
|
ui: {
|
|
135
126
|
components: ['attribution'],
|
|
136
127
|
},
|
|
137
128
|
});
|
|
138
129
|
|
|
139
|
-
if (
|
|
140
|
-
const
|
|
130
|
+
if (layers && layers[0] && general && general.centerOnExtent) {
|
|
131
|
+
const firstLayer = layers[0];
|
|
132
|
+
firstLayer
|
|
133
|
+
.when(() => {
|
|
134
|
+
return firstLayer.queryExtent();
|
|
135
|
+
})
|
|
136
|
+
.then((response) => {
|
|
137
|
+
view.goTo(response.extent);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (general?.show_zoom) {
|
|
142
|
+
const zoomPosition =
|
|
143
|
+
general && general.zoom_position ? general.zoom_position : 'top-right';
|
|
141
144
|
const zoomWidget = new Zoom({
|
|
142
145
|
view: view,
|
|
143
146
|
});
|
|
@@ -164,9 +167,11 @@ const Webmap = (props) => {
|
|
|
164
167
|
view.ui.add(legendWidget, legendPosition);
|
|
165
168
|
}
|
|
166
169
|
|
|
167
|
-
if (
|
|
170
|
+
if (general?.show_print) {
|
|
168
171
|
const printPosition =
|
|
169
|
-
|
|
172
|
+
general && general.print_position
|
|
173
|
+
? general.print_position
|
|
174
|
+
: 'top-right';
|
|
170
175
|
const printWidget = new Expand({
|
|
171
176
|
content: new Print({
|
|
172
177
|
view: view,
|
|
@@ -201,4 +206,4 @@ const Webmap = (props) => {
|
|
|
201
206
|
);
|
|
202
207
|
};
|
|
203
208
|
|
|
204
|
-
export default Webmap;
|
|
209
|
+
export default React.memo(Webmap);
|
|
@@ -9,28 +9,34 @@ import worldSVG from '@plone/volto/icons/world.svg';
|
|
|
9
9
|
import downloadSVG from '@plone/volto/icons/download.svg';
|
|
10
10
|
|
|
11
11
|
const ExtraViews = ({ data }) => {
|
|
12
|
-
const {
|
|
13
|
-
|
|
12
|
+
const {
|
|
13
|
+
map_data = {},
|
|
14
|
+
description,
|
|
15
|
+
show_legend,
|
|
16
|
+
show_download,
|
|
17
|
+
show_viewer,
|
|
18
|
+
} = data;
|
|
19
|
+
|
|
14
20
|
return (
|
|
15
21
|
<>
|
|
16
|
-
{
|
|
17
|
-
{description && serializeNodes(description)}
|
|
18
|
-
{(general.show_download || general.show_viewer) && (
|
|
22
|
+
{map_data.layers?.map_layers[0] && (show_download || show_viewer) && (
|
|
19
23
|
<div
|
|
20
24
|
style={{ display: 'flex', justifyContent: 'end', margin: '10px 0' }}
|
|
21
25
|
>
|
|
22
|
-
{
|
|
26
|
+
{show_download && (
|
|
23
27
|
<a
|
|
24
28
|
target="_blank"
|
|
25
29
|
rel="noreferrer"
|
|
26
30
|
href={`${map_data.layers.map_layers[0].map_layer.map_service_url}?f=lyr&v=9.3`}
|
|
27
31
|
>
|
|
28
32
|
<Button size="tiny">
|
|
29
|
-
<
|
|
33
|
+
<Button.Content>
|
|
34
|
+
<Icon name={downloadSVG} title="Download" size="25px" />
|
|
35
|
+
</Button.Content>
|
|
30
36
|
</Button>
|
|
31
37
|
</a>
|
|
32
38
|
)}
|
|
33
|
-
{
|
|
39
|
+
{show_viewer && (
|
|
34
40
|
<a
|
|
35
41
|
target="_blank"
|
|
36
42
|
rel="noreferrer"
|
|
@@ -40,12 +46,16 @@ const ExtraViews = ({ data }) => {
|
|
|
40
46
|
}
|
|
41
47
|
>
|
|
42
48
|
<Button size="tiny">
|
|
43
|
-
<
|
|
49
|
+
<Button.Content>
|
|
50
|
+
<Icon name={worldSVG} title="View map" size="25px" />
|
|
51
|
+
</Button.Content>
|
|
44
52
|
</Button>
|
|
45
53
|
</a>
|
|
46
54
|
)}
|
|
47
55
|
</div>
|
|
48
56
|
)}
|
|
57
|
+
{show_legend && <LegendWidget data={map_data} />}
|
|
58
|
+
{description && serializeNodes(description)}
|
|
49
59
|
</>
|
|
50
60
|
);
|
|
51
61
|
};
|
|
@@ -4,11 +4,14 @@ import { Input, Select, Button, Grid } from 'semantic-ui-react';
|
|
|
4
4
|
|
|
5
5
|
import checkSVG from '@plone/volto/icons/check.svg';
|
|
6
6
|
import closeSVG from '@plone/volto/icons/clear.svg';
|
|
7
|
+
import aheadSVG from '@plone/volto/icons/ahead.svg';
|
|
7
8
|
|
|
8
9
|
import { fetchArcgisData } from '../../utils';
|
|
9
10
|
|
|
10
11
|
const LayerSelectWidget = (props) => {
|
|
11
|
-
const { onChange,
|
|
12
|
+
const { onChange, id } = props;
|
|
13
|
+
|
|
14
|
+
const value = React.useMemo(() => props.value || {}, [props.value]);
|
|
12
15
|
|
|
13
16
|
const {
|
|
14
17
|
available_layers,
|
|
@@ -97,30 +100,26 @@ const LayerSelectWidget = (props) => {
|
|
|
97
100
|
<Input
|
|
98
101
|
type="text"
|
|
99
102
|
onChange={(e, { value }) => setServiceUrl(value)}
|
|
100
|
-
style={{ width: '
|
|
103
|
+
style={{ width: '70%' }}
|
|
101
104
|
value={serviceUrl}
|
|
102
|
-
|
|
103
|
-
|
|
105
|
+
action
|
|
106
|
+
actionPosition="right"
|
|
107
|
+
>
|
|
108
|
+
<input />
|
|
104
109
|
<Button
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
alignItems: 'center',
|
|
109
|
-
}}
|
|
110
|
+
type="submit"
|
|
111
|
+
size="tiny"
|
|
112
|
+
compact
|
|
110
113
|
color={checkColor}
|
|
111
114
|
onClick={handleServiceUrlCheck}
|
|
112
115
|
>
|
|
113
|
-
<p style={{ fontSize: '14px', margin: '0', marginRight: '5px' }}>
|
|
114
|
-
Check Url
|
|
115
|
-
</p>
|
|
116
116
|
<Icon
|
|
117
117
|
name={serviceUrlError ? closeSVG : checkSVG}
|
|
118
|
-
style={{ marginLeft: '5px' }}
|
|
119
118
|
title="Check Url"
|
|
120
119
|
size="17px"
|
|
121
120
|
/>
|
|
122
121
|
</Button>
|
|
123
|
-
</
|
|
122
|
+
</Input>
|
|
124
123
|
</Grid.Row>
|
|
125
124
|
<h4>Layer</h4>
|
|
126
125
|
<Grid.Row>
|
|
@@ -137,26 +136,28 @@ const LayerSelectWidget = (props) => {
|
|
|
137
136
|
<Input
|
|
138
137
|
type="text"
|
|
139
138
|
onChange={(e, { value }) => setLayerQuery(value)}
|
|
140
|
-
style={{ width: '
|
|
139
|
+
style={{ width: '70%' }}
|
|
141
140
|
value={layerQuery}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
style={{
|
|
145
|
-
margin: '10px 0',
|
|
146
|
-
display: 'flex',
|
|
147
|
-
alignItems: 'center',
|
|
148
|
-
}}
|
|
149
|
-
color={checkColor}
|
|
150
|
-
onClick={handleQueryLayer}
|
|
141
|
+
action
|
|
142
|
+
actionPosition="right"
|
|
151
143
|
>
|
|
152
|
-
<
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
144
|
+
<input />
|
|
145
|
+
<Button
|
|
146
|
+
type="submit"
|
|
147
|
+
size="tiny"
|
|
148
|
+
compact
|
|
149
|
+
color={'green'}
|
|
150
|
+
onClick={handleQueryLayer}
|
|
151
|
+
>
|
|
152
|
+
<Icon name={aheadSVG} title="Check Url" size="17px" />
|
|
153
|
+
</Button>
|
|
154
|
+
</Input>
|
|
155
|
+
</Grid.Row>
|
|
156
|
+
<Grid.Row>
|
|
157
|
+
<p style={{ fontSize: '12px', fontWeight: 'bold' }}>
|
|
158
|
+
Available Fields:
|
|
159
|
+
</p>
|
|
156
160
|
</Grid.Row>
|
|
157
|
-
<p style={{ fontSize: '12px', fontWeight: 'bold' }}>
|
|
158
|
-
Available Fields:
|
|
159
|
-
</p>
|
|
160
161
|
{fields &&
|
|
161
162
|
fields.length > 0 &&
|
|
162
163
|
fields.map((field, id) => (
|
|
@@ -3,7 +3,9 @@ import { Button } from 'semantic-ui-react';
|
|
|
3
3
|
import LayerSelectWidget from './LayerSelectWidget';
|
|
4
4
|
|
|
5
5
|
const LayersPanel = ({ data, onChange, block }) => {
|
|
6
|
-
const
|
|
6
|
+
const map_layers = React.useMemo(() => data.map_layers || [], [
|
|
7
|
+
data.map_layers,
|
|
8
|
+
]);
|
|
7
9
|
|
|
8
10
|
React.useEffect(() => {
|
|
9
11
|
if (!data.map_layers) {
|
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Grid } from 'semantic-ui-react';
|
|
3
3
|
import { fetchArcgisData } from '../../utils';
|
|
4
|
+
import { Icon } from '@plone/volto/components';
|
|
5
|
+
|
|
6
|
+
import rightKeySVG from '@plone/volto/icons/right-key.svg';
|
|
7
|
+
import downKeySVG from '@plone/volto/icons/down-key.svg';
|
|
8
|
+
|
|
9
|
+
const LayerLegend = ({ data, name }) => {
|
|
10
|
+
const [expand, setExpand] = React.useState(true);
|
|
4
11
|
|
|
5
|
-
const LayerLegend = ({ data }) => {
|
|
6
12
|
return (
|
|
7
13
|
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
14
|
+
<h5
|
|
15
|
+
role="presentation"
|
|
16
|
+
onClick={() => setExpand(!expand)}
|
|
17
|
+
style={{
|
|
18
|
+
marginTop: '10px',
|
|
19
|
+
marginBottom: '5px',
|
|
20
|
+
cursor: 'pointer',
|
|
21
|
+
display: 'flex',
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
<Icon
|
|
25
|
+
name={expand ? downKeySVG : rightKeySVG}
|
|
26
|
+
title={expand ? 'Collapse' : 'Expand'}
|
|
27
|
+
size="17px"
|
|
28
|
+
/>
|
|
29
|
+
{name}
|
|
30
|
+
</h5>
|
|
31
|
+
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
32
|
+
{expand &&
|
|
33
|
+
data.length > 0 &&
|
|
34
|
+
data.map((item, i) => {
|
|
35
|
+
return (
|
|
36
|
+
<span key={i} style={{ display: 'flex', alignItems: 'center' }}>
|
|
37
|
+
<img
|
|
38
|
+
alt="alt"
|
|
39
|
+
src={`data:image/png;base64,${item.imageData}`}
|
|
40
|
+
/>
|
|
41
|
+
<span style={{ fontSize: '13px', marginLeft: '5px' }}>
|
|
42
|
+
{item.label}
|
|
43
|
+
</span>
|
|
44
|
+
</span>
|
|
45
|
+
);
|
|
46
|
+
})}
|
|
47
|
+
</div>
|
|
17
48
|
</div>
|
|
18
49
|
);
|
|
19
50
|
};
|
|
@@ -37,10 +68,11 @@ const LegendWidget = (props) => {
|
|
|
37
68
|
};
|
|
38
69
|
|
|
39
70
|
React.useEffect(() => {
|
|
40
|
-
|
|
71
|
+
if (activeLayer) {
|
|
72
|
+
fetchLegend(`${activeLayer.map_service_url}/legend`);
|
|
73
|
+
}
|
|
41
74
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
42
75
|
}, [data, activeLayer.map_service_url]);
|
|
43
|
-
|
|
44
76
|
return (
|
|
45
77
|
<>
|
|
46
78
|
<div style={{ margin: '10px 0' }}>
|
|
@@ -48,15 +80,19 @@ const LegendWidget = (props) => {
|
|
|
48
80
|
<Grid.Row>
|
|
49
81
|
<Grid.Column>
|
|
50
82
|
<h3>Legend:</h3>
|
|
83
|
+
{!activeLayer && (
|
|
84
|
+
<p>
|
|
85
|
+
No layer found for legend. Please add a map layer from editor.
|
|
86
|
+
</p>
|
|
87
|
+
)}
|
|
51
88
|
{legendLayers.length > 0 &&
|
|
52
|
-
legendLayers.map((layer,
|
|
89
|
+
legendLayers.map((layer, i) => {
|
|
53
90
|
return (
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
</div>
|
|
91
|
+
<LayerLegend
|
|
92
|
+
key={i}
|
|
93
|
+
name={layer?.layerName}
|
|
94
|
+
data={layer?.legend}
|
|
95
|
+
/>
|
|
60
96
|
);
|
|
61
97
|
})}
|
|
62
98
|
</Grid.Column>
|
|
@@ -67,4 +103,4 @@ const LegendWidget = (props) => {
|
|
|
67
103
|
);
|
|
68
104
|
};
|
|
69
105
|
|
|
70
|
-
export default LegendWidget;
|
|
106
|
+
export default React.memo(LegendWidget);
|
|
@@ -3,7 +3,7 @@ import { Modal, Button, Grid } from 'semantic-ui-react';
|
|
|
3
3
|
import Webmap from '../Webmap';
|
|
4
4
|
import { FormFieldWrapper, InlineForm } from '@plone/volto/components';
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import PanelsSchema from './panelsSchema';
|
|
7
7
|
|
|
8
8
|
const MapEditorWidget = (props) => {
|
|
9
9
|
const [open, setOpen] = React.useState(false);
|
|
@@ -11,9 +11,16 @@ const MapEditorWidget = (props) => {
|
|
|
11
11
|
const [intValue, setIntValue] = React.useState(value);
|
|
12
12
|
|
|
13
13
|
const dataForm = { map_data: intValue };
|
|
14
|
-
|
|
15
14
|
const handleApplyChanges = () => {
|
|
16
15
|
onChange(id, intValue);
|
|
16
|
+
|
|
17
|
+
//set map data for screenshot
|
|
18
|
+
// if (intValue.layers?.map_layers[0].map_layer?.map_service_url) {
|
|
19
|
+
// onChange(
|
|
20
|
+
// 'url',
|
|
21
|
+
// `${intValue.layers?.map_layers[0].map_layer?.map_service_url}?f=jsapi`,
|
|
22
|
+
// );
|
|
23
|
+
// }
|
|
17
24
|
setOpen(false);
|
|
18
25
|
};
|
|
19
26
|
|
|
@@ -26,6 +33,8 @@ const MapEditorWidget = (props) => {
|
|
|
26
33
|
setIntValue(fieldVal);
|
|
27
34
|
};
|
|
28
35
|
|
|
36
|
+
let schema = PanelsSchema({ data: dataForm });
|
|
37
|
+
|
|
29
38
|
return (
|
|
30
39
|
<FormFieldWrapper {...props}>
|
|
31
40
|
<Modal
|
|
@@ -46,8 +55,8 @@ const MapEditorWidget = (props) => {
|
|
|
46
55
|
<Grid.Column width={4}>
|
|
47
56
|
<InlineForm
|
|
48
57
|
block={block}
|
|
49
|
-
title={
|
|
50
|
-
schema={
|
|
58
|
+
title={schema.title}
|
|
59
|
+
schema={schema}
|
|
51
60
|
onChangeField={(id, value) => {
|
|
52
61
|
handleChangeField(id, value);
|
|
53
62
|
}}
|
|
@@ -24,7 +24,7 @@ export const ObjectTypesWidget = (props) => {
|
|
|
24
24
|
),
|
|
25
25
|
render: () => {
|
|
26
26
|
return (
|
|
27
|
-
<Tab.Pane>
|
|
27
|
+
<Tab.Pane style={{ padding: '0' }}>
|
|
28
28
|
<ObjectWidget
|
|
29
29
|
schema={schema}
|
|
30
30
|
id={id}
|
|
@@ -45,7 +45,7 @@ export const ObjectTypesWidget = (props) => {
|
|
|
45
45
|
menu={{ fluid: true, vertical: true, tabular: true }}
|
|
46
46
|
panes={schemas.map(createTab)}
|
|
47
47
|
activeIndex={activeTab}
|
|
48
|
-
grid={{ paneWidth:
|
|
48
|
+
grid={{ paneWidth: 9, tabWidth: 3 }}
|
|
49
49
|
/>
|
|
50
50
|
);
|
|
51
51
|
};
|
|
@@ -55,136 +55,106 @@ const MapLayersSchema = {
|
|
|
55
55
|
},
|
|
56
56
|
required: [],
|
|
57
57
|
};
|
|
58
|
-
const PrintSchema = {
|
|
59
|
-
title: 'Print',
|
|
60
|
-
fieldsets: [
|
|
61
|
-
{
|
|
62
|
-
id: 'default',
|
|
63
|
-
title: 'Print',
|
|
64
|
-
fields: ['show_print', 'position'],
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
properties: {
|
|
68
|
-
show_print: {
|
|
69
|
-
title: 'Show print',
|
|
70
|
-
type: 'boolean',
|
|
71
|
-
},
|
|
72
|
-
position: {
|
|
73
|
-
title: 'Print position',
|
|
74
|
-
choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
|
|
75
|
-
(n) => {
|
|
76
|
-
return [n, n];
|
|
77
|
-
},
|
|
78
|
-
),
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
required: [],
|
|
82
|
-
};
|
|
83
58
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
fieldsets: [
|
|
87
|
-
{
|
|
88
|
-
id: 'default',
|
|
89
|
-
title: 'Zoom',
|
|
90
|
-
fields: ['show_zoom', 'position', 'zoom_level', 'long', 'lat'],
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
properties: {
|
|
94
|
-
show_zoom: {
|
|
95
|
-
title: 'Show zoom',
|
|
96
|
-
type: 'boolean',
|
|
97
|
-
},
|
|
98
|
-
position: {
|
|
99
|
-
title: 'Zoom position',
|
|
100
|
-
choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
|
|
101
|
-
(n) => {
|
|
102
|
-
return [n, n];
|
|
103
|
-
},
|
|
104
|
-
),
|
|
105
|
-
},
|
|
106
|
-
zoom_level: {
|
|
107
|
-
title: 'Zoom level',
|
|
108
|
-
type: 'number',
|
|
109
|
-
},
|
|
110
|
-
long: {
|
|
111
|
-
title: 'Longitude',
|
|
112
|
-
type: 'number',
|
|
113
|
-
},
|
|
114
|
-
lat: {
|
|
115
|
-
title: 'Latitude',
|
|
116
|
-
type: 'number',
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
required: [],
|
|
120
|
-
};
|
|
59
|
+
const GeneralSchema = ({ data = {} }) => {
|
|
60
|
+
const centerOnExtent = data?.map_data?.general?.centerOnExtent;
|
|
121
61
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
62
|
+
return {
|
|
63
|
+
title: 'General',
|
|
64
|
+
fieldsets: [
|
|
65
|
+
{
|
|
66
|
+
id: 'default',
|
|
67
|
+
title: 'Zoom',
|
|
68
|
+
fields: [
|
|
69
|
+
'show_print',
|
|
70
|
+
'print_position',
|
|
71
|
+
'show_zoom',
|
|
72
|
+
'centerOnExtent',
|
|
73
|
+
'zoom_position',
|
|
74
|
+
...(!centerOnExtent ? ['zoom_level', 'long', 'lat'] : []),
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
properties: {
|
|
79
|
+
show_zoom: {
|
|
80
|
+
title: 'Show zoom',
|
|
81
|
+
type: 'boolean',
|
|
82
|
+
},
|
|
83
|
+
centerOnExtent: {
|
|
84
|
+
title: 'Center on extent',
|
|
85
|
+
type: 'boolean',
|
|
86
|
+
description:
|
|
87
|
+
'This will override latitude/longitude/zoom level and will lock zoom/moving the map.',
|
|
88
|
+
},
|
|
89
|
+
zoom_position: {
|
|
90
|
+
title: 'Zoom position',
|
|
91
|
+
choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
|
|
92
|
+
(n) => {
|
|
93
|
+
return [n, n];
|
|
94
|
+
},
|
|
95
|
+
),
|
|
96
|
+
},
|
|
97
|
+
zoom_level: {
|
|
98
|
+
title: 'Zoom level',
|
|
99
|
+
type: 'number',
|
|
100
|
+
},
|
|
101
|
+
long: {
|
|
102
|
+
title: 'Longitude',
|
|
103
|
+
type: 'number',
|
|
104
|
+
},
|
|
105
|
+
lat: {
|
|
106
|
+
title: 'Latitude',
|
|
107
|
+
type: 'number',
|
|
108
|
+
},
|
|
109
|
+
show_print: {
|
|
110
|
+
title: 'Show print',
|
|
111
|
+
type: 'boolean',
|
|
112
|
+
},
|
|
113
|
+
print_position: {
|
|
114
|
+
title: 'Print position',
|
|
115
|
+
choices: ['bottom-right', 'bottom-left', 'top-right', 'top-left'].map(
|
|
116
|
+
(n) => {
|
|
117
|
+
return [n, n];
|
|
118
|
+
},
|
|
119
|
+
),
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
required: [],
|
|
123
|
+
};
|
|
150
124
|
};
|
|
151
125
|
|
|
152
|
-
export
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
],
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
required: [],
|
|
126
|
+
export default ({ data = {} }) => {
|
|
127
|
+
const generalSchema = GeneralSchema({ data });
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
title: 'Map Editor',
|
|
131
|
+
fieldsets: [
|
|
132
|
+
{
|
|
133
|
+
id: 'default',
|
|
134
|
+
title: 'Map Editor Sections',
|
|
135
|
+
fields: ['map_data'],
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
properties: {
|
|
139
|
+
map_data: {
|
|
140
|
+
title: 'Panels',
|
|
141
|
+
widget: 'object_types_widget',
|
|
142
|
+
schemas: [
|
|
143
|
+
{
|
|
144
|
+
id: 'general',
|
|
145
|
+
schema: generalSchema,
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: 'base',
|
|
149
|
+
schema: BaseLayerSchema,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: 'layers',
|
|
153
|
+
schema: MapLayersSchema,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
required: [],
|
|
159
|
+
};
|
|
190
160
|
};
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,21 @@ import MapEditorWidget from './components/Blocks/EEAMap/components/widgets/MapEd
|
|
|
5
5
|
import ObjectTypesWidget from './components/Blocks/EEAMap/components/widgets/ObjectTypesWidget';
|
|
6
6
|
|
|
7
7
|
export default (config) => {
|
|
8
|
+
config.settings.allowed_cors_destinations = [
|
|
9
|
+
...(config.settings.allowed_cors_destinations || []),
|
|
10
|
+
'land.discomap.eea.europa.eu',
|
|
11
|
+
'marine.discomap.eea.europa.eu',
|
|
12
|
+
'climate.discomap.eea.europa.eu',
|
|
13
|
+
'image.discomap.eea.europa.eu',
|
|
14
|
+
'ldp.discomap.eea.europa.eu',
|
|
15
|
+
'bio.discomap.eea.europa.eu',
|
|
16
|
+
'air.discomap.eea.europa.eu',
|
|
17
|
+
'maratlas.discomap.eea.europa.eu',
|
|
18
|
+
'forest.discomap.eea.europa.eu',
|
|
19
|
+
'water.discomap.eea.europa.eu',
|
|
20
|
+
'noise.discomap.eea.europa.eu',
|
|
21
|
+
'copernicus.discomap.eea.europa.eu',
|
|
22
|
+
];
|
|
8
23
|
config.blocks.blocksConfig.eea_map_block = {
|
|
9
24
|
id: 'eea_map_block', // The name (id) of the block
|
|
10
25
|
title: 'EEA Map', // The display name of the block
|
package/cypress.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"baseUrl": "http://localhost:3000",
|
|
3
|
-
"viewportWidth": 1280,
|
|
4
|
-
"defaultCommandTimeout": 8888,
|
|
5
|
-
"chromeWebSecurity": false,
|
|
6
|
-
"reporter": "junit",
|
|
7
|
-
"video": true,
|
|
8
|
-
"retries": {
|
|
9
|
-
"runMode": 8,
|
|
10
|
-
"openMode": 0
|
|
11
|
-
},
|
|
12
|
-
"reporterOptions": {
|
|
13
|
-
"mochaFile": "cypress/reports/cypress-[hash].xml",
|
|
14
|
-
"jenkinsMode": true,
|
|
15
|
-
"toConsole": true
|
|
16
|
-
}
|
|
17
|
-
}
|