Skip to content

Commit 9422dcf

Browse files
committed
Merge branch 'dev'
2 parents 4e62647 + 5f8345b commit 9422dcf

15 files changed

Lines changed: 237 additions & 242 deletions

Jenkinsfile

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pipeline {
22
agent {
33
docker {
44
image 'node:latest'
5-
args '-p 3011:3000'
5+
args '-p 3000:3000'
66
}
77
}
88
environment {
@@ -25,4 +25,31 @@ pipeline {
2525
}
2626
}
2727
}
28-
}
28+
post {
29+
always {
30+
script {
31+
properties([[$class: 'GithubProjectProperty',
32+
projectUrlStr: 'https://github.com/clarity-h2020/map-component']])
33+
}
34+
step([$class: 'GitHubIssueNotifier',
35+
issueAppend: true,
36+
issueReopen: false,
37+
issueLabel: 'CI',
38+
issueTitle: '$JOB_NAME $BUILD_DISPLAY_NAME failed'])
39+
}
40+
failure {
41+
emailext attachLog: true,
42+
to: "pascal@cismet.de",
43+
subject: "Build failed in Jenkins: ${currentBuild.fullDisplayName}",
44+
body: """<p>FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
45+
<p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>"""
46+
}
47+
unstable {
48+
emailext attachLog: true,
49+
to: "pascal@cismet.de",
50+
subject: "Jenkins build became unstable: ${currentBuild.fullDisplayName}",
51+
body: """<p>UNSTABLE: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
52+
<p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>"""
53+
}
54+
}
55+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clarity-map-component",
3-
"version": "2.4.6",
3+
"version": "2.5.0",
44
"private": true,
55
"license": "LGPL",
66
"dependencies": {
@@ -14,6 +14,7 @@
1414
"leaflet-loading": "latest",
1515
"leaflet-providers": "git://github.com/leaflet-extras/leaflet-providers#semver:^1.8.0",
1616
"leaflet.nontiledlayer": "^1.0.8",
17+
"leaflet.sync": "^0.2.4",
1718
"loglevel": "^1.6.6",
1819
"prop-types": "latest",
1920
"query-string": "^6.10.1",

src/App.js

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,25 @@ export default class App extends React.Component {
2727
<Route exact path={`${process.env.PUBLIC_URL}/ResourcePreviewMap/`} component={GenericMap} />
2828
<Route exact path={`${process.env.PUBLIC_URL}/DataPackagePreviewMap/`} component={GenericMap} />
2929
<Route exact path={`${process.env.PUBLIC_URL}/StudyPreviewMap/`} component={GenericMap} />
30-
<Route
31-
exact
32-
path={`${process.env.PUBLIC_URL}/CharacteriseHazardMap/`}
33-
component={CharacteriseHazardMap}
34-
/>
30+
<Route exact path={`${process.env.PUBLIC_URL}/CharacteriseHazardMap/`} component={CharacteriseHazardMap} />
3531
<Route exact path={`${process.env.PUBLIC_URL}/ExposureMap/`} component={ExposureMap} />
36-
<Route
37-
exact
38-
path={`${process.env.PUBLIC_URL}/HazardLocalEffectsMap/`}
39-
component={HazardLocalEffectsMap}
40-
/>
41-
<Route
42-
exact
43-
path={`${process.env.PUBLIC_URL}/RiskAndImpactMap/`}
44-
component={RiskAndImpactMap}
45-
/>
46-
<Route
47-
exact
48-
path={`${process.env.PUBLIC_URL}/VulnerabilityMap/`}
49-
component={VulnerabilityMap}
50-
/>
32+
<Route exact path={`${process.env.PUBLIC_URL}/HazardLocalEffectsMap/`} component={HazardLocalEffectsMap} />
33+
<Route exact path={`${process.env.PUBLIC_URL}/RiskAndImpactMap/`} component={RiskAndImpactMap} />
34+
<Route exact path={`${process.env.PUBLIC_URL}/VulnerabilityMap/`} component={VulnerabilityMap} />
5135
<Route exact path={`${process.env.PUBLIC_URL}/StudyArea/`} component={StudyArea} />
36+
37+
38+
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedGenericMap/`} render={(props) => <GenericMap {...props} isSynchronised={true} />} />
39+
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedCharacteriseHazardMap/`} render={(props) => <CharacteriseHazardMap {...props} isSynchronised={true} />} />
40+
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedExposureMap/`} render={(props) => <ExposureMap {...props} isSynchronised={true} />} />
41+
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedHazardLocalEffectsMap/`} render={(props) => <HazardLocalEffectsMap {...props} isSynchronised={true} />} />
42+
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedRiskAndImpactMap/`} render={(props) => <RiskAndImpactMap {...props} isSynchronised={true} />} />
43+
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedVulnerabilityMap/`} render={(props) => <VulnerabilityMap {...props} isSynchronised={true} />} />
44+
5245
<Route exact path={process.env.PUBLIC_URL} component={GenericMap} />
5346
</Switch>
5447
</BrowserRouter>
5548
</main>
5649
);
5750
}
58-
}
51+
}

src/MapComp.css

Lines changed: 0 additions & 69 deletions
This file was deleted.

src/__tests__/CSISHelpers.test.js

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@
1010

1111
import axios from 'axios';
1212
import log from 'loglevel';
13-
import { CSISHelpers } from 'csis-helpers-js';
1413
import express from 'express';
14+
15+
// required because of https://github.com/clarity-h2020/simple-table-component/issues/4#issuecomment-595114163
16+
import 'react-app-polyfill/ie9';
17+
import 'react-app-polyfill/stable';
18+
19+
import { CSISHelpers } from 'csis-helpers-js';
1520
import apiResponseStudy from './../__fixtures__/study.json';
1621
import apiResponseDataPackage from './../__fixtures__/dataPackage.json';
1722
import apiResponseResources from './../__fixtures__/resources.json';
@@ -21,6 +26,9 @@ const app = express();
2126
var server;
2227

2328
beforeAll(() => {
29+
// required because of https://github.com/clarity-h2020/map-component/issues/43#issuecomment-595621339
30+
axios.defaults.adapter = require('axios/lib/adapters/http');
31+
2432
app.get('/jsonapi/group/study', function(req, res) {
2533
res.json(apiResponseStudy);
2634
});
@@ -41,14 +49,21 @@ beforeAll(() => {
4149
res.json(apiResponseResources);
4250
});
4351

44-
server = app.listen(31336, () => log.debug('Example app listening on port 31336!'));
52+
// this is just unbelievable: log.debug() is not printed to console when running the tests in VSCode. WTF?!
53+
server = app.listen(0, () => log.debug(`Example app listening on http://${server.address().address}:${server.address().port}`));
54+
log.debug(`Example app listening on http://${server.address().address}:${server.address().port}`);
4555
});
4656

4757
test('test extract study area from study json', async (done) => {
4858

49-
const response = await axios.get(
50-
'http://localhost:31336/jsonapi/group/study?filter[id][condition][path]=id&filter[id][condition][operator]=%3D&filter[id][condition][value]=c3609e3e-f80f-482b-9e9f-3a26226a6859'
51-
);
59+
// does not work if bound d to ipv6 adaress. :-()
60+
// const url = `http://${server.address().address}:${server.address().port}/jsonapi/group/study?filter[id][condition][path]=id&filter[id][condition][operator]=%3D&filter[id][condition][value]=c3609e3e-f80f-482b-9e9f-3a26226a6859`;
61+
const url = `http://localhost:${server.address().port}/jsonapi/group/study?filter[id][condition][path]=id&filter[id][condition][operator]=%3D&filter[id][condition][value]=c3609e3e-f80f-482b-9e9f-3a26226a6859`;
62+
// unbelievable: does not print to console. See https://github.com/facebook/jest/issues/2441
63+
log.info(url);
64+
const response = await axios.get(url);
65+
// -> error 400 ?! This used to work with a fixed port. since simple things like logging don't seem
66+
// to be possible with jest, and debugging tests in vscode works only 50% of the time, we disable this test.
5267

5368
expect.assertions(5);
5469
expect(response).toBeDefined();
@@ -158,8 +173,16 @@ test('check for emikat id in study', () => {
158173

159174
afterAll(() => {
160175
log.debug('afterAll');
161-
server.close(() => {
162-
//console.log('JSON Server closed');
163-
//process.exit(0);
164-
});
176+
if(server) {
177+
server.close(() => {
178+
//console.log('JSON Server closed');
179+
//process.exit(0);
180+
});
181+
} else {
182+
// WTF?!!!!
183+
// https://github.com/clarity-h2020/map-component/issues/43#issuecomment-595637179
184+
185+
// unfortunely, we'll never see this because of https://github.com/facebook/jest/issues/2441
186+
log.warn('server undefined');
187+
}
165188
});

src/__tests__/CSISRemoteHelpers.test.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
import axios from 'axios';
1414
import log from 'loglevel';
15+
16+
// required because of https://github.com/clarity-h2020/simple-table-component/issues/4#issuecomment-595114163
17+
import 'react-app-polyfill/ie9';
18+
import 'react-app-polyfill/stable';
19+
1520
import { CSISRemoteHelpers, CSISHelpers } from 'csis-helpers-js';
1621

1722
import apiResponseStudy from './../__fixtures__/study.json';
@@ -22,6 +27,9 @@ log.enableAll();
2227
* Set auth headers for live API test
2328
*/
2429
beforeAll(async (done) => {
30+
// required because of https://github.com/clarity-h2020/map-component/issues/43#issuecomment-595621339
31+
axios.defaults.adapter = require('axios/lib/adapters/http');
32+
2533
jest.setTimeout(60000);
2634
let cookie = process.env.COOKIE;
2735

@@ -114,7 +122,7 @@ describe('Remote API tests with authentication', () => {
114122
done();
115123
});
116124

117-
it.only('[DEV] test get complete Study', async (done) => {
125+
it('[DEV] test get complete Study', async (done) => {
118126
const studyGroupNode = await CSISRemoteHelpers.getStudyGroupNodeFromCsis(
119127
undefined,
120128
'c3609e3e-f80f-482b-9e9f-3a26226a6859'

src/__tests__/EMIKATHelpers.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
* ***************************************************
99
*/
1010

11-
import { EMIKATHelpers } from 'csis-helpers-js';
11+
// required because of https://github.com/clarity-h2020/simple-table-component/issues/4#issuecomment-595114163
12+
import 'react-app-polyfill/ie9';
13+
import 'react-app-polyfill/stable';
14+
15+
import { EMIKATHelpers } from 'csis-helpers-js';
1216

1317
test('[RELEASE] URL without EmikatId', () => {
1418
const url =

src/components/CharacteriseHazardMap.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import React from 'react';
2-
import MapComponent from './commons/MapComponent';
3-
import BasicMap from './commons/BasicMap';
1+
import GenericMap from './GenericMap';
42

5-
export default class CharacteriseHazardMap extends BasicMap {
3+
export default class CharacteriseHazardMap extends GenericMap {
64
constructor(props) {
75
// FIXME: Warning: CharacteriseHazardMap(...): When calling super() in `CharacteriseHazardMap`,
86
// make sure to pass up the same props that your component's constructor was passed.
@@ -33,20 +31,4 @@ export default class CharacteriseHazardMap extends BasicMap {
3331
console.log('characteriseHazard-map -> process URL: ' + url);
3432
return super.processUrl(resource, includedArray, url);
3533
}
36-
37-
/**
38-
* Render the map
39-
*/
40-
render() {
41-
return (
42-
<MapComponent
43-
loading={this.state.loading}
44-
bounds={this.state.bounds}
45-
baseLayers={this.state.baseLayers}
46-
overlays={this.state.overlays}
47-
studyAreaPolygon={this.state.studyAreaPolygon}
48-
exclusiveGroups={this.state.exclusiveGroups}
49-
/>
50-
);
51-
}
5234
}

src/components/ExposureMap.js

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import React from 'react';
2-
import MapComponent from './commons/MapComponent';
3-
import BasicMap from './commons/BasicMap';
1+
import GenericMap from './GenericMap';
42

5-
export default class ExposureMap extends BasicMap {
3+
export default class ExposureMap extends GenericMap {
64
constructor(props) {
75
super({ ...props, mapSelectionId: 'eu-gl:exposure-evaluation' });
86

@@ -15,27 +13,4 @@ export default class ExposureMap extends BasicMap {
1513
loading: true
1614
};
1715
}
18-
19-
/**
20-
* Render the map
21-
*/
22-
render() {
23-
if (
24-
!this.queryParams ||
25-
(!this.queryParams.study_uuid && !this.queryParams.resource_uuid && !this.queryParams.datapackage_uuid)
26-
) {
27-
return super.render();
28-
}
29-
30-
return (
31-
<MapComponent
32-
loading={this.state.loading}
33-
bounds={this.state.bounds}
34-
baseLayers={this.state.baseLayers}
35-
overlays={this.state.overlays}
36-
exclusiveGroups={this.state.exclusiveGroups}
37-
studyAreaPolygon={this.state.studyAreaPolygon}
38-
/>
39-
);
40-
}
4116
}

0 commit comments

Comments
 (0)