Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Add Settings Page #1298

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
453 changes: 227 additions & 226 deletions CHANGELOG.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions scripts/resetdb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function enableswitches() {
./scripts/manage waffle_switch claim_a_facility on
./scripts/manage waffle_switch ppe on
./scripts/manage waffle_switch report_a_facility on
./scripts/manage waffle_switch embedded_map on
}

function assigngroups() {
Expand Down
13 changes: 12 additions & 1 deletion src/app/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import ClaimFacility from './components/ClaimFacility';
import ClaimedFacilities from './components/ClaimedFacilities';
import AboutClaimedFacilities from './components/AboutClaimedFacilities';
import SurveyDialogNotification from './components/SurveyDialogNotification';
import Settings from './components/Settings';

import './App.css';

Expand Down Expand Up @@ -57,6 +58,7 @@ import {
claimedFacilitiesRoute,
CLAIM_A_FACILITY,
aboutClaimedFacilitiesRoute,
settingsRoute,
} from './util/constants';

const appStyles = Object.freeze({
Expand Down Expand Up @@ -166,7 +168,11 @@ class App extends Component {
<Route
exact
path={profileRoute}
component={UserProfile}
component={({
match: {
params: { id },
},
}) => <UserProfile id={id} />}
/>
<Route
exact
Expand Down Expand Up @@ -202,6 +208,11 @@ class App extends Component {
</FeatureFlag>
)}
/>
<Route
exact
path={settingsRoute}
component={Settings}
/>
<Route
exact
path={mainRoute}
Expand Down
100 changes: 100 additions & 0 deletions src/app/src/components/EmbeddedMapCode.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import React from 'react';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import { shape, string, bool } from 'prop-types';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import noop from 'lodash/noop';
import { toast } from 'react-toastify';

import { createIFrameHTML } from '../util/util';

const styles = {
sectionHeader: {
color: 'rgb(0, 0, 0)',
fontSize: '18px',
margin: '10px 0',
},
embedContainer: {
background: 'rgb(240, 240, 240)',
borderRadius: '0px',
minHeight: '278px',
width: '360px',
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
padding: '20px',
},
embedTextBox: {
background: 'rgb(255, 255, 255)',
borderRadius: 0,
border: '1px solid rgb(214, 216, 221)',
flex: 1,
width: '90%',
marginTop: '20px',
color: 'rgb(0, 0, 0)',
fontFamily: 'ff-tisa-sans-web-pro,sans-serif',
padding: '10px',
},
embedButton: {
background: 'rgb(0, 0, 0)',
borderRadius: 0,
marginTop: '10px',
color: 'white',
},
};

function EmbeddedMapCode({
color,
font,
width,
height,
fullWidth,
contributor,
}) {
const mapSettings = {
color,
font,
width,
height,
fullWidth,
contributor,
};

return (
<div style={styles.embedContainer}>
<Typography style={styles.sectionHeader}>Embed code</Typography>
<Typography style={styles.embedTextBox}>
{createIFrameHTML(mapSettings)}
</Typography>
<CopyToClipboard
text={createIFrameHTML(mapSettings)}
onCopy={() => toast('Copied code to clipboard')}
>
<Button
variant="contained"
style={styles.embedButton}
onClick={noop}
>
Copy to clipboard
</Button>
</CopyToClipboard>
</div>
);
}

EmbeddedMapCode.defaultProps = {
font: null,
};

EmbeddedMapCode.propTypes = {
width: string.isRequired,
height: string.isRequired,
fullWidth: bool.isRequired,
color: string.isRequired,
font: shape({
label: string,
value: string,
}),
};

export default EmbeddedMapCode;
137 changes: 137 additions & 0 deletions src/app/src/components/EmbeddedMapConfig.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import React, { useState } from 'react';
import { connect } from 'react-redux';
import Typography from '@material-ui/core/Typography';
import Grid from '@material-ui/core/Grid';

import { userPropType } from '../util/propTypes';
import { getEmbeddedMapSrc } from '../util/util';
import AppGrid from './AppGrid';
import EmbeddedMapFieldsConfig from './EmbeddedMapFieldsConfig';
import EmbeddedMapThemeConfig from './EmbeddedMapThemeConfig';
import EmbeddedMapSizeConfig from './EmbeddedMapSizeConfig';
import EmbeddedMapCode from './EmbeddedMapCode';

const styles = {
container: {
marginBottom: '200px',
},
section: {
marginTop: '30px',
},
sectionHeader: {
color: 'rgb(0, 0, 0)',
fontSize: '18px',
margin: '10px 0',
},
previewHeader: {
color: 'rgb(0, 0, 0)',
fontSize: '24px',
},
};

function EmbeddedMapConfig({ user }) {
// TODO: Replace with backend configuration data
const [fields, setFields] = useState([
{ included: true, label: 'Years active', value: 'years_active' },
{ included: true, label: 'num_widgets', value: 'num_widgets' },
{
included: false,
label: 'some_other_field_name',
value: 'some_other_field_name',
},
]);
TaiWilkin marked this conversation as resolved.
Show resolved Hide resolved
const [
includeOtherContributorFields,
setIncludeOtherContributorFields,
] = useState(true);
const [color, setColor] = useState('#C74444');
const [font, setFont] = useState(null);
const [width, setWidth] = useState('780');
const [fullWidth, setFullWidth] = useState(false);
const [height, setHeight] = useState('440');

const mapSettings = {
color,
font,
width,
height,
fullWidth,
contributor: [user?.id],
};

return (
<AppGrid style={styles.container} title="">
<Typography>
Generate a custom OAR map to embed in your website. The map will
TaiWilkin marked this conversation as resolved.
Show resolved Hide resolved
include all facilities you have contributed.
</Typography>
<Grid item xs={6}>
<EmbeddedMapFieldsConfig
fields={fields}
setFields={setFields}
includeOtherContributorFields={
includeOtherContributorFields
}
setIncludeOtherContributorFields={
setIncludeOtherContributorFields
}
/>
<EmbeddedMapThemeConfig
color={color}
setColor={setColor}
font={font}
setFont={setFont}
/>
<EmbeddedMapSizeConfig
width={width}
setWidth={setWidth}
height={height}
setHeight={setHeight}
fullWidth={fullWidth}
setFullWidth={setFullWidth}
/>
</Grid>
<Grid item xs={6} style={{ ...styles.section, padding: '20px' }}>
<EmbeddedMapCode {...mapSettings} />
</Grid>
<Grid
item
xs={12}
style={{ ...styles.section, minHeight: '500px' }}
>
<Typography style={styles.previewHeader}>Preview</Typography>
<iframe
frameBorder="0"
scrolling="no"
marginHeight="0"
marginWidth="0"
width={width}
height={height}
type="text/html"
src={getEmbeddedMapSrc(mapSettings)}
title="embedded-map"
/>
</Grid>
</AppGrid>
);
}

EmbeddedMapConfig.defaultProps = {
user: null,
};

EmbeddedMapConfig.propTypes = {
user: userPropType,
};

function mapStateToProps({
auth: {
user: { user },
},
}) {
return {
user,
};
}

export default connect(mapStateToProps)(EmbeddedMapConfig);
Loading