@eeacms/volto-cca-policy 0.1.29 → 0.1.30
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 +24 -0
- package/package.json +9 -2
- package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.jsx +55 -53
- package/src/components/manage/Blocks/CaseStudyExplorer/FeatureInteraction.jsx +25 -9
- package/src/components/manage/Blocks/CountryMapHeatIndex/Edit.js +5 -0
- package/src/components/manage/Blocks/CountryMapHeatIndex/Filter.jsx +66 -0
- package/src/components/manage/Blocks/CountryMapHeatIndex/View.js +174 -0
- package/src/components/manage/Blocks/CountryMapHeatIndex/hooks.js +18 -0
- package/src/components/manage/Blocks/CountryMapHeatIndex/index.js +16 -0
- package/src/components/manage/Blocks/CountryMapHeatIndex/map-utils.js +419 -0
- package/src/components/manage/Blocks/CountryMapHeatIndex/styles.css +131 -0
- package/src/components/manage/Blocks/CountryMapHeatIndex/withResponsiveContainer.js +21 -0
- package/src/components/manage/Blocks/CountryMapObservatory/CountryMapObservatoryEdit.js +5 -0
- package/src/components/manage/Blocks/CountryMapObservatory/CountryMapObservatoryView.js +130 -0
- package/src/components/manage/Blocks/CountryMapObservatory/euro-countries-simplified.js +46195 -0
- package/src/components/manage/Blocks/CountryMapObservatory/flags.js +57 -0
- package/src/components/manage/Blocks/CountryMapObservatory/index.js +16 -0
- package/src/components/manage/Blocks/{CountryMap/CountryMapView.js → CountryMapObservatory/map-utils.js} +10 -142
- package/src/components/manage/Blocks/CountryMapObservatory/schema.js +29 -0
- package/src/components/manage/Blocks/CountryMapObservatory/withResponsiveContainer.js +21 -0
- package/src/components/manage/Blocks/CountryMapProfile/Edit.js +5 -0
- package/src/components/manage/Blocks/CountryMapProfile/Filter.jsx +114 -0
- package/src/components/manage/Blocks/CountryMapProfile/View.js +157 -0
- package/src/components/manage/Blocks/CountryMapProfile/euro-countries-simplified.js +46195 -0
- package/src/components/manage/Blocks/CountryMapProfile/flags.js +57 -0
- package/src/components/manage/Blocks/CountryMapProfile/hooks.js +18 -0
- package/src/components/manage/Blocks/CountryMapProfile/index.js +16 -0
- package/src/components/manage/Blocks/CountryMapProfile/map-utils.js +515 -0
- package/src/components/manage/Blocks/CountryMapProfile/styles.css +234 -0
- package/src/components/manage/Blocks/CountryMapProfile/withResponsiveContainer.js +21 -0
- package/src/components/manage/Blocks/FilterAceContent/FilterAceContentView.jsx +4 -0
- package/src/components/manage/Blocks/Listing/OrganisationCardsListingView.jsx +89 -0
- package/src/components/manage/Blocks/Listing/index.js +19 -0
- package/src/components/manage/Blocks/Listing/styles.less +12 -0
- package/src/components/manage/Blocks/index.js +8 -2
- package/src/express-middleware.js +8 -1
- package/src/index.js +20 -1
- package/src/components/manage/Blocks/CountryMap/CountryMapEdit.js +0 -5
- package/src/components/manage/Blocks/CountryMap/index.js +0 -16
- /package/src/components/manage/Blocks/{CountryMap → CountryMapHeatIndex}/euro-countries-simplified.js +0 -0
- /package/src/components/manage/Blocks/{CountryMap → CountryMapHeatIndex}/flags.js +0 -0
- /package/src/components/manage/Blocks/{CountryMap → CountryMapObservatory}/styles.css +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,30 @@ 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.30](https://github.com/eea/volto-cca-policy/compare/0.1.29...0.1.30) - 27 July 2023
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Refs #255643 - Add temporal-coverage, geolocation, dataprovenance widgets for EEACoreMetadata. [GhitaB - [`34f9126`](https://github.com/eea/volto-cca-policy/commit/34f91263530067e36ceff23b3a6f1e0dd7b2b492)]
|
|
12
|
+
- Refs #255585 - Add Sitemap link in footer. [Ghiță Bizău - [`a2b9e47`](https://github.com/eea/volto-cca-policy/commit/a2b9e478fc3e959f8925d842f2d9ea7a38836eae)]
|
|
13
|
+
- Enable sitemap for mission [Tiberiu Ichim - [`2ce7a54`](https://github.com/eea/volto-cca-policy/commit/2ce7a54026b5c6e3ea3dbef6368671141c10f865)]
|
|
14
|
+
- Refs #161489 - Custom listing variation: implement contributions link. [GhitaB - [`d085959`](https://github.com/eea/volto-cca-policy/commit/d085959bb0794ff8cb72aca81bfe9fdd24ab29d3)]
|
|
15
|
+
- Refs #161489 - Custom listing variation: improve styles. [GhitaB - [`12f1f19`](https://github.com/eea/volto-cca-policy/commit/12f1f196a283d5a353d5abb70640c748f537b947)]
|
|
16
|
+
- Refs #161489 - Custom listing variation: move styles to less file. [GhitaB - [`0e09b43`](https://github.com/eea/volto-cca-policy/commit/0e09b43fd92c31a81bfcc48cc0e0871db0d9bc76)]
|
|
17
|
+
- Refs #161489 - Custom listing variation: fix error in edit, also fix jenkins. [GhitaB - [`82c32b5`](https://github.com/eea/volto-cca-policy/commit/82c32b55037437b6be3deef199491b93c04ef1dc)]
|
|
18
|
+
- Refs #161489 - Custom listing variation: install listing. [GhitaB - [`6a3c570`](https://github.com/eea/volto-cca-policy/commit/6a3c570c1ae133c598fb90f9c70f53340b5c1ffa)]
|
|
19
|
+
- Refs #161489 - Custom listing variation: show website link. [GhitaB - [`ae177e0`](https://github.com/eea/volto-cca-policy/commit/ae177e05aa94781e278fd04e2a7776b487fb55e1)]
|
|
20
|
+
- Enable fullobjects on listing item [Tiberiu Ichim - [`d6b91b9`](https://github.com/eea/volto-cca-policy/commit/d6b91b989d7fb4895070758c3d2a81651acdf5af)]
|
|
21
|
+
- Refs #161489 - Custom listing variation: improve styles. [GhitaB - [`50d27e2`](https://github.com/eea/volto-cca-policy/commit/50d27e2c5f19a816eba0bf2568bce6205316b655)]
|
|
22
|
+
- Refs #161489 - Custom listing variation: fix grid, styles. [GhitaB - [`79fb456`](https://github.com/eea/volto-cca-policy/commit/79fb4564c0d42a539f4f38ae2cd5243eb0edb74a)]
|
|
23
|
+
- Refs #161489 - Add custom listing variation for items cards used in Observatory About. [GhitaB - [`cd99466`](https://github.com/eea/volto-cca-policy/commit/cd994668946402f74522411508ce986af33472ee)]
|
|
24
|
+
- Refs #161493 - wip jenkins [Tripon Eugen - [`665c918`](https://github.com/eea/volto-cca-policy/commit/665c9183481b43253ad488e973e184f59ca980a1)]
|
|
25
|
+
- Refs #161493 - observatory country profile [Tripon Eugen - [`9dfe890`](https://github.com/eea/volto-cca-policy/commit/9dfe890834363cf913fed20eed2a208542a47669)]
|
|
26
|
+
- Refs #161493 - cca country profile and observatory heat index [Tripon Eugen - [`6af532b`](https://github.com/eea/volto-cca-policy/commit/6af532b42785c0d5e3e7dda83d6909eca16d26e5)]
|
|
27
|
+
- Add labels [Tiberiu Ichim - [`219213d`](https://github.com/eea/volto-cca-policy/commit/219213d185ce27cff83cba061a8f5a73a76b8ba5)]
|
|
28
|
+
- Fix country map [Tiberiu Ichim - [`30fed7d`](https://github.com/eea/volto-cca-policy/commit/30fed7d6d35d6994addd0e7ccbfa0160863d4855)]
|
|
29
|
+
- Remove console.log [Tiberiu Ichim - [`c98374c`](https://github.com/eea/volto-cca-policy/commit/c98374cbe7ada2816de5e0bbd2ac92f190ebef2d)]
|
|
30
|
+
- Improvements to casestudy map [Tiberiu Ichim - [`9908304`](https://github.com/eea/volto-cca-policy/commit/99083048fef48f908b74491ec20c074072b67ff9)]
|
|
7
31
|
### [0.1.29](https://github.com/eea/volto-cca-policy/compare/0.1.28...0.1.29) - 20 June 2023
|
|
8
32
|
|
|
9
33
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-cca-policy",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"description": "@eeacms/volto-cca-policy: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"addons": [
|
|
20
20
|
"@eeacms/volto-openlayers-map",
|
|
21
|
+
"@eeacms/volto-widget-temporal-coverage",
|
|
22
|
+
"@eeacms/volto-widget-geolocation",
|
|
23
|
+
"@eeacms/volto-widget-dataprovenance",
|
|
21
24
|
"@eeacms/volto-eea-design-system",
|
|
22
25
|
"@eeacms/volto-globalsearch"
|
|
23
26
|
],
|
|
@@ -25,7 +28,11 @@
|
|
|
25
28
|
"@eeacms/volto-eea-design-system": "*",
|
|
26
29
|
"@eeacms/volto-globalsearch": "*",
|
|
27
30
|
"@eeacms/volto-openlayers-map": "*",
|
|
28
|
-
"
|
|
31
|
+
"@eeacms/volto-widget-dataprovenance": "*",
|
|
32
|
+
"@eeacms/volto-widget-geolocation": "*",
|
|
33
|
+
"@eeacms/volto-widget-temporal-coverage": "*",
|
|
34
|
+
"d3": "3",
|
|
35
|
+
"d3-geo": "3"
|
|
29
36
|
},
|
|
30
37
|
"devDependencies": {
|
|
31
38
|
"@cypress/code-coverage": "^3.10.0",
|
|
@@ -8,15 +8,24 @@ import FeatureInteraction from './FeatureInteraction';
|
|
|
8
8
|
|
|
9
9
|
import { getFeatures } from './utils';
|
|
10
10
|
|
|
11
|
-
const styleCache = {};
|
|
12
|
-
|
|
13
11
|
export default function CaseStudyMap(props) {
|
|
14
12
|
const { items, activeItems } = props;
|
|
15
13
|
const [selectedCase, onSelectedCase] = React.useState();
|
|
16
14
|
|
|
17
15
|
const features = getFeatures(items); //console.log('Features list', features);
|
|
18
16
|
|
|
19
|
-
const [tileWMSSources
|
|
17
|
+
const [tileWMSSources] = React.useState([
|
|
18
|
+
// , setTileWMSSources
|
|
19
|
+
new ol.source.TileWMS({
|
|
20
|
+
url: 'https://gisco-services.ec.europa.eu/maps/service',
|
|
21
|
+
params: {
|
|
22
|
+
LAYERS: 'OSMBlossomComposite',
|
|
23
|
+
TILED: true,
|
|
24
|
+
},
|
|
25
|
+
serverType: 'geoserver',
|
|
26
|
+
transition: 0,
|
|
27
|
+
}),
|
|
28
|
+
]);
|
|
20
29
|
const [pointsSource] = React.useState(
|
|
21
30
|
new ol.source.Vector({
|
|
22
31
|
features,
|
|
@@ -37,20 +46,6 @@ export default function CaseStudyMap(props) {
|
|
|
37
46
|
}
|
|
38
47
|
}, [activeItems, pointsSource]);
|
|
39
48
|
|
|
40
|
-
React.useEffect(() => {
|
|
41
|
-
setTileWMSSources([
|
|
42
|
-
new ol.source.TileWMS({
|
|
43
|
-
url: 'https://gisco-services.ec.europa.eu/maps/service',
|
|
44
|
-
params: {
|
|
45
|
-
LAYERS: 'OSMBlossomComposite',
|
|
46
|
-
TILED: true,
|
|
47
|
-
},
|
|
48
|
-
serverType: 'geoserver',
|
|
49
|
-
transition: 0,
|
|
50
|
-
}),
|
|
51
|
-
]);
|
|
52
|
-
}, []);
|
|
53
|
-
|
|
54
49
|
return features.length > 0 ? (
|
|
55
50
|
<Map
|
|
56
51
|
view={{
|
|
@@ -65,7 +60,7 @@ export default function CaseStudyMap(props) {
|
|
|
65
60
|
<InfoOverlay
|
|
66
61
|
selectedFeature={selectedCase}
|
|
67
62
|
onFeatureSelect={onSelectedCase}
|
|
68
|
-
layerId={tileWMSSources
|
|
63
|
+
layerId={tileWMSSources[0]}
|
|
69
64
|
/>
|
|
70
65
|
<FeatureInteraction onFeatureSelect={onSelectedCase} />
|
|
71
66
|
<Layer.Tile source={tileWMSSources[0]} zIndex={0} />
|
|
@@ -75,43 +70,50 @@ export default function CaseStudyMap(props) {
|
|
|
75
70
|
) : null;
|
|
76
71
|
}
|
|
77
72
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
let style =
|
|
73
|
+
const _cached = {};
|
|
74
|
+
|
|
75
|
+
function getStyle(size) {
|
|
76
|
+
let style = _cached[size];
|
|
82
77
|
|
|
83
78
|
if (!style) {
|
|
84
|
-
style =
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
79
|
+
style =
|
|
80
|
+
size === 1
|
|
81
|
+
? new ol.style.Style({
|
|
82
|
+
image: new ol.style.Circle({
|
|
83
|
+
radius: 5,
|
|
84
|
+
stroke: new ol.style.Stroke({
|
|
85
|
+
color: '#fff',
|
|
86
|
+
}),
|
|
87
|
+
fill: new ol.style.Fill({
|
|
88
|
+
color: '#000000',
|
|
89
|
+
}),
|
|
90
|
+
}),
|
|
91
|
+
})
|
|
92
|
+
: new ol.style.Style({
|
|
93
|
+
image: new ol.style.Circle({
|
|
94
|
+
radius: 10 + Math.min(Math.floor(size / 3), 10),
|
|
95
|
+
stroke: new ol.style.Stroke({
|
|
96
|
+
color: '#fff',
|
|
97
|
+
}),
|
|
98
|
+
fill: new ol.style.Fill({
|
|
99
|
+
color: '#3399CC',
|
|
100
|
+
}),
|
|
101
|
+
}),
|
|
102
|
+
text: new ol.style.Text({
|
|
103
|
+
text: size.toString(),
|
|
104
|
+
fill: new ol.style.Fill({
|
|
105
|
+
color: '#fff',
|
|
106
|
+
}),
|
|
107
|
+
}),
|
|
108
|
+
});
|
|
109
|
+
_cached[size] = style;
|
|
102
110
|
}
|
|
111
|
+
return style;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function clusterStyle(feature) {
|
|
115
|
+
const size = feature.get('features').length;
|
|
116
|
+
//const size = feature.get('casePoints').length;
|
|
103
117
|
|
|
104
|
-
return size
|
|
105
|
-
? new ol.style.Style({
|
|
106
|
-
image: new ol.style.Circle({
|
|
107
|
-
radius: 5,
|
|
108
|
-
stroke: new ol.style.Stroke({
|
|
109
|
-
color: '#fff',
|
|
110
|
-
}),
|
|
111
|
-
fill: new ol.style.Fill({
|
|
112
|
-
color: '#000000',
|
|
113
|
-
}),
|
|
114
|
-
}),
|
|
115
|
-
})
|
|
116
|
-
: style;
|
|
118
|
+
return getStyle(size);
|
|
117
119
|
}
|
|
@@ -6,12 +6,15 @@ const useStyles = () => {
|
|
|
6
6
|
const selected = React.useMemo(
|
|
7
7
|
() =>
|
|
8
8
|
new ol.style.Style({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
image: new ol.style.Circle({
|
|
10
|
+
radius: 12,
|
|
11
|
+
fill: new ol.style.Fill({
|
|
12
|
+
color: '#ccc',
|
|
13
|
+
}),
|
|
14
|
+
stroke: new ol.style.Stroke({
|
|
15
|
+
color: 'rgba(255, 0, 0, 0.7)',
|
|
16
|
+
width: 2,
|
|
17
|
+
}),
|
|
15
18
|
}),
|
|
16
19
|
}),
|
|
17
20
|
[],
|
|
@@ -19,8 +22,10 @@ const useStyles = () => {
|
|
|
19
22
|
|
|
20
23
|
const selectStyle = React.useCallback(
|
|
21
24
|
(feature) => {
|
|
22
|
-
const color = feature.get('COLOR') || '#eeeeee';
|
|
23
|
-
selected.getFill().setColor(color);
|
|
25
|
+
// const color = feature.get('COLOR') || '#eeeeee';
|
|
26
|
+
// selected.getFill().setColor(color);
|
|
27
|
+
const color = feature.values_.features[0].values_['color'] || '#ccc';
|
|
28
|
+
selected.image_.getFill().setColor(color);
|
|
24
29
|
return selected;
|
|
25
30
|
},
|
|
26
31
|
[selected],
|
|
@@ -55,10 +60,20 @@ export default function FeatureInteraction({ onFeatureSelect }) {
|
|
|
55
60
|
if (subfeatures.length === 1) {
|
|
56
61
|
const selectedFeature = subfeatures[0].values_;
|
|
57
62
|
onFeatureSelect(selectedFeature);
|
|
63
|
+
// console.log('onfeatureselect');
|
|
58
64
|
} else {
|
|
65
|
+
// zoom to extent of cluster points
|
|
59
66
|
const extent = getExtentOfFeatures(subfeatures);
|
|
60
|
-
|
|
67
|
+
|
|
68
|
+
let extentBuffer =
|
|
69
|
+
(extent[3] - extent[1] + extent[2] - extent[0]) / 4;
|
|
70
|
+
extentBuffer = extentBuffer < 500 ? 500 : extentBuffer;
|
|
71
|
+
// console.log('extentBuffer', { extent, extentBuffer });
|
|
72
|
+
const paddedExtent = ol.extent.buffer(extent, extentBuffer);
|
|
73
|
+
|
|
74
|
+
// const paddedExtent = ol.extent.buffer(extent, 50000);
|
|
61
75
|
map.getView().fit(paddedExtent, { ...map.getSize(), duration: 1000 });
|
|
76
|
+
// console.log('onclusterzoom');
|
|
62
77
|
}
|
|
63
78
|
});
|
|
64
79
|
|
|
@@ -67,6 +82,7 @@ export default function FeatureInteraction({ onFeatureSelect }) {
|
|
|
67
82
|
|
|
68
83
|
map.addInteraction(select);
|
|
69
84
|
|
|
85
|
+
// TODO: does this accumulate?
|
|
70
86
|
map.on('pointermove', (e) => {
|
|
71
87
|
const pixel = map.getEventPixel(e.originalEvent);
|
|
72
88
|
const hit = map.hasFeatureAtPixel(pixel);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export default function Filter(props) {
|
|
2
|
+
const { thematicMapMode, setThematicMapMode } = props;
|
|
3
|
+
return (
|
|
4
|
+
<>
|
|
5
|
+
<h2>Choose thematic map:</h2>
|
|
6
|
+
<div id="sections-selector">
|
|
7
|
+
<input
|
|
8
|
+
type="radio"
|
|
9
|
+
name="country-map-section"
|
|
10
|
+
value="hhap"
|
|
11
|
+
checked="checked"
|
|
12
|
+
onChange={(e) => {
|
|
13
|
+
setThematicMapMode(e.target.value);
|
|
14
|
+
}}
|
|
15
|
+
/>
|
|
16
|
+
Heat health action plans (HHAP)
|
|
17
|
+
<br />
|
|
18
|
+
<input
|
|
19
|
+
type="radio"
|
|
20
|
+
name="country-map-section"
|
|
21
|
+
value="hhws"
|
|
22
|
+
onChange={(e) => {
|
|
23
|
+
setThematicMapMode(e.target.value);
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
Heat health warning systems (HHWS)
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
{thematicMapMode === 'hhap' && (
|
|
30
|
+
<div className="legend climate-legend">
|
|
31
|
+
<div className="legend-el">
|
|
32
|
+
<span className="country-national-hhap legend-box"></span>
|
|
33
|
+
<p className="legend-text">National HHAP</p>
|
|
34
|
+
</div>
|
|
35
|
+
<div className="legend-el">
|
|
36
|
+
<span className="country-subnational-hhap legend-box"></span>
|
|
37
|
+
<p className="legend-text">Subnational or local</p>
|
|
38
|
+
</div>
|
|
39
|
+
<div className="legend-el">
|
|
40
|
+
<span className="country-no-hhap legend-box"></span>
|
|
41
|
+
<p className="legend-text">No HHAP</p>
|
|
42
|
+
</div>
|
|
43
|
+
<div className="legend-el">
|
|
44
|
+
<span className="country-national-hhap legend-box"></span>
|
|
45
|
+
<p className="legend-text">No information</p>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
|
|
50
|
+
{thematicMapMode === 'hhws' && (
|
|
51
|
+
<div className="legend portals-legend">
|
|
52
|
+
<div className="legend-el">
|
|
53
|
+
<span className="country-national-hhap legend-box"></span>
|
|
54
|
+
<p className="legend-text">
|
|
55
|
+
HHWS available (click on country for further information)
|
|
56
|
+
</p>
|
|
57
|
+
</div>
|
|
58
|
+
<div className="legend-el">
|
|
59
|
+
<span className="country-none legend-box"></span>
|
|
60
|
+
<p className="legend-text">No information</p>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
)}
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import flags from './flags.js';
|
|
3
|
+
import './styles.css';
|
|
4
|
+
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
|
|
5
|
+
import { Grid } from 'semantic-ui-react';
|
|
6
|
+
import { compose } from 'redux';
|
|
7
|
+
import { clientOnly } from '@eeacms/volto-cca-policy/helpers';
|
|
8
|
+
import withResponsiveContainer from './withResponsiveContainer.js';
|
|
9
|
+
import { addAppURL } from '@plone/volto/helpers';
|
|
10
|
+
import {
|
|
11
|
+
getFocusCountriesFeature,
|
|
12
|
+
getFocusCountryNames,
|
|
13
|
+
renderCountriesBox,
|
|
14
|
+
} from './map-utils.js';
|
|
15
|
+
|
|
16
|
+
import Filter from './Filter';
|
|
17
|
+
|
|
18
|
+
import { useCountriesMetadata } from './hooks';
|
|
19
|
+
|
|
20
|
+
const countries_metadata_url = '/en/@@countries-heat-index-json';
|
|
21
|
+
|
|
22
|
+
const withCountriesData = (WrappedComponent) => {
|
|
23
|
+
function WithCountriesDataWrapped(props) {
|
|
24
|
+
let [cpath, setCpath] = React.useState();
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!cpath) {
|
|
28
|
+
import('./euro-countries-simplified.js').then((mod) => {
|
|
29
|
+
const _cpath = mod.default;
|
|
30
|
+
_cpath.features = _cpath.features.map(function (c) {
|
|
31
|
+
//console.log(c);
|
|
32
|
+
var name = c.properties.SHRT_ENGL;
|
|
33
|
+
if (!name) {
|
|
34
|
+
// console.log('No flag for', c.properties);
|
|
35
|
+
return c;
|
|
36
|
+
} else if (name === 'Czechia') {
|
|
37
|
+
name = 'Czech Republic';
|
|
38
|
+
}
|
|
39
|
+
var cname = name.replace(' ', '_');
|
|
40
|
+
flags.forEach(function (f) {
|
|
41
|
+
if (f.indexOf(cname) > -1) {
|
|
42
|
+
c.url = f;
|
|
43
|
+
//console.log(c.url);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return c;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
setCpath(_cpath);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}, [cpath]);
|
|
53
|
+
|
|
54
|
+
return cpath ? <WrappedComponent {...props} cpath={cpath} /> : null;
|
|
55
|
+
}
|
|
56
|
+
return WithCountriesDataWrapped;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const CountryMapObservatoryView = (props) => {
|
|
60
|
+
const svgRef = useRef(null);
|
|
61
|
+
const { d3, d3Geo, size, cpath } = props;
|
|
62
|
+
const { height, width } = size;
|
|
63
|
+
const [thematicMapMode, setThematicMapMode] = React.useState('hhap');
|
|
64
|
+
|
|
65
|
+
const countries_metadata = useCountriesMetadata(
|
|
66
|
+
addAppURL(countries_metadata_url),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
// D3 Code
|
|
71
|
+
|
|
72
|
+
// Dimensions
|
|
73
|
+
//const parentDiv = document.getElementById('page-document');
|
|
74
|
+
let dimensions = {
|
|
75
|
+
//width: parentDiv.offsetWidth,
|
|
76
|
+
width,
|
|
77
|
+
height,
|
|
78
|
+
margins: 50,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
dimensions.containerWidth = dimensions.width - dimensions.margins * 2;
|
|
82
|
+
dimensions.containerHeight = dimensions.height - dimensions.margins * 2;
|
|
83
|
+
|
|
84
|
+
//const d3 = loadable.lib(() => import('d3'));
|
|
85
|
+
// SELECTIONS
|
|
86
|
+
const svg = d3
|
|
87
|
+
.select(svgRef.current)
|
|
88
|
+
.attr('id', 'country_map')
|
|
89
|
+
//.classed("line-chart", true)
|
|
90
|
+
.attr('width', dimensions.width)
|
|
91
|
+
.attr('height', dimensions.height);
|
|
92
|
+
//console.log('SVG x-y', svg.getBBox());
|
|
93
|
+
/*
|
|
94
|
+
const container = svg
|
|
95
|
+
.append('g')
|
|
96
|
+
.classed('container', true)
|
|
97
|
+
.attr(
|
|
98
|
+
'transform',
|
|
99
|
+
`translate(${dimensions.margins}, ${dimensions.margins})`,
|
|
100
|
+
);
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
//console.log('cpath', cpath);
|
|
104
|
+
//console.log(fpath);
|
|
105
|
+
//console.log('Flags',flags);
|
|
106
|
+
//console.log('filtered', getFocusCountriesFeature(cpath));
|
|
107
|
+
|
|
108
|
+
window.countrySettings = cpath.features;
|
|
109
|
+
|
|
110
|
+
var opts = {
|
|
111
|
+
world: cpath.features,
|
|
112
|
+
countries_metadata: countries_metadata,
|
|
113
|
+
thematic_map_mode: thematicMapMode,
|
|
114
|
+
svg: svg,
|
|
115
|
+
coordinates: {
|
|
116
|
+
x: 0,
|
|
117
|
+
y: 0,
|
|
118
|
+
width: dimensions.containerWidth,
|
|
119
|
+
height: dimensions.containerHeight,
|
|
120
|
+
},
|
|
121
|
+
focusCountries: {
|
|
122
|
+
names: getFocusCountryNames(),
|
|
123
|
+
feature: getFocusCountriesFeature(cpath),
|
|
124
|
+
},
|
|
125
|
+
zoom: 0.95,
|
|
126
|
+
};
|
|
127
|
+
renderCountriesBox(opts, d3, d3Geo);
|
|
128
|
+
// Draw Circle
|
|
129
|
+
//container.append("circle").attr("r", 25).style("color","blue");
|
|
130
|
+
}, [
|
|
131
|
+
props.Data,
|
|
132
|
+
d3,
|
|
133
|
+
width,
|
|
134
|
+
height,
|
|
135
|
+
cpath,
|
|
136
|
+
d3Geo,
|
|
137
|
+
thematicMapMode,
|
|
138
|
+
countries_metadata,
|
|
139
|
+
]); // redraw chart if data changes
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<div>
|
|
143
|
+
<Grid columns="12">
|
|
144
|
+
<Grid.Column mobile={9} tablet={9} computer={10} className="col-left">
|
|
145
|
+
<svg ref={svgRef} />
|
|
146
|
+
</Grid.Column>
|
|
147
|
+
<Grid.Column
|
|
148
|
+
mobile={3}
|
|
149
|
+
tablet={3}
|
|
150
|
+
computer={2}
|
|
151
|
+
className="col-left"
|
|
152
|
+
id="cse-filter"
|
|
153
|
+
>
|
|
154
|
+
<Filter
|
|
155
|
+
thematicMapMode={thematicMapMode}
|
|
156
|
+
setThematicMapMode={setThematicMapMode}
|
|
157
|
+
/>
|
|
158
|
+
</Grid.Column>
|
|
159
|
+
</Grid>
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export default compose(
|
|
165
|
+
clientOnly,
|
|
166
|
+
injectLazyLibs(['d3', 'd3Geo']),
|
|
167
|
+
withResponsiveContainer,
|
|
168
|
+
withCountriesData,
|
|
169
|
+
)(CountryMapObservatoryView);
|
|
170
|
+
|
|
171
|
+
// import loadable from '@loadable/component';
|
|
172
|
+
//import * as d3 from 'd3';
|
|
173
|
+
// import cpath from './euro-countries-simplified';
|
|
174
|
+
//
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import superagent from 'superagent';
|
|
3
|
+
|
|
4
|
+
export function useCountriesMetadata(url) {
|
|
5
|
+
const [countries_metadata, setCountriesMetadata] = React.useState([]);
|
|
6
|
+
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
superagent
|
|
9
|
+
.get(url)
|
|
10
|
+
.set('accept', 'json')
|
|
11
|
+
.then((resp) => {
|
|
12
|
+
const res = JSON.parse(resp.text);
|
|
13
|
+
setCountriesMetadata(res);
|
|
14
|
+
});
|
|
15
|
+
}, [url]);
|
|
16
|
+
|
|
17
|
+
return countries_metadata;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import worldSVG from '@plone/volto/icons/world.svg';
|
|
2
|
+
import Edit from './Edit';
|
|
3
|
+
import View from './View';
|
|
4
|
+
|
|
5
|
+
export default function installCountryMapHeatIndex(config) {
|
|
6
|
+
config.blocks.blocksConfig.countryMapHeatIndex = {
|
|
7
|
+
id: 'countryMapHeatIndex',
|
|
8
|
+
title: 'Country Map Observatory Heat Index',
|
|
9
|
+
icon: worldSVG,
|
|
10
|
+
group: 'common',
|
|
11
|
+
edit: Edit,
|
|
12
|
+
view: View,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return config;
|
|
16
|
+
}
|