Commit 9fff2194 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch 'new-map-layers' into 'master'

Include legend in MapLayerConfig

See merge request genesys-pgr/genesys-ui!228
parents d3327e9e 0de4425a
......@@ -93,6 +93,7 @@ module.exports = {
}
}
// console.log('Outgoing headers ' + p, req.headers);
return p;
},
onError(err, req, res) {
......
......@@ -437,17 +437,17 @@
"map": "Map"
},
"climate": {
"bio1": "Annual mean temperature [°c]",
"bio1": "Annual mean temperature [°C]",
"bio2": "Mean diurnal range (mean of monthly (max temp - min temp))",
"bio3": "Isothermality (bio2/bio7) (* 100)",
"bio4": "Temperature seasonality (standard deviation *100)",
"bio5": "Max temperature of warmest month [°c]",
"bio6": "Min temperature of coldest month [°c]",
"bio7": "Temperature annual range (bio5-bio6) [°c]",
"bio8": "Mean temperature of wettest quarter [°c]",
"bio9": "Mean temperature of driest quarter [°c]",
"bio10": "Mean temperature of warmest quarter [°c]",
"bio11": "Mean temperature of coldest quarter [°c]",
"bio5": "Max temperature of warmest month [°C]",
"bio6": "Min temperature of coldest month [°C]",
"bio7": "Temperature annual range (bio5-bio6) [°C]",
"bio8": "Mean temperature of wettest quarter [°C]",
"bio9": "Mean temperature of driest quarter [°C]",
"bio10": "Mean temperature of warmest quarter [°C]",
"bio11": "Mean temperature of coldest quarter [°C]",
"bio12": "Annual precipitation [mm]",
"bio13": "Precipitation of wettest month [mm]",
"bio14": "Precipitation of driest month [mm]",
......@@ -483,6 +483,10 @@
"12": "Dec"
}
},
"climateDescription": {
"temp": "Derived from the monthly temperature values in order to generate more biologically meaningful variables. They represent annual or quarterly trends.",
"prec": "Derived from the monthly rainfall values in order to generate more biologically meaningful variables. They represent annual or quarterly trends."
},
"model": {
"modelName": "Accession",
"modelName_plural": "Accessions",
......@@ -550,17 +554,17 @@
"elevation": "Elevation of collecting site",
"climate": {
"bio1": "Annual mean temperature [°c]",
"bio1": "Annual mean temperature [°C]",
"bio2": "Mean diurnal range (mean of monthly (max temp - min temp))",
"bio3": "Isothermality (bio2/bio7) (* 100)",
"bio4": "Temperature seasonality (standard deviation *100)",
"bio5": "Max temperature of warmest month [°c]",
"bio6": "Min temperature of coldest month [°c]",
"bio7": "Temperature annual range (bio5-bio6) [°c]",
"bio8": "Mean temperature of wettest quarter [°c]",
"bio9": "Mean temperature of driest quarter [°c]",
"bio10": "Mean temperature of warmest quarter [°c]",
"bio11": "Mean temperature of coldest quarter [°c]",
"bio5": "Max temperature of warmest month [°C]",
"bio6": "Min temperature of coldest month [°C]",
"bio7": "Temperature annual range (bio5-bio6) [°C]",
"bio8": "Mean temperature of wettest quarter [°C]",
"bio9": "Mean temperature of driest quarter [°C]",
"bio10": "Mean temperature of warmest quarter [°C]",
"bio11": "Mean temperature of coldest quarter [°C]",
"bio12": "Annual precipitation [mm]",
"bio13": "Precipitation of wettest month [mm]",
"bio14": "Precipitation of driest month [mm]",
......
......@@ -25,6 +25,7 @@ const httpProxy = proxy(config.apiUrl, {
}
console.log(`Will HTTP Proxy filter? ${typeof req.headers.authorization !== 'undefined'}`);
// console.log(`Incoming headers for ${req.url}`, req.headers);
return typeof req.headers.authorization !== 'undefined';
}
// Not proxying the request
......
......@@ -88,17 +88,17 @@
"map": "Map"
},
"climate": {
"bio1": "Annual mean temperature [°c]",
"bio1": "Annual mean temperature [°C]",
"bio2": "Mean diurnal range (mean of monthly (max temp - min temp))",
"bio3": "Isothermality (bio2/bio7) (* 100)",
"bio4": "Temperature seasonality (standard deviation *100)",
"bio5": "Max temperature of warmest month [°c]",
"bio6": "Min temperature of coldest month [°c]",
"bio7": "Temperature annual range (bio5-bio6) [°c]",
"bio8": "Mean temperature of wettest quarter [°c]",
"bio9": "Mean temperature of driest quarter [°c]",
"bio10": "Mean temperature of warmest quarter [°c]",
"bio11": "Mean temperature of coldest quarter [°c]",
"bio5": "Max temperature of warmest month [°C]",
"bio6": "Min temperature of coldest month [°C]",
"bio7": "Temperature annual range (bio5-bio6) [°C]",
"bio8": "Mean temperature of wettest quarter [°C]",
"bio9": "Mean temperature of driest quarter [°C]",
"bio10": "Mean temperature of warmest quarter [°C]",
"bio11": "Mean temperature of coldest quarter [°C]",
"bio12": "Annual precipitation [mm]",
"bio13": "Precipitation of wettest month [mm]",
"bio14": "Precipitation of driest month [mm]",
......@@ -134,6 +134,10 @@
"12": "Dec"
}
},
"climateDescription": {
"temp": "Derived from the monthly temperature values in order to generate more biologically meaningful variables. They represent annual or quarterly trends.",
"prec": "Derived from the monthly rainfall values in order to generate more biologically meaningful variables. They represent annual or quarterly trends."
},
"model": {
"modelName": "Accession",
"modelName_plural": "Accessions",
......@@ -201,17 +205,17 @@
"elevation": "Elevation of collecting site",
"climate": {
"bio1": "Annual mean temperature [°c]",
"bio1": "Annual mean temperature [°C]",
"bio2": "Mean diurnal range (mean of monthly (max temp - min temp))",
"bio3": "Isothermality (bio2/bio7) (* 100)",
"bio4": "Temperature seasonality (standard deviation *100)",
"bio5": "Max temperature of warmest month [°c]",
"bio6": "Min temperature of coldest month [°c]",
"bio7": "Temperature annual range (bio5-bio6) [°c]",
"bio8": "Mean temperature of wettest quarter [°c]",
"bio9": "Mean temperature of driest quarter [°c]",
"bio10": "Mean temperature of warmest quarter [°c]",
"bio11": "Mean temperature of coldest quarter [°c]",
"bio5": "Max temperature of warmest month [°C]",
"bio6": "Min temperature of coldest month [°C]",
"bio7": "Temperature annual range (bio5-bio6) [°C]",
"bio8": "Mean temperature of wettest quarter [°C]",
"bio9": "Mean temperature of driest quarter [°C]",
"bio10": "Mean temperature of warmest quarter [°C]",
"bio11": "Mean temperature of coldest quarter [°C]",
"bio12": "Annual precipitation [mm]",
"bio13": "Precipitation of wettest month [mm]",
"bio14": "Precipitation of driest month [mm]",
......
......@@ -45,7 +45,7 @@ const styles = (theme) => ({
left: '-8px',
},
description: {
margin: '0 -20px',
// margin: '0 -20px',
padding: '8px 20px',
whiteSpace: 'initial' as 'initial',
},
......@@ -68,28 +68,28 @@ const styles = (theme) => ({
interface IMapLayerConfigProps extends React.ClassAttributes<any> {
title: string;
classes: any;
t: any;
layer: MapLayer;
updateTileLayerInfo: (layerInfo: MapLayer) => void;
}
class MapLayerConfig extends React.Component<IMapLayerConfigProps> {
public state = {
legendOpacity: 1.0,
sliderOpacity: 0.5,
show: false,
};
public componentWillMount() {
const {layer} = this.props;
if (layer && layer.enabled) {
this.setState({show: true});
this.setState({ show: true });
}
}
public render() {
const {classes, layer, t} = this.props;
const {show} = this.state;
const {classes, layer} = this.props;
const {show, legendOpacity} = this.state;
return (
<div className={ `${ classes.root } ${ show && classes.rootOpened }` }>
......@@ -101,7 +101,7 @@ class MapLayerConfig extends React.Component<IMapLayerConfigProps> {
<Divider style={ {margin: '0 -20px'} }/>
<div className={ classes.content }>
<div className={ classes.description }>
<div>{ t(layer.description) }</div>
<div><img style={ { opacity: legendOpacity } } src={ layer.legendUrl } /></div>
</div>
<div className={ classes.opacitySlider }>
......@@ -136,14 +136,17 @@ class MapLayerConfig extends React.Component<IMapLayerConfigProps> {
private handleSliderChange = (e, value) => {
const {updateTileLayerInfo, layer} = this.props;
this.setState({ ...this.state, legendOpacity: this.state.show ? this.state.sliderOpacity : 1.0, sliderOpacity: value });
updateTileLayerInfo({...layer, opacity: value});
}
private handleCheckBoxChange = (e, value) => {
const {updateTileLayerInfo, layer} = this.props;
this.setState({ ...this.state, show: value, legendOpacity: value ? this.state.sliderOpacity : 1.0 });
updateTileLayerInfo({...layer, enabled: value});
}
}
const mapDispatchToProps = (dispatch) => bindActionCreators({
updateTileLayerInfo,
}, dispatch);
......
class MapLayer {
public name: string;
public title: string;
public description: string;
public legendUrl: string;
public url: string;
public enabled: boolean;
public opacity: number;
......@@ -24,7 +24,7 @@ export const AVAILABLE_LAYERS = layerNames.map((layerName) => ({
...new MapLayer(),
name: layerName,
title: `accessions.climate.${ layerName }`,
description: `accessions.climateDescription.${ layerName }`,
legendUrl: `https://a.static.genesys-pgr.org/worldclim1.4/${ layerName }/legend.png`,
url: `https://{s}.static.genesys-pgr.org/worldclim1.4/${ layerName }/{z}/{x}/{y}.png`,
}));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment