diff --git a/src/client/actions/index.js b/src/client/actions/index.js index 97ef84726fc9df1fb55753be3035b6765f57a32c..0258d1b933f7341eb7f6522dd499c829a0984eb6 100644 --- a/src/client/actions/index.js +++ b/src/client/actions/index.js @@ -134,8 +134,9 @@ export const fetchManuscriptsFailed = (error) => ({ }); // Places -export const fetchPlaces = () => ({ +export const fetchPlaces = variant => ({ type: FETCH_PLACES, + variant }); export const updatePlaces = ({ places }) => ({ type: UPDATE_PLACES, diff --git a/src/client/components/Deck.js b/src/client/components/Deck.js index b5a654fed1283c107630addbe852019f4af60d3d..7973f696dfc6f2021e16919edaa92b77adc9bc99 100644 --- a/src/client/components/Deck.js +++ b/src/client/components/Deck.js @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { withStyles } from '@material-ui/core/styles'; +import { has } from 'lodash'; import DeckGL, { ArcLayer } from 'deck.gl'; import ReactMapGL, { NavigationControl, HTMLOverlay } from 'react-map-gl'; import 'mapbox-gl/dist/mapbox-gl.css'; @@ -78,7 +79,7 @@ class Deck extends React.Component { } componentDidMount() { - this.props.fetchPlaces(); + this.props.fetchPlaces('migrations'); } parseCoordinates = (coords) => { @@ -172,9 +173,14 @@ class Deck extends React.Component { render() { // console.log(this.props.data) + let arcData = []; + if (has(this.props.data[0], 'to')) { + arcData = this.props.data; + } + const layer = new ArcLayer({ id: 'arc-layer', - data: this.props.data, + data: arcData, pickable: true, //getStrokeWidth: d => this.getStrokeWidth(d.manuscriptCount), getStrokeWidth: 1, diff --git a/src/client/components/LeafletMap.js b/src/client/components/LeafletMap.js index b3d59a215b07005238d464f43d1a20c33cb3c660..a3d36267f3ada1d35e50897b06971489c9b1681e 100644 --- a/src/client/components/LeafletMap.js +++ b/src/client/components/LeafletMap.js @@ -47,7 +47,7 @@ class LeafletMap extends React.Component { componentDidMount() { //this.props.fetchManuscripts(); - this.props.fetchPlaces(); + this.props.fetchPlaces('creationPlaces'); // Base layers const OSMBaseLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { @@ -117,7 +117,7 @@ class LeafletMap extends React.Component { L.Marker.setBouncingOptions({ exclusive: true }); - L.control.sidebar({ container: 'sidebar' }).addTo(this.leafletMap).open('home'); + //L.control.sidebar({ container: 'sidebar' }).addTo(this.leafletMap).open('home'); } @@ -302,7 +302,7 @@ class LeafletMap extends React.Component { render() { return ( <div className="leaflet-container"> - <LeafletSidebar /> + {/*<LeafletSidebar />*/} <div id="map" style={style} /> </div> ); diff --git a/src/client/components/NavTabs.js b/src/client/components/NavTabs.js index 52bde04ce64b4dda278d0fffff8b3edf50635aa5..7a0f03619c38d1c436f86a7154467302e76322ee 100644 --- a/src/client/components/NavTabs.js +++ b/src/client/components/NavTabs.js @@ -10,10 +10,10 @@ const NavTabs = (props) => { // <Tab value="migrationMap" label="migrations" /> return ( <Tabs value={props.resultFormat} onChange={handleChange}> - { /* <Tab value="table" label="Table" /> - <Tab value="creationPlaceMap" label="creation places" /> */} - <Tab value="migrationMap" label="migrations" /> - { /* <Tab value="statistics" label="Statistics" /> */} + <Tab value="table" label="Table" /> + <Tab value="creationPlaces" label="creation places" /> + <Tab value="migrations" label="migrations" /> + <Tab value="statistics" label="Statistics" /> </Tabs> ); }; diff --git a/src/client/containers/MapApp.js b/src/client/containers/MapApp.js index 1abda3df91483d7df721927453ed12ee4a7e7c64..42f97d661442cbe1590bf85d8e1596fe4b4bce84 100644 --- a/src/client/containers/MapApp.js +++ b/src/client/containers/MapApp.js @@ -188,7 +188,7 @@ let MapApp = (props) => { } let mapElement = ''; - if ((oneColumnView && options.resultFormat === 'creationPlaceMap') || (!oneColumnView)) { + if ((oneColumnView && options.resultFormat === 'creationPlaces') || (!oneColumnView)) { mapElement = ( <LeafletMap fetchPlaces={props.fetchPlaces} @@ -207,7 +207,7 @@ let MapApp = (props) => { /> ); } - if ((oneColumnView && options.resultFormat === 'migrationMap') || (!oneColumnView)) { + if ((oneColumnView && options.resultFormat === 'migrations') || (!oneColumnView)) { mapElement = <Deck data={creationPlaces} fetchPlaces={props.fetchPlaces} @@ -232,7 +232,7 @@ let MapApp = (props) => { mainResultsView = table; break; } - case 'creationPlaceMap': { + case 'creationPlaces': { mainResultsView = ( <div className={classes.fullMap}> {mapElement} @@ -240,7 +240,7 @@ let MapApp = (props) => { ); break; } - case 'migrationMap': { + case 'migrations': { mainResultsView = ( <div className={classes.fullMap}> {mapElement} diff --git a/src/client/epics/index.js b/src/client/epics/index.js index 461d646d1f61b3d16e04e1ad116736b94351cfd0..49da7684ac465dd9ac6ceb5d2bd67ae91a063688 100644 --- a/src/client/epics/index.js +++ b/src/client/epics/index.js @@ -38,9 +38,9 @@ const getManuscripts = action$ => action$.pipe( const getPlaces = action$ => action$.pipe( ofType(FETCH_PLACES), - mergeMap(() => { + mergeMap(action => { const searchUrl = apiUrl + 'places'; - const requestUrl = `${searchUrl}`; + const requestUrl = `${searchUrl}?variant=${action.variant}`; return ajax.getJSON(requestUrl).pipe( map(response => updatePlaces({ places: response })) ); diff --git a/src/client/reducers/options.js b/src/client/reducers/options.js index 8cf9a4be7b1bbdb30f356603888eaee02e83d01c..21908ba99c78d64578c8c907e605d84f4f7fd0cb 100644 --- a/src/client/reducers/options.js +++ b/src/client/reducers/options.js @@ -5,7 +5,7 @@ import { } from '../actions'; const DEFAULT_LANGUAGE = 'en'; -const DEFAULT_RESULT_FORMAT = 'migrationMap'; +const DEFAULT_RESULT_FORMAT = 'creationPlaces'; const DEFAULT_MAP_MODE = 'cluster'; export const INITIAL_STATE = { diff --git a/src/server/index.js b/src/server/index.js index 66ecbe6cc8de5fc99cc0dc740f1227c1864b89b7..002ee3687cbb7345f2b0a115de050a2d19170b53 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -71,7 +71,8 @@ app.get('/places/:placeId?', (req, res) => { return res.sendStatus(500); }); } else { - return getPlaces().then((data) => { + const variant = req.query.variant ? req.query.variant : 'creationPlaces'; + return getPlaces(variant).then((data) => { // console.log(data); res.json(data); }) diff --git a/src/server/sparql/Datasets.js b/src/server/sparql/Datasets.js index 1fcce0c22d62bd4cf526187d416655361d00d948..cd5e8bb338e0fd8abc646c6da7db6b1e877dc4d1 100644 --- a/src/server/sparql/Datasets.js +++ b/src/server/sparql/Datasets.js @@ -188,7 +188,7 @@ module.exports = { } GROUP BY ?id ?manuscriptRecord `, - 'placesQuery': ` + 'creationPlacesQuery': ` PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX wgs84: <http://www.w3.org/2003/01/geo/wgs84_pos#> PREFIX dc: <http://purl.org/dc/elements/1.1/> diff --git a/src/server/sparql/Manuscripts.js b/src/server/sparql/Manuscripts.js index 124b49462e420746d20b2029a9ca01d00a31feb0..24e38a7b018482f9de0359cff2b8abe8998b71c4 100644 --- a/src/server/sparql/Manuscripts.js +++ b/src/server/sparql/Manuscripts.js @@ -25,12 +25,10 @@ export const getManuscriptCount = (filterObj) => { return sparqlSearchEngine.doSearch(countQuery, endpoint, mapCount); }; -export const getPlaces = () => { - const { endpoint, migrationsQuery } = datasetConfig['mmm']; - //const { endpoint, placesQuery } = datasetConfig['mmm']; - //console.log(migrationsQuery) - return sparqlSearchEngine.doSearch(migrationsQuery, endpoint, makeObjectList); - //return sparqlSearchEngine.doSearch(placesQuery, endpoint, makeObjectList); +export const getPlaces = variant => { + console.log(variant) + const config = datasetConfig['mmm']; + return sparqlSearchEngine.doSearch(config[`${variant}Query`], config.endpoint, makeObjectList); }; export const getPlace = (id) => {