Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
p-a-s-c-a-l committed Mar 16, 2020
2 parents 4e62647 + 5f8345b commit 9422dcf
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 242 deletions.
31 changes: 29 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pipeline {
agent {
docker {
image 'node:latest'
args '-p 3011:3000'
args '-p 3000:3000'
}
}
environment {
Expand All @@ -25,4 +25,31 @@ pipeline {
}
}
}
}
post {
always {
script {
properties([[$class: 'GithubProjectProperty',
projectUrlStr: 'https://github.com/clarity-h2020/map-component']])
}
step([$class: 'GitHubIssueNotifier',
issueAppend: true,
issueReopen: false,
issueLabel: 'CI',
issueTitle: '$JOB_NAME $BUILD_DISPLAY_NAME failed'])
}
failure {
emailext attachLog: true,
to: "pascal@cismet.de",
subject: "Build failed in Jenkins: ${currentBuild.fullDisplayName}",
body: """<p>FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>"""
}
unstable {
emailext attachLog: true,
to: "pascal@cismet.de",
subject: "Jenkins build became unstable: ${currentBuild.fullDisplayName}",
body: """<p>UNSTABLE: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at &QUOT;<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>&QUOT;</p>"""
}
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clarity-map-component",
"version": "2.4.6",
"version": "2.5.0",
"private": true,
"license": "LGPL",
"dependencies": {
Expand All @@ -14,6 +14,7 @@
"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.6",
"prop-types": "latest",
"query-string": "^6.10.1",
Expand Down
35 changes: 14 additions & 21 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,25 @@ export default class App extends React.Component {
<Route exact path={`${process.env.PUBLIC_URL}/ResourcePreviewMap/`} component={GenericMap} />
<Route exact path={`${process.env.PUBLIC_URL}/DataPackagePreviewMap/`} component={GenericMap} />
<Route exact path={`${process.env.PUBLIC_URL}/StudyPreviewMap/`} component={GenericMap} />
<Route
exact
path={`${process.env.PUBLIC_URL}/CharacteriseHazardMap/`}
component={CharacteriseHazardMap}
/>
<Route exact path={`${process.env.PUBLIC_URL}/CharacteriseHazardMap/`} component={CharacteriseHazardMap} />
<Route exact path={`${process.env.PUBLIC_URL}/ExposureMap/`} component={ExposureMap} />
<Route
exact
path={`${process.env.PUBLIC_URL}/HazardLocalEffectsMap/`}
component={HazardLocalEffectsMap}
/>
<Route
exact
path={`${process.env.PUBLIC_URL}/RiskAndImpactMap/`}
component={RiskAndImpactMap}
/>
<Route
exact
path={`${process.env.PUBLIC_URL}/VulnerabilityMap/`}
component={VulnerabilityMap}
/>
<Route exact path={`${process.env.PUBLIC_URL}/HazardLocalEffectsMap/`} component={HazardLocalEffectsMap} />
<Route exact path={`${process.env.PUBLIC_URL}/RiskAndImpactMap/`} component={RiskAndImpactMap} />
<Route exact path={`${process.env.PUBLIC_URL}/VulnerabilityMap/`} component={VulnerabilityMap} />
<Route exact path={`${process.env.PUBLIC_URL}/StudyArea/`} component={StudyArea} />


<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedGenericMap/`} render={(props) => <GenericMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedCharacteriseHazardMap/`} render={(props) => <CharacteriseHazardMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedExposureMap/`} render={(props) => <ExposureMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedHazardLocalEffectsMap/`} render={(props) => <HazardLocalEffectsMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedRiskAndImpactMap/`} render={(props) => <RiskAndImpactMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedVulnerabilityMap/`} render={(props) => <VulnerabilityMap {...props} isSynchronised={true} />} />

<Route exact path={process.env.PUBLIC_URL} component={GenericMap} />
</Switch>
</BrowserRouter>
</main>
);
}
}
}
69 changes: 0 additions & 69 deletions src/MapComp.css

This file was deleted.

41 changes: 32 additions & 9 deletions src/__tests__/CSISHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@

import axios from 'axios';
import log from 'loglevel';
import { CSISHelpers } from 'csis-helpers-js';
import express from 'express';

// required because of https://github.com/clarity-h2020/simple-table-component/issues/4#issuecomment-595114163
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';

import { CSISHelpers } from 'csis-helpers-js';
import apiResponseStudy from './../__fixtures__/study.json';
import apiResponseDataPackage from './../__fixtures__/dataPackage.json';
import apiResponseResources from './../__fixtures__/resources.json';
Expand All @@ -21,6 +26,9 @@ const app = express();
var server;

beforeAll(() => {
// required because of https://github.com/clarity-h2020/map-component/issues/43#issuecomment-595621339
axios.defaults.adapter = require('axios/lib/adapters/http');

app.get('/jsonapi/group/study', function(req, res) {
res.json(apiResponseStudy);
});
Expand All @@ -41,14 +49,21 @@ beforeAll(() => {
res.json(apiResponseResources);
});

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

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

const response = await axios.get(
'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'
);
// does not work if bound d to ipv6 adaress. :-()
// 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`;
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`;
// unbelievable: does not print to console. See https://github.com/facebook/jest/issues/2441
log.info(url);
const response = await axios.get(url);
// -> error 400 ?! This used to work with a fixed port. since simple things like logging don't seem
// to be possible with jest, and debugging tests in vscode works only 50% of the time, we disable this test.

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

afterAll(() => {
log.debug('afterAll');
server.close(() => {
//console.log('JSON Server closed');
//process.exit(0);
});
if(server) {
server.close(() => {
//console.log('JSON Server closed');
//process.exit(0);
});
} else {
// WTF?!!!!
// https://github.com/clarity-h2020/map-component/issues/43#issuecomment-595637179

// unfortunely, we'll never see this because of https://github.com/facebook/jest/issues/2441
log.warn('server undefined');
}
});
10 changes: 9 additions & 1 deletion src/__tests__/CSISRemoteHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@

import axios from 'axios';
import log from 'loglevel';

// required because of https://github.com/clarity-h2020/simple-table-component/issues/4#issuecomment-595114163
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';

import { CSISRemoteHelpers, CSISHelpers } from 'csis-helpers-js';

import apiResponseStudy from './../__fixtures__/study.json';
Expand All @@ -22,6 +27,9 @@ log.enableAll();
* Set auth headers for live API test
*/
beforeAll(async (done) => {
// required because of https://github.com/clarity-h2020/map-component/issues/43#issuecomment-595621339
axios.defaults.adapter = require('axios/lib/adapters/http');

jest.setTimeout(60000);
let cookie = process.env.COOKIE;

Expand Down Expand Up @@ -114,7 +122,7 @@ describe('Remote API tests with authentication', () => {
done();
});

it.only('[DEV] test get complete Study', async (done) => {
it('[DEV] test get complete Study', async (done) => {
const studyGroupNode = await CSISRemoteHelpers.getStudyGroupNodeFromCsis(
undefined,
'c3609e3e-f80f-482b-9e9f-3a26226a6859'
Expand Down
6 changes: 5 additions & 1 deletion src/__tests__/EMIKATHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
* ***************************************************
*/

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

import { EMIKATHelpers } from 'csis-helpers-js';

test('[RELEASE] URL without EmikatId', () => {
const url =
Expand Down
22 changes: 2 additions & 20 deletions src/components/CharacteriseHazardMap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import MapComponent from './commons/MapComponent';
import BasicMap from './commons/BasicMap';
import GenericMap from './GenericMap';

export default class CharacteriseHazardMap extends BasicMap {
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.
Expand Down Expand Up @@ -33,20 +31,4 @@ export default class CharacteriseHazardMap extends BasicMap {
console.log('characteriseHazard-map -> process URL: ' + url);
return super.processUrl(resource, includedArray, url);
}

/**
* Render the map
*/
render() {
return (
<MapComponent
loading={this.state.loading}
bounds={this.state.bounds}
baseLayers={this.state.baseLayers}
overlays={this.state.overlays}
studyAreaPolygon={this.state.studyAreaPolygon}
exclusiveGroups={this.state.exclusiveGroups}
/>
);
}
}
29 changes: 2 additions & 27 deletions src/components/ExposureMap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import MapComponent from './commons/MapComponent';
import BasicMap from './commons/BasicMap';
import GenericMap from './GenericMap';

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

Expand All @@ -15,27 +13,4 @@ export default class ExposureMap extends BasicMap {
loading: true
};
}

/**
* Render the map
*/
render() {
if (
!this.queryParams ||
(!this.queryParams.study_uuid && !this.queryParams.resource_uuid && !this.queryParams.datapackage_uuid)
) {
return super.render();
}

return (
<MapComponent
loading={this.state.loading}
bounds={this.state.bounds}
baseLayers={this.state.baseLayers}
overlays={this.state.overlays}
exclusiveGroups={this.state.exclusiveGroups}
studyAreaPolygon={this.state.studyAreaPolygon}
/>
);
}
}
Loading

0 comments on commit 9422dcf

Please sign in to comment.