Newer
Older
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import withWidth from '@material-ui/core/withWidth';
import compose from 'recompose/compose';
import Paper from '@material-ui/core/Paper';
import VirtualizedTable from '../components/VirtualizedTable';
import ResultTable from '../components/ResultTable';
import LeafletMap from '../components/map/LeafletMap';
import GMap from '../components/map/GMap';
import CircularProgress from '@material-ui/core/CircularProgress';
import purple from '@material-ui/core/colors/purple';
getVisibleResults,
getVisibleValues
} from '../selectors';
import {
updateQuery,
fetchSuggestions,
clearSuggestions,
fetchManuscripts,
fetchPlaces,
clearManuscripts,
clearPlaces,
openMarkerPopup,
removeTempMarker
} from '../actions';
const styles = theme => ({
root: {
flexGrow: 1,
height: '100%',
},
minWidth: 640,
minHeight: 700
display: 'flex',
width: '100%',
height: 'calc(100% - 128px)',
borderRight: '4px solid' + theme.palette.primary.main,
borderLeft: '4px solid' + theme.palette.primary.main,
},
resultTable: {
width: 1024,
height: 'calc(100% - 5px)',
borderRight: '4px solid' + theme.palette.primary.main,
},
resultTableOneColumn: {
width: '100%',
height: 'calc(100% - 5px)',
},
rightColumn: {
height: '100%',
width: 'calc(100% - 1024px)',
width: '100%',
height: '50%',
borderBottom: '4px solid' + theme.palette.primary.main,
fullMap: {
width: '100%',
height: '100%',
},
width: '100%',
height: '50%',
statisticsOneColumn: {
width: '100%',
height: '100%',
},
progress: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
footer: {
position: 'absolute',
borderTop: '4px solid' + theme.palette.primary.main,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
bottom: 0,
width: '100%',
height: 64,
background: theme.palette.primary.main,
borderRadius: 0,
},
aaltoLogo: {
//paddingLeft: 24,
height: 37
},
uhLogo: {
paddingLeft: 44,
height: 52
},
secoLogo: {
paddingLeft: 44,
height: 52
},
heldigLogo: {
paddingLeft: 44,
height: 37
},
kotusLogo: {
paddingLeft: 44,
height: 50
},
});
let MapApp = (props) => {
const { classes, options, browser, search, map, manuscripts, creationPlaces, facetValues } = props;
let oneColumnView = true;
//console.log(manuscripts)
let table = '';
if (search.fetchingManuscripts) {
const tableClass = oneColumnView ? classes.resultTableOneColumn : classes.resultTable;
<div className={[tableClass, classes.progress].join(' ')}>
<Typography className={classes.progressTitle} variant="display1">Fetching manuscript data</Typography>
<CircularProgress style={{ color: purple[500] }} thickness={5} />
} else {
if ((oneColumnView && options.resultFormat === 'table') || (!oneColumnView)) {
//console.log(facetValues)
table = (
<div className={oneColumnView ? classes.resultTableOneColumn : classes.resultTable}>
<ResultTable
rows={manuscripts}
facetValues={facetValues}
fetchFacet={props.fetchFacet}
let mapElement = '';
if ((oneColumnView && options.resultFormat === 'map') || (!oneColumnView)) {
if (options.mapMode === 'heatmap') {
mapElement = (
googleMapURL="https://maps.googleapis.com/maps/api/js?key=AIzaSyCKWw5FjhwLsfp_l2gjVAifPkT3cxGXhA4&v=3.exp&libraries=geometry,drawing,places,visualization"
loadingElement={<div style={{ height: `100%` }} />}
containerElement={<div style={{ height: `100%` }} />}
mapElement={<div style={{ height: `100%` }} />}
/>
);
} else {
mapElement = (
fetchPlaces={props.fetchPlaces}
fetchManuscripts={props.fetchManuscripts}
mapMode={options.mapMode}
geoJSON={map.geoJSON}
geoJSONKey={map.geoJSONKey}
bouncingMarker={map.bouncingMarker}
popupMarker={map.popupMarker}
bouncingMarkerKey={map.bouncingMarkerKey}
openPopupMarkerKey={map.openPopupMarkerKey}
/>
);
}
}
let statistics = '';
if ((oneColumnView && options.resultFormat === 'statistics') || (!oneColumnView)) {
<div className={oneColumnView ? classes.statisticsOneColumn : classes.statistics}>
<Pie data={creationPlaces} groupBy={props.search.groupBy} query={props.search.query} />
}
let mainResultsView = '';
if (oneColumnView) {
switch(options.resultFormat) {
case 'table': {
mainResultsView = table;
break;
}
case 'map': {
mainResultsView = (
<div className={classes.fullMap}>
</div>
);
break;
}
case 'statistics': {
mainResultsView = statistics;
break;
}
}
} else {
mainResultsView = table;
return (
<div className={classes.root}>
<div className={classes.appFrame}>
<TopBar
oneColumnView={oneColumnView}
mapMode={options.mapMode}
resultFormat={options.resultFormat}
updateMapMode={props.updateMapMode}
updateResultFormat={props.updateResultFormat}
datasets={search.datasets}
toggleDataset={props.toggleDataset}
<div className={classes.mainContainer}>
{mainResultsView}
{!oneColumnView &&
<div className={classes.rightColumn}>
<div className={classes.map}>
{mapElement}
<Paper className={classes.footer}>
<img className={classes.aaltoLogo} src='img/logos/aalto-logo-white-no-background-small.png' alt='Aalto University logo'/>
<img className={classes.uhLogo} src='img/logos/university-of-helsinki-logo-white-no-background-small.png' alt='University of Helsinki logo'/>
<img className={classes.secoLogo} src='img/logos/seco-logo-white-no-background-small.png' alt='SeCo logo'/>
<img className={classes.heldigLogo} src='img/logos/heldig-logo-small.png' alt='HELDIG logo'/>
</div>
</div>
);
};
const mapStateToProps = (state) => {
return {
options: state.options,
browser: state.browser,
map: state.map,
manuscripts: getVisibleResults(state.search),
manuscriptsPropertyValues: getVisibleValues(state.search),
creationPlaces: state.search.places,
facetValues: state.facet.values
const mapDispatchToProps = ({
updateQuery,
fetchSuggestions,
clearSuggestions,
fetchManuscripts,
fetchPlaces,
clearManuscripts,
clearPlaces,
bounceMarker,
openMarkerPopup,
removeTempMarker
});
MapApp.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
//error: PropTypes.object.isRequired,
browser: PropTypes.object.isRequired,
options: PropTypes.object.isRequired,
search: PropTypes.object.isRequired,
map: PropTypes.object.isRequired,
manuscriptsPropertyValues: PropTypes.object.isRequired,
facetValues: PropTypes.array.isRequired,
updateQuery: PropTypes.func.isRequired,
fetchSuggestions: PropTypes.func.isRequired,
clearSuggestions: PropTypes.func.isRequired,
fetchManuscripts: PropTypes.func.isRequired,
fetchPlaces: PropTypes.func.isRequired,
fetchFacet: PropTypes.func.isRequired,
clearManuscripts: PropTypes.func.isRequired,
clearPlaces: PropTypes.func.isRequired,
clearFacet: PropTypes.func.isRequired,
openMarkerPopup: PropTypes.func.isRequired,
removeTempMarker: PropTypes.func.isRequired,
updateResultFormat: PropTypes.func.isRequired,
updateMapMode: PropTypes.func.isRequired,
updateResultsFilter: PropTypes.func.isRequired,
export default compose(
connect(
mapStateToProps,
mapDispatchToProps
),
withWidth(),
withStyles(styles, {withTheme: true}),
)(MapApp);