Skip to content

Commit

Permalink
Merge branch 'dev' into aws-economize
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyweb authored Feb 1, 2021
2 parents 42d9cc9 + 9477ad5 commit e14ef31
Show file tree
Hide file tree
Showing 12 changed files with 363 additions and 161 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_test_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
run: |
cp .env.example .env
docker-compose up --no-start api
- name: Lint API
run: docker-compose run api flake8
- name: Seed database and run API
run: |
docker-compose up -d api
- name: Run unit tests
run: docker-compose run api pytest
- name: Lint API
run: docker-compose run api flake8
# - name: Run Postman tests
# run: chmod +x postman/test.sh && postman/test.sh
75 changes: 40 additions & 35 deletions client/components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React from 'react';
// import PropTypes from 'proptypes';
import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import mapboxgl from 'mapbox-gl';

Expand All @@ -15,7 +16,6 @@ import {
} from './constants';

import {
ncBoundaries,
ccBoundaries,
ncNameFromId,
ccNameFromId,
Expand Down Expand Up @@ -62,7 +62,7 @@ class Map extends React.Component {
activeRequestsLayer: 'points',
selectedTypes: props.selectedTypes,
locationInfo: INITIAL_LOCATION,
geoFilterType: GEO_FILTER_TYPES.address,
geoFilterType: GEO_FILTER_TYPES.nc,
filterGeo: null,
filteredRequestCounts: {},
hoveredRegionName: null,
Expand Down Expand Up @@ -127,8 +127,39 @@ class Map extends React.Component {
if (
this.state.filterGeo !== prevState.filterGeo ||
this.state.selectedTypes !== prevState.selectedTypes
)
this.map.once('idle', this.setFilteredRequestCounts);
) this.map.once('idle', this.setFilteredRequestCounts);

if (this.props.ncBoundaries != prevProps.ncBoundaries) {
this.ncLayer.init({
map: this.map,
addListeners: true,
sourceId: 'nc',
sourceData: this.props.ncBoundaries,
idProperty: 'nc_id',
onSelectRegion: geo => {
this.setState({
locationInfo: {
nc: {
name: ncNameFromId(geo.properties.nc_id),
// url removed from /geojson payload
// need to map from /councils response
// url: geo.properties.waddress || geo.properties.dwebsite,
},
},
});
this.map.once('zoomend', () => {
this.setState({ filterGeo: geo });
});
},
onHoverRegion: geo => {
this.setState({
hoveredRegionName: geo
? ncNameFromId(geo.properties.nc_id)
: null
});
}
});
}
}

initLayers = addListeners => {
Expand All @@ -155,34 +186,6 @@ class Map extends React.Component {
}),
});

this.ncLayer.init({
map: this.map,
addListeners,
sourceId: 'nc',
sourceData: ncBoundaries,
idProperty: 'nc_id',
onSelectRegion: geo => {
this.setState({
locationInfo: {
nc: {
name: ncNameFromId(geo.properties.nc_id),
url: geo.properties.waddress || geo.properties.dwebsite,
},
},
});
this.map.once('zoomend', () => {
this.setState({ filterGeo: geo });
});
},
onHoverRegion: geo => {
this.setState({
hoveredRegionName: geo
? ncNameFromId(geo.properties.nc_id)
: null
});
}
});

this.ccLayer.init({
map: this.map,
addListeners,
Expand Down Expand Up @@ -257,7 +260,7 @@ class Map extends React.Component {

const features = this.map.queryRenderedFeatures(e.point, {
layers: [
// 'request-circles',
'request-circles',
...masks,
...hoverables
]
Expand Down Expand Up @@ -503,6 +506,8 @@ Map.propTypes = {};

Map.defaultProps = {};

export default withStyles(styles)(Map);
const mapStateToProps = state => ({
ncBoundaries: state.metadata.ncGeojson,
});

// export default Map;
export default connect(mapStateToProps, null)(withStyles(styles)(Map));
10 changes: 6 additions & 4 deletions client/components/Map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class MapContainer extends React.Component {
}

getOpenRequests = async () => {
// const url = `${process.env.API_URL}/requests/pins/open`;
// const { data } = await axios.get(url);
const url = `${process.env.API_URL}/open-requests`;
const { data } = await axios.post(url);
this.openRequests = data;
Expand All @@ -61,14 +63,14 @@ class MapContainer extends React.Component {

return this.setState({
requests: this.convertRequests(this.openRequests.requests),
ncCounts: this.openRequests.counts.nc,
ccCounts: this.openRequests.counts.cc,
// ncCounts: this.openRequests.counts.nc,
// ccCounts: this.openRequests.counts.cc,
});
case MAP_MODES.CLOSED:
return this.setState({
requests: this.convertRequests(pins),
ncCounts: null,
ccCounts: null,
// ncCounts: null,
// ccCounts: null,
});
}
};
Expand Down
Loading

0 comments on commit e14ef31

Please sign in to comment.