Skip to content

Commit

Permalink
Merge branch 'feature/096-resource-re-purposing' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
p-a-s-c-a-l committed May 18, 2020
2 parents 37a003a + c4701be commit 4a0188f
Show file tree
Hide file tree
Showing 12 changed files with 26,554 additions and 416 deletions.
46 changes: 46 additions & 0 deletions examples/basic-ee-map.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<html>

<head>
<meta charset="utf-8" />
</head>

<body>
<script>
(function ($, Drupal) {
window.Drupal.behaviors.mapComponentIFrameConnector = {
attach: function (context, drupalSettings) {
// Using once() to apply the mapComponentIFrameConnector effect when you want to run just one function.
$(window, context).once('mapComponentIFrameConnector').each(function () {

const additionalQueryParameters = {
clarityBackgroundLayersTagType:'taxonomy_term--dp_resourcetype',
clarityBackgroundLayersTagName:'clarity-background-layer',
clarityBackgroundLayersGroupName:'Elements at Risk',
overlayLayersTagType:'taxonomy_term--eu_gl',
overlayLayersTagName:'Exposure Evaluation',
overlayLayersGroupName:'Additional Elements at Risk',
overlayLayersGroupingTagType:'taxonomy_term--elements_at_risk'
};

const mapType = 'SynchronisedGenericMap';
const grouping_tag = 'taxonomy_term--hazards'; //deprecated
const iFrameMapComponent = document.getElementById('map-component');

if (undefined !== drupalSettings && undefined !== drupalSettings.csisHelpers && undefined !== drupalSettings.csisHelpers.initMapComponent) {
drupalSettings.csisHelpers.initMapComponent(mapType, grouping_tag, iFrameMapComponent, additionalQueryParameters);
return;
} else {
console.error('no global drupalSettings object found, probably not connected to Drupal!');
}
});
}
};

})(jQuery, Drupal);
</script>

<iframe name="map-component" id="map-component"
src="https://csis.myclimateservice.eu/apps/map-component/build/loader.html" style="width:100%;height:500px;">
</iframe>
</body>
</html>
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{
"name": "clarity-map-component",
"version": "2.5.1",
"version": "2.6.0",
"private": true,
"license": "LGPL",
"dependencies": {
"@turf/boolean-within": "latest",
"browserslist": "^4.12.0",
"csis-helpers-js": "git://github.com/clarity-h2020/csis-helpers-js.git#semver:^0.5.4",
"handlebars": "^4.7.6",
"browserslist": "^4.11.0",
"csis-helpers-js": "git://github.com/clarity-h2020/csis-helpers-js.git#semver:^0.6.0",
"handlebars": "^4.7.3",
"history": "^4.10.1",
"leaflet": "^1.6.0",
"leaflet-draw": "^1.0.4",
"leaflet-loading": "latest",
"leaflet-providers": "git://github.com/leaflet-extras/leaflet-providers#semver:^1.8.0",
"leaflet.nontiledlayer": "^1.0.8",
"leaflet.sync": "^0.2.4",
"loglevel": "^1.6.8",
"loglevel": "^1.6.7",
"prop-types": "latest",
"query-string": "^6.12.1",
"query-string": "^6.11.1",
"react": "^16.13.1",
"react-compound-slider": "^2.5.0",
"react-dom": "^16.13.1",
"react-leaflet": "^2.7.0",
"react-leaflet": "^2.6.3",
"react-leaflet-draw": "^0.19.0",
"react-leaflet-grouped-layer-control": "git://github.com/clarity-h2020/react-leaflet-grouped-layer-control.git#semver:^0.1.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"turf": "latest",
"wicket": "^1.3.6"
"wicket": "^1.3.5"
},
"resolutions": {
"js-yaml": "^3.13.1",
"handlebars": "^4.7.6",
"browserslist": "^4.12.0"
"handlebars": "^4.7.3",
"browserslist": "^4.11.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down Expand Up @@ -60,7 +60,7 @@
},
"devDependencies": {
"babel-polyfill": "^6.26.0",
"react-styleguidist": "^11.0.6",
"react-styleguidist": "^11.0.4",
"serve": "^11.3.0"
}
}
2 changes: 2 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export const history = createBrowserHistory({
});

/**
* This class is mainly responsible for routing to the correct map component.
*
* @class
*/
export default class App extends React.Component {
Expand Down
26,604 changes: 26,309 additions & 295 deletions src/__fixtures__/dataPackage.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/__tests__/CSISHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ test('find resources with @mapview:ogc:wms references in resource array', () =>
const referenceType = '@mapview:ogc:wms';
const resourcesArray = apiResponseResources.data;
const includedArray = apiResponseResources.included;
const filteredResources = CSISHelpers.filterResourcesbyReferenceType(resourcesArray, includedArray, referenceType);
const filteredResources = CSISHelpers.filterResourcesByReferenceType(resourcesArray, includedArray, referenceType);
expect(filteredResources.length).toBeLessThan(resourcesArray.length);
expect(filteredResources).toHaveLength(30);
});
Expand All @@ -110,7 +110,7 @@ test('find HC resources with @mapview:ogc:wms references in resource array', ()
const resourcesArray = apiResponseResources.data;
const includedArray = apiResponseResources.included;

const filteredResources = CSISHelpers.filterResourcesbyReferenceType(
const filteredResources = CSISHelpers.filterResourcesByReferenceType(
CSISHelpers.filterResourcesbyTagName(resourcesArray, includedArray, tagType, tagName),
includedArray,
referenceType
Expand Down Expand Up @@ -152,14 +152,14 @@ test('get 1st "reference" for first HC resource with @mapview:ogc:wms references
const resourcesArray = apiResponseResources.data;
const includedArray = apiResponseResources.included;

const filteredResources = CSISHelpers.filterResourcesbyReferenceType(
const filteredResources = CSISHelpers.filterResourcesByReferenceType(
CSISHelpers.filterResourcesbyTagName(resourcesArray, includedArray, tagType, tagName),
includedArray,
referenceType
);
expect(filteredResources).not.toBeNull();
expect(filteredResources.length).toBeGreaterThan(0);
const reference = CSISHelpers.extractReferencesfromResource(filteredResources[0], includedArray, referenceType);
const reference = CSISHelpers.extractReferencesFromResource(filteredResources[0], includedArray, referenceType);
expect(reference).not.toBeNull();
expect(reference.length).toBeGreaterThan(0);

Expand Down
5 changes: 4 additions & 1 deletion src/components/CharacteriseHazardMap.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import GenericMap from './GenericMap';

/**
* @deprecated
*/
export default class CharacteriseHazardMap extends GenericMap {
constructor(props) {
// FIXME: Warning: CharacteriseHazardMap(...): When calling super() in `CharacteriseHazardMap`,
// make sure to pass up the same props that your component's constructor was passed.
super({
...props,
mapSelectionId: 'eu-gl:hazard-characterization',
mapSelectionId: 'Hazard Characterization', // deprecated
groupingCriteria: 'taxonomy_term--hazards'
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/ExposureMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import GenericMap from './GenericMap';

export default class ExposureMap extends GenericMap {
constructor(props) {
super({ ...props, mapSelectionId: 'eu-gl:exposure-evaluation' });
super({ ...props, mapSelectionId: 'Exposure Evaluation' }); //deprecated

var overlays = [];
this.state = {
Expand Down
9 changes: 7 additions & 2 deletions src/components/GenericMap.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react';
import log from 'loglevel';

import MapComponent from './commons/MapComponent';
import BasicMap from './commons/BasicMap';

// yes, order of imports do matter
import 'leaflet.sync';

/**
* Generic Map Base class.
*/
export default class GenericMap extends BasicMap {
constructor(props) {
super(props);
Expand All @@ -20,7 +25,7 @@ export default class GenericMap extends BasicMap {
}

/**
* Synchronise Maps. See https://github.com/jieter/Leaflet.Sync
* Synchronised Maps. See https://github.com/jieter/Leaflet.Sync
*/
componentDidUpdate() {
if (this.mapComponentA && this.mapComponentA.leafletMapInstance && this.mapComponentB && this.mapComponentB.leafletMapInstance) {
Expand Down Expand Up @@ -58,7 +63,7 @@ export default class GenericMap extends BasicMap {
}

if (this.props.isSynchronised === true) {
log.info('rendering two sychronised maps');
log.info('rendering two sychronised maps: ' + this.props.isSynchronised);
return (<>
<MapComponent
loading={this.state.loading}
Expand Down
2 changes: 1 addition & 1 deletion src/components/HazardLocalEffectsMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import GenericMap from './GenericMap';

export default class HazardLocalEffectsMap extends GenericMap {
constructor(props) {
super({ ...props, mapSelectionId: 'eu-gl:hazard-characterization:local-effects' });
super({ ...props, mapSelectionId: 'Hazard Characterization - Local Effects' }); // deprecated

var overlays = [];
this.state = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/RiskAndImpactMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default class RiskAndImpactMap extends GenericMap {
constructor(props) {
super({
...props,
mapSelectionId: 'eu-gl:risk-and-impact-assessment',
mapSelectionId: 'Risk and Impact Assessment', //deprecated
groupingCriteria: 'taxonomy_term--hazards'
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/VulnerabilityMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import GenericMap from './GenericMap';
*/
export default class VulnerabilityMap extends GenericMap {
constructor(props) {
super({ ...props, mapSelectionId: 'eu-gl:vulnerability-analysis' });
super({ ...props, mapSelectionId: 'Vulnerability Analysis' }); //deprecated

var overlays = [];
this.state = {
Expand Down
Loading

0 comments on commit 4a0188f

Please sign in to comment.