Skip to content
Snippets Groups Projects
Commit 336cb969 authored by Esko Ikkala's avatar Esko Ikkala
Browse files

Add result format options when the app is in oneColumView

parent 2dbe6f08
No related branches found
No related tags found
No related merge requests found
...@@ -3,29 +3,22 @@ import PropTypes from 'prop-types'; ...@@ -3,29 +3,22 @@ import PropTypes from 'prop-types';
import Tabs from '@material-ui/core/Tabs'; import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab'; import Tab from '@material-ui/core/Tab';
class NavTabs extends React.Component { const NavTabs = (props) => {
state = { const handleChange = (event, value) => {
value: 0, props.updateResultFormat(value);
}; };
return (
handleChange = (event, value) => { <Tabs value={props.resultFormat} onChange={handleChange}>
this.setState({ value }); <Tab value="table" label="Table" />
}; <Tab value="map" label="Map" />
<Tab value="statistics" label="Statistics" />
render() { </Tabs>
const { value } = this.state; );
return ( };
<Tabs value={value} onChange={this.handleChange}>
<Tab label="Table" />
<Tab label="Map" />
<Tab label="Statistics" />
</Tabs>
);
}
}
NavTabs.propTypes = { NavTabs.propTypes = {
resultView: PropTypes.string, resultFormat: PropTypes.string.isRequired,
updateResultFormat: PropTypes.func.isRequired
}; };
export default NavTabs; export default NavTabs;
...@@ -108,7 +108,10 @@ class TopBar extends React.Component { ...@@ -108,7 +108,10 @@ class TopBar extends React.Component {
<img className={classes.namesampoLogo} src='img/logos/namesampo.png' alt='NameSampo logo'/> <img className={classes.namesampoLogo} src='img/logos/namesampo.png' alt='NameSampo logo'/>
{this.props.oneColumnView && {this.props.oneColumnView &&
<div className={classes.navTabs}> <div className={classes.navTabs}>
<NavTabs /> <NavTabs
resultFormat={this.props.resultFormat}
updateResultFormat={this.props.updateResultFormat}
/>
</div> </div>
} }
</Toolbar> </Toolbar>
...@@ -121,6 +124,8 @@ TopBar.propTypes = { ...@@ -121,6 +124,8 @@ TopBar.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
oneColumnView: PropTypes.bool.isRequired, oneColumnView: PropTypes.bool.isRequired,
mapMode: PropTypes.string.isRequired, mapMode: PropTypes.string.isRequired,
resultFormat: PropTypes.string.isRequired,
updateResultFormat: PropTypes.func.isRequired,
updateMapMode: PropTypes.func.isRequired, updateMapMode: PropTypes.func.isRequired,
}; };
......
...@@ -76,6 +76,10 @@ const styles = theme => ({ ...@@ -76,6 +76,10 @@ const styles = theme => ({
height: '50%', height: '50%',
borderBottom: '4px solid' + theme.palette.primary.main, borderBottom: '4px solid' + theme.palette.primary.main,
}, },
fullMap: {
width: '100%',
height: '100%',
},
statistics: { statistics: {
width: '100%', width: '100%',
height: '50%', height: '50%',
...@@ -115,37 +119,95 @@ const styles = theme => ({ ...@@ -115,37 +119,95 @@ const styles = theme => ({
}); });
let MapApp = (props) => { let MapApp = (props) => {
const { classes, mapMode, browser } = props; const { classes, mapMode, resultFormat, browser } = props;
//error, //error,
let oneColumnView = true; let oneColumnView = browser.lessThan.extraLarge;
if (browser.greaterThan.extraLarge) {
oneColumnView = false; // console.log('oneColumnView', oneColumnView)
// console.log('resultFormat', resultFormat)
// console.log('mapMode', mapMode)
let table = '';
if ((oneColumnView && resultFormat === 'table') || (!oneColumnView)) {
table = (
<div className={oneColumnView ? classes.resultTableOneColumn : classes.resultTable}>
<VirtualizedTable
list={Immutable.List(props.results)}
resultValues={props.resultValues}
search={props.search}
sortResults={props.sortResults}
toggleDataset={props.toggleDataset}
updateResultsFilter={props.updateResultsFilter}
updateQuery={props.updateQuery}
fetchResults={props.fetchResults}
clearResults={props.clearResults}
fetchSuggestions={props.fetchSuggestions}
clearSuggestions={props.clearSuggestions}
/>
</div>
);
} }
let map = ''; let map = '';
if (mapMode === 'heatmap') { if ((oneColumnView && resultFormat === 'map') || (!oneColumnView)) {
map = ( if (mapMode === 'heatmap') {
<GMap map = (
results={props.results} <GMap
googleMapURL="https://maps.googleapis.com/maps/api/js?key=AIzaSyCKWw5FjhwLsfp_l2gjVAifPkT3cxGXhA4&v=3.exp&libraries=geometry,drawing,places,visualization" results={props.results}
loadingElement={<div style={{ height: `100%` }} />} googleMapURL="https://maps.googleapis.com/maps/api/js?key=AIzaSyCKWw5FjhwLsfp_l2gjVAifPkT3cxGXhA4&v=3.exp&libraries=geometry,drawing,places,visualization"
containerElement={<div style={{ height: `100%` }} />} loadingElement={<div style={{ height: `100%` }} />}
mapElement={<div style={{ height: `100%` }} />} containerElement={<div style={{ height: `100%` }} />}
/> mapElement={<div style={{ height: `100%` }} />}
/>
);
} else {
map = (
<LeafletMap
sliderValue={100}
results={props.results}
geoJSON={props.geoJSON}
geoJSONKey={props.geoJSONKey}
getGeoJSON={props.getGeoJSON}
mapMode={props.mapMode}
/>
);
}
}
let statistics = '';
if ((oneColumnView && resultFormat === 'statistics') || (!oneColumnView)) {
statistics = (
<div className={classes.statistics}>
<Pie data={props.results} groupBy={props.search.groupBy} query={props.search.query} />
</div>
); );
}
let mainResultsView = '';
if (oneColumnView) {
switch(props.resultFormat) {
case 'table': {
mainResultsView = table;
break;
}
case 'map': {
mainResultsView = (
<div className={classes.fullMap}>
{map}
</div>
);
break;
}
case 'statistics': {
mainResultsView = statistics;
break;
}
}
} else { } else {
map = ( mainResultsView = table;
<LeafletMap
sliderValue={100}
results={props.results}
geoJSON={props.geoJSON}
geoJSONKey={props.geoJSONKey}
getGeoJSON={props.getGeoJSON}
mapMode={props.mapMode}
/>
);
} }
// map = ''; // map = '';
return ( return (
...@@ -154,32 +216,18 @@ let MapApp = (props) => { ...@@ -154,32 +216,18 @@ let MapApp = (props) => {
<TopBar <TopBar
oneColumnView={oneColumnView} oneColumnView={oneColumnView}
mapMode={props.mapMode} mapMode={props.mapMode}
resultFormat={props.resultFormat}
updateMapMode={props.updateMapMode} updateMapMode={props.updateMapMode}
updateResultFormat={props.updateResultFormat}
/> />
<div className={classes.mainContainer}> <div className={classes.mainContainer}>
<div className={oneColumnView ? classes.resultTableOneColumn : classes.resultTable}> {mainResultsView}
<VirtualizedTable
list={Immutable.List(props.results)}
resultValues={props.resultValues}
search={props.search}
sortResults={props.sortResults}
toggleDataset={props.toggleDataset}
updateResultsFilter={props.updateResultsFilter}
updateQuery={props.updateQuery}
fetchResults={props.fetchResults}
clearResults={props.clearResults}
fetchSuggestions={props.fetchSuggestions}
clearSuggestions={props.clearSuggestions}
/>
</div>
{!oneColumnView && {!oneColumnView &&
<div className={classes.rightColumn}> <div className={classes.rightColumn}>
<div className={classes.map}> <div className={classes.map}>
{map} {map}
</div> </div>
<div className={classes.statistics}> {statistics}
<Pie data={props.results} groupBy={props.search.groupBy} query={props.search.query} />
</div>
</div> </div>
} }
</div> </div>
......
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