Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate Google BigQuery data serving for small snapshot #274

Closed
wants to merge 41 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0caede1
Functions Test
nofurtherinformation Jul 9, 2021
1440bfe
Version fix
nofurtherinformation Jul 20, 2021
da9dafe
Remove Performance
nofurtherinformation Jul 20, 2021
0bdc815
Update cors.js
nofurtherinformation Jul 20, 2021
748fa02
P
nofurtherinformation Jul 21, 2021
56b3920
Big Query test functions
nofurtherinformation Jul 21, 2021
809eaf3
Update query.js
nofurtherinformation Jul 21, 2021
ced9d0e
Update query.js
nofurtherinformation Jul 21, 2021
222d85e
Remove logs
nofurtherinformation Jul 21, 2021
d8b9d5f
Range Bigquery
nofurtherinformation Jul 28, 2021
e592731
Update q.js
nofurtherinformation Jul 28, 2021
e3c9459
Columns fix
nofurtherinformation Jul 28, 2021
b26e82e
Update q.js
nofurtherinformation Jul 28, 2021
21d0123
Update q.js
nofurtherinformation Jul 28, 2021
d27c137
Merge branch 'functions-test' into gbq-integration
nofurtherinformation Aug 18, 2021
3a1ecc4
Update michigan-schools.csv
nofurtherinformation Aug 19, 2021
8892078
Time Series Function
nofurtherinformation Aug 19, 2021
6fdd80b
Create qLastMonth.js
nofurtherinformation Aug 19, 2021
9157557
Snapshot initial load
nofurtherinformation Aug 20, 2021
71ae64d
WIP
nofurtherinformation Aug 25, 2021
3323141
Initial Load to BQ
nofurtherinformation Aug 25, 2021
90a0e29
wip
nofurtherinformation Aug 25, 2021
5449de8
WIP
nofurtherinformation Aug 26, 2021
b811a19
WIP
nofurtherinformation Aug 26, 2021
4eccda5
Line chart fix
nofurtherinformation Aug 26, 2021
c1f2248
WIP
nofurtherinformation Aug 26, 2021
6934967
User Preferences
nofurtherinformation Aug 26, 2021
2dcebfc
Revised Preferences Menu
nofurtherinformation Aug 27, 2021
32bb27b
Saved Days Preference Fix
nofurtherinformation Aug 27, 2021
cfaed00
Update TopPanel.js
nofurtherinformation Aug 27, 2021
6b4f70e
Update VariablePanel.js
nofurtherinformation Aug 27, 2021
f0d7388
Update VariablePanel.js
nofurtherinformation Aug 27, 2021
eac9fe2
Columns update [skip ci]
nofurtherinformation Oct 14, 2021
6db12e4
WIP Selection
nofurtherinformation Oct 18, 2021
efcc551
Update MainLineChart.js
nofurtherinformation Oct 21, 2021
dd68fa0
wip
nofurtherinformation Oct 22, 2021
fb932df
URL Params Support
nofurtherinformation Oct 22, 2021
f7e6d21
Gzip response
nofurtherinformation Oct 25, 2021
6c936cb
Lint
nofurtherinformation Oct 25, 2021
1ee68e8
Lazy load data
nofurtherinformation Oct 25, 2021
ae69107
Styling Attribution and Loading
nofurtherinformation Oct 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revised Preferences Menu
nofurtherinformation committed Aug 27, 2021
commit 2dcebfc8ec20de24097981fa144faaad081266c7
2 changes: 1 addition & 1 deletion src/components/MapSection.js
Original file line number Diff line number Diff line change
@@ -616,7 +616,7 @@ export default function MapSection(){
LayerArray.push(layers['choroplethHighlight'])
LayerArray.push(layers['choroplethHover'])
}

if (resources && resources.includes('hospital')) LayerArray.push(layers['hospitals'])
if (resources && resources.includes('clinic')) LayerArray.push(layers['clinic'])
if (resources && resources.includes('vaccinationSites')) LayerArray.push(layers['vaccinationSites'])
91 changes: 70 additions & 21 deletions src/components/TopPanel.js
Original file line number Diff line number Diff line change
@@ -7,11 +7,15 @@ import styled from 'styled-components';
import { DateSlider, Dock, Ticks, SliderPlaceholder } from '../components';
import { colors } from '../config';
import * as SVG from '../config/svg';
import { OutlineButton } from '../styled_components';
import { OutlineButton, StyledDropDown } from '../styled_components';
// MUI import
import MenuItem from '@material-ui/core/MenuItem';
import Select from '@material-ui/core/Select';
import Checkbox from '@material-ui/core/Checkbox';
import FormGroup from '@material-ui/core/FormGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import Slider from '@material-ui/core/Slider';

import { range } from 'lodash';

// Styled components
const TopDrawer = styled.div`
@@ -77,6 +81,7 @@ const PreferenceButton = styled.button`

const DismissButton = styled(OutlineButton)`
border:none;
font-weight:normal;
&.topRight {
position:absolute;
top:0;
@@ -109,48 +114,92 @@ const PreferencePanelContainer = styled.div`
}
`

function PreferncePanel({closePanel}){
const SnapshotSelect = styled.p`
&.disabled {
opacity:0.5;
pointer-events:none;
}
`

const DaysDropdown = styled(StyledDropDown)`
transform:translateY(-6px);
`

function PreferencePanel({closePanel}){
const shouldAlwaysLoadTimeseries = useSelector((state)=>state.shouldAlwaysLoadTimeseries)
const snapshotDaysToLoad = useSelector((state) => state.snapshotDaysToLoad);
const shouldSaveLocation = useSelector((state) => state.shouldSaveLocation);
const shouldSaveOverlay = useSelector((state) => state.shouldSaveOverlay);
const shouldSaveResource = useSelector((state) => state.shouldSaveResource);
const mapParams = useSelector((state) => state.mapParams);

const dispatch = useDispatch();

return <PreferencePanelContainer>
<h3>Atlas Preferences</h3>
<br/>
<FormGroup row>
<SnapshotSelect id="snapshot-slider-label" className={shouldAlwaysLoadTimeseries ? 'disabled' : ''}>
Only load the most recent {
<DaysDropdown>
<Select
value={snapshotDaysToLoad}
id="snapshotDaysToLoad-select"
onChange={(e, newVal) => dispatch({type:'SET_PREFERENCE', payload:{pref:'snapshotDaysToLoad',value:newVal}})}
>
{range(1,13).map(i => <MenuItem
value={i*15}
key={`snapshot-${i}`}
>{i*15} days</MenuItem>)}
</Select>
</DaysDropdown>
} of data
</SnapshotSelect>
<FormControlLabel
control={<Checkbox
checked={shouldAlwaysLoadTimeseries}
onChange={() => dispatch({type:'SET_LOAD_TIMESERIES',payload:'toggle'})}
name="checkedA"
/>}
label="Always load historic time-series data"
label="Always load all historic time-series data"
/>
{!shouldAlwaysLoadTimeseries && <><p id="snapshot-slider-label">
Number of days to load: {snapshotDaysToLoad} days
</p>
<Slider min={15} max={180} step={15}
value={snapshotDaysToLoad}
onChange={(e, value) => dispatch({type:'SET_PREFERENCE',payload:{pref:'snapshotDaysToLoad', value}})}
aria-labelledby="snapshot-slider-label" /></>}
<FormControlLabel
control={<Checkbox checked={shouldSaveLocation} onChange={() => dispatch({type:'SET_PREFERENCE', payload:{pref:'shouldSaveLocation',value:'toggle'}})} name="checkedA" />}
control={
<Checkbox
checked={shouldSaveLocation}
onChange={() => dispatch({type:'SET_PREFERENCE', payload:{pref:'shouldSaveLocation',value:'toggle'}})}
name="saveLocation"
/>}
label="Save map location"
/>
<br/>
<FormControlLabel
control={<Checkbox checked={false} onChange={(e) => console.log(e)} name="checkedA" />}
label="Save variable settings (requires historic time-series data enabled)"
control={
<Checkbox
checked={false}
onChange={(e) => console.log(e)}
name="saveVariable"
/>}
label="Save variable settings"
disabled
/>
<FormControlLabel
control={<Checkbox checked={false} onChange={(e) => console.log(e)} name="checkedA" />}
label="Save overlay displayed"
disabled
control={
<Checkbox
checked={shouldSaveOverlay !== false}
onChange={()=> dispatch({type:'SET_PREFERENCE', payload:{pref:'shouldSaveOverlay',value:shouldSaveOverlay === false ? mapParams.overlay : 'toggle'}})}
name="saveOverlay"
/>}
label="Save overlay layer"
/>
<FormControlLabel
control={<Checkbox checked={false} onChange={(e) => console.log(e)} name="checkedA" />}
label="Save resource displayed"
disabled
control={
<Checkbox
checked={shouldSaveResource !== false}
onChange={()=> dispatch({type:'SET_PREFERENCE', payload:{pref:'shouldSaveResource',value:shouldSaveResource === false ? mapParams.resource : 'toggle'}})}
name="saveResource"
/>}
label="Save resource layer"
/>
</FormGroup>
<DismissButton onClick={closePanel} className="topRight">×</DismissButton>
@@ -180,7 +229,7 @@ export default function TopPanel(){
</PreferenceContainer>
}
<PreferenceButton onClick={() => setShowPreferenceMenu(prev => !prev)}>{SVG.sliders}</PreferenceButton>
{showPreferenceMenu && <PreferncePanel closePanel={() => setShowPreferenceMenu(false)} />}
{showPreferenceMenu && <PreferencePanel closePanel={() => setShowPreferenceMenu(false)} />}
</TopDrawer>
)
}
18 changes: 17 additions & 1 deletion src/components/VariablePanel.js
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import { StyledDropDown, BinsContainer, Gutter } from '../styled_components';
import { setVariableParams, setMapParams, setCurrentData, setPanelState, setParametersAndData, setNotification, changeDotDensityMode, toggleDotDensityRace, setDotDensityBgOpacity } from '../actions';
import { fixedScales, colorScales, colors, variableTree, urlParamsTree, datasetTree, allGeographies, allDatasets } from '../config';
import * as SVG from '../config/svg';
import { useEffect } from 'react/cjs/react.development';

/** STYLES */
const VariablePanelContainer = styled.div`
@@ -341,7 +342,9 @@ export default function VariablePanel(){
const dataPresets = useSelector(state => state.dataPresets);
const shouldLoadTimeseries = useSelector((state)=>state.shouldLoadTimeseries);
const shouldAlwaysLoadTimeseries = useSelector((state)=>state.shouldAlwaysLoadTimeseries);

const shouldSaveOverlay = useSelector((state)=>state.shouldSaveOverlay);
const shouldSaveResource = useSelector((state)=>state.shouldSaveResource);

const handleMapType = (event, newValue) => {
let nBins = newValue === 'hinge15_breaks' ? 6 : 8
if (newValue === 'lisa') {
@@ -387,6 +390,7 @@ export default function VariablePanel(){
}
)
)
shouldSaveOverlay !== false && dispatch({type:'SET_PREFERENCE', payload:{pref:'shouldSaveOverlay',value:event.target.value}})
}
const handleMapResource = (event) =>{
dispatch(
@@ -396,7 +400,19 @@ export default function VariablePanel(){
}
)
)
shouldSaveResource !== false && dispatch({type:'SET_PREFERENCE', payload:{pref:'shouldSaveResource',value:event.target.value}})
}

useEffect(() => {
if (shouldSaveOverlay !== false) {
handleMapOverlay({target:{value:shouldSaveOverlay}})
}

if (shouldSaveResource !== false) {
handleMapResource({target:{value:shouldSaveResource}})
}
},[])

const handleOpenClose = () => dispatch(setPanelState({variables:!panelState.variables}))
const handleVizTypeButton = (vizType) => dispatch(setMapParams({vizType}))
const handleDotDensitySlider = (e, newValue) => dispatch(setDotDensityBgOpacity(newValue))
4 changes: 3 additions & 1 deletion src/constants/defaults.js
Original file line number Diff line number Diff line change
@@ -145,5 +145,7 @@ export const INITIAL_STATE = {
shouldAlwaysLoadTimeseries: false,
snapshotDaysToLoad: 90,
savedLocation: '',
shouldSaveLocation: false
shouldSaveLocation: false,
shouldSaveOverlay:false,
shouldSaveResource:false
};
1 change: 0 additions & 1 deletion src/contexts/ViewportContext.js
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@ export const ViewportProvider = ({defaultViewport = {}, children}) => {

useEffect(() => {
if (shouldSaveLocation && document.hasFocus()){
console.log( JSON.stringify(viewport))
dispatch({
type: 'SET_PREFERENCE',
payload: {
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import { PersistGate } from 'redux-persist/integration/react';
const persistConfig = {
key: 'root',
storage,
whitelist: ['shouldAlwaysLoadTimeseries','snapshotDaysToLoad','savedLocation','shouldSaveLocation']
whitelist: ['shouldAlwaysLoadTimeseries','snapshotDaysToLoad','savedLocation','shouldSaveLocation','shouldSaveOverlay','shouldSaveResource']
}

const persistedReducer = persistReducer(persistConfig, rootReducer)
4 changes: 3 additions & 1 deletion src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -895,7 +895,9 @@ var reducer = (state = INITIAL_STATE, action) => {
return {
...state,
[action.payload.pref]: action.payload.value === 'toggle'
? !state[action.payload.pref]
? 'string' === typeof(state[action.payload.pref])
? false
: !state[action.payload.pref]
: action.payload.value
}
}
6 changes: 3 additions & 3 deletions src/styled_components/index.js
Original file line number Diff line number Diff line change
@@ -195,17 +195,17 @@ export const HoverDiv = styled.div`
`

export const OutlineButton = styled.button`
border:none;
padding:0.25em 0.5em;
border-radius:0.125em;
border-radius:0.5em;
margin:0.5em;
font-weight:bold;
cursor:pointer;
transition:250ms all;
color:white;
border-width:1px;
border-style:solid;
background:none;
background:${colors.darkgray};
box-shadow: 0px 0px 5px rgba(0,0,0,0.7);
font-family:'Lato', Arial, sans-serif;
&:hover {
border-color:${colors.yellow};
1 change: 0 additions & 1 deletion src/utils/parseMapboxLayers.js
Original file line number Diff line number Diff line change
@@ -24,7 +24,6 @@ export default function parseMapboxLayers(defaultLayers, mapParams, globalMap=fa
: ['native_american_reservations','segregated_cities','uscongress-districts'].includes(mapParams.overlay)
? defaultLayers.map(layer => {
if (mapParams.resource.includes(layer.id.split('-')[0]) || mapParams.overlay.includes(layer.id.split('-')[0])) {
console.log(layer)
return {...layer, layout: {...layer.layout, visibility: "visible"}}
} else if (layer.id.includes('label')){
return {...layer, layout: {...layer.layout, visibility: "none"}}