Skip to content
Snippets Groups Projects
Commit 613f5f47 authored by esikkala's avatar esikkala
Browse files

Parametrize place fetching, show all tabs

parent 51a93edc
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
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,
......
......@@ -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>
);
......
......@@ -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>
);
};
......
......@@ -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}
......
......@@ -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 }))
);
......
......@@ -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 = {
......
......@@ -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);
})
......
......@@ -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/>
......
......@@ -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) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment