diff --git a/client/components/About.js b/client/components/About.js deleted file mode 100644 index bed14f40e..000000000 --- a/client/components/About.js +++ /dev/null @@ -1,51 +0,0 @@ -import React from 'react' -import Button from '@material-ui/core/Button' -import Dialog from '@material-ui/core/Dialog' -import DialogActions from '@material-ui/core/DialogActions' -import DialogContent from '@material-ui/core/DialogContent' -import DialogContentText from '@material-ui/core/DialogContentText' -import DialogTitle from '@material-ui/core/DialogTitle' -import CssBaseline from '@material-ui/core/CssBaseline' - -class About extends React.Component { - state = { - open: true - } - - handleClickOpen = () => { - this.setState({ open: true }) - } - - handleClose = () => { - this.setState({ open: false }) - } - - render () { - return ( - - - - - {"Section under development."} - - - - The functionality of this section has not been developed yet. We expect to have it for November 2018. Thanks for your understanding. - - - - - - - - ) - } -} - -export default About diff --git a/client/components/Browse.js b/client/components/Browse.js deleted file mode 100644 index 2231b1f8b..000000000 --- a/client/components/Browse.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react' -import UserList from './UserList' -import CssBaseline from '@material-ui/core/CssBaseline' - -const Browse = () => { - return ( - - - - - ) -} - -export default Browse diff --git a/client/components/Contact.js b/client/components/Contact.js deleted file mode 100644 index 268efeaee..000000000 --- a/client/components/Contact.js +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react' -import Button from '@material-ui/core/Button' -import Dialog from '@material-ui/core/Dialog' -import DialogActions from '@material-ui/core/DialogActions' -import DialogContent from '@material-ui/core/DialogContent' -import DialogContentText from '@material-ui/core/DialogContentText' -import DialogTitle from '@material-ui/core/DialogTitle' -import CssBaseline from '@material-ui/core/CssBaseline' - -class Contact extends React.Component { - state = { - open: true - } - - handleClickOpen = () => { - this.setState({ open: true }) - } - - handleClose = () => { - this.setState({ open: false }) - } - - render () { - return ( - - - - - - {"Section under development."} - - - - The functionality of this section has not been developed yet. We expect to have it for November 2018. Thanks for your understanding. - - - - - - - - ) - } -} - -export default Contact diff --git a/client/components/DescendentsTree.js b/client/components/DescendentsTree.js deleted file mode 100644 index 9a1cb06ea..000000000 --- a/client/components/DescendentsTree.js +++ /dev/null @@ -1,258 +0,0 @@ -import React, { Component } from 'react' -import {graphql, compose} from 'react-apollo' -import {getDescendentsQuery} from '../queries/queries' - -// Materia UI - -import { withStyles } from '@material-ui/core/styles' -import Card from '@material-ui/core/Card' -import CardActionArea from '@material-ui/core/CardActionArea' -import CardActions from '@material-ui/core/CardActions' -import CardContent from '@material-ui/core/CardContent' -import CardMedia from '@material-ui/core/CardMedia' -import Typography from '@material-ui/core/Typography' -import Grid from '@material-ui/core/Grid' - -// Material UI Nestled Lists -import ListSubheader from '@material-ui/core/ListSubheader'; -import List from '@material-ui/core/List'; -import ListItem from '@material-ui/core/ListItem'; -import ListItemIcon from '@material-ui/core/ListItemIcon'; -import ListItemText from '@material-ui/core/ListItemText'; -import Collapse from '@material-ui/core/Collapse'; -import ExpandLess from '@material-ui/icons/ExpandLess'; -import ExpandMore from '@material-ui/icons/ExpandMore'; -import StarBorder from '@material-ui/icons/StarBorder'; - -// Images -import PortraitImage from '../img/portrait.jpg' - -const styles = theme => ({ - card: { - maxWidth: 300, - minWidth: 300, - paddingTop: '30' - }, - media: { - height: 0, - paddingTop: '56.25%', // 16:9, - marginTop: '30', - minWidth: 300 - }, - typography: { - maxWidth: 345, - minWidth: 300, - paddingTop: '30' - }, - appBar: { - position: 'relative' - }, - flex: { - flex: 1 - }, - grid: { - paddingTop: '30', - marginTop: 30 - }, - list: { - width: '80%', - marginLeft: '10%', - marginTop: 25 - }, - button: { - margin: theme.spacing.unit, - marginTop: theme.spacing.unit * 3 - }, - nested: { - paddingLeft: theme.spacing.unit * 4, - }, -}) - -class DescendentsTree extends Component { - - constructor (props) { - super(props) - - this.state = { - id: '', - open: true - } - } - - handleClick = () => { - this.setState(state => ({ open: !state.open })); -}; - - displayIcons(amount) { - - switch (amount) { - case 1: return ( -
- - - -
- ) - case 2: return ( -
- - - - - - -
- ) - case 3: return ( -
- - - - - - - - - -
- ) - default: return(
) - } - } - - displayNestedListItems(node, level) { - - const { classes } = this.props - return node.descendents.map(descendent => { - return ( -
- - {this.displayIcons(level)} - - - - - - {descendent.alias} - - - - - - - - - - - {this.displayNestedList(descendent, level)} -
- ) - } - ) - } - - displayNestedList(descendent, level) { - const primaryText = "Children of " + descendent.alias - if (descendent.descendents !== undefined) { - if (descendent.descendents.length > 0) { - return( - - { - this.setState(state => ({ [descendent.alias]: !state[descendent.alias] })); - } - }> - - {this.state[descendent.alias] ? : } - - - {this.displayNestedListItems(descendent, level + 1)} - - - ) - } else { - return (
) - } - } - } - - - displayTopList () { - let data = this.props.data - const { classes } = this.props - - if (data.loading) { - return (
Loading Descendents...
) - } else { - if (data.users_Descendents === undefined) { - return (
No Descendents to Display
) - } else { - return data.users_Descendents.map(descendent => { - return ( -
- - - {this.displayIcons(1)} - - - - - - {descendent.alias} - - - - - - - - - - - - {this.displayNestedList(descendent, 1)} - -
- ) - }) - } - } - } - - render () { - const { classes } = this.props - return ( -
- } - className={classes.list} - > - {this.displayTopList()} - -
- ) - } -} - -export default compose( - graphql(getDescendentsQuery, { // What follows is the way to pass a parameter to a query. - options: (props) => { - return { - variables: { - name: 'getDescendentsQuery', - id: props.userId - } - } - }}), - withStyles(styles) -)(DescendentsTree) // This technique binds more than one query to a single component. diff --git a/client/components/Home.js b/client/components/Home.js deleted file mode 100644 index bb829f8dd..000000000 --- a/client/components/Home.js +++ /dev/null @@ -1,104 +0,0 @@ -import React, { Component } from 'react' -import { compose } from 'recompose' -import { withStyles } from '@material-ui/core/styles' -import Grid from '@material-ui/core/Grid' -import Typography from '@material-ui/core/Typography' -import CssBaseline from '@material-ui/core/CssBaseline' - -const styles = theme => ({ - root: { - flexGrow: 1, - padding: 100 - }, - grid: { - margin: theme.spacing.unit, - width: '50%' - }, - typography: { - width: '100%', - marginTop: 20, - marginBottom: 20 - }, - '@global': { - body: { - backgroundColor: theme.palette.common.white - } - }, - layout: { - width: 'auto', - marginLeft: theme.spacing.unit * 3, - marginRight: theme.spacing.unit * 3, - [theme.breakpoints.up(900 + theme.spacing.unit * 3 * 2)]: { - width: 900, - marginLeft: 'auto', - marginRight: 'auto' - } - }, - heroContent: { - maxWidth: 600, - margin: '0 auto', - padding: `${theme.spacing.unit * 8}px 0 ${theme.spacing.unit * 6}px` - } -}) - -class Home extends Component { - - render () { - const { classes } = this.props - return ( - - -
-
- - Collaborate. Innovate. Evolve. - - - Welcome to Advanced Algos Users Module - -
-
- - - - - Intro - - - This module is responsible for managing users across the Advanced Algos system. Here you can browse the Users Directory, search for users and get to their profiles. You can create your own User profile if you sign up, or manage it if you already have one by logging in. - - - Development Status - - - This module is is currently under development. Implementation started 1st of September 2018 and this is the result of the 3rd sprint of 2 weeks of work each. - - - What can you do? - - - Currently you can use the Browse section to list all registered users. At the Search page you can searh for users by name. Clicking on View Profile you can see some more info about that user. You can signup with your Github account and manage your profile information while logged in. While loggedin, you can edit your profile info, define your referrer and view your descendants. You will find all features under develpment with a dialog indicating it is not ready. - - - - - -
- - ) - } -} - -export default compose( - withStyles(styles) -)(Home) diff --git a/client/components/LoggedInUser.js b/client/components/LoggedInUser.js deleted file mode 100644 index 933394e43..000000000 --- a/client/components/LoggedInUser.js +++ /dev/null @@ -1,135 +0,0 @@ -import React, { Component } from 'react' -import {graphql, compose} from 'react-apollo' -import {getUserByAuthIdQuery} from '../queries/queries' -import { withStyles } from '@material-ui/core/styles' -import classNames from 'classnames' - -import Button from '@material-ui/core/Button' -import IconButton from '@material-ui/core/IconButton' - -// icons -import UserIcon from '@material-ui/icons/Person' -import { Link } from 'react-router-dom' - -const UserLink = props => - -const styles = theme => ({ - root: { - flexGrow: 1 - }, - flex: { - flexGrow: 1, - marginLeft: 30 - }, - menuButton: { - marginLeft: -12, - marginRight: 20 - }, - cssRoot: { - color: '#FFFFFF', - backgroundColor: theme.palette.secondary, - '&:hover': { - backgroundColor: theme.palette.dark - }, - whiteSpace: 'nowrap', - paddingRight: 2 * theme.spacing.unit, - paddingLeft: 2 * theme.spacing.unit - }, - button: { - margin: theme.spacing.unit - }, - leftIcon: { - marginRight: theme.spacing.unit - }, - rightIcon: { - marginLeft: theme.spacing.unit - }, - iconSmall: { - fontSize: 20 - } -}) - -class LoggedInUser extends Component { - - displayLoggedInUser () { - const user = this.props.data.users_UserByAuthId - const { classes, match } = this.props - - if (user) { - let displayName = 'No Display Name' - - if ( - user.alias !== null && - user.alias !== '' - ) { displayName = user.alias } - - if ( - user.firstName !== null && - user.firstName !== '' - ) { displayName = user.firstName } - - if ( - user.firstName !== null && - user.firstName !== '' && - user.lastName !== null && - user.lastName !== '' - ) { displayName = user.firstName + ' ' + user.lastName } - - let authArray = this.props.authId.split('|') - let identityProvider = authArray[0] - - return ( -
- -
- ) - } else { - return ( -
- ) - } - } - - componentDidMount () { - - } - - render () { - if (this.loggedInUserStored !== true) { - let user = this.props.data.users_UserByAuthId - - if (user !== undefined) { - localStorage.setItem('loggedInUser', JSON.stringify(this.props.data.users_UserByAuthId)) - this.loggedInUserStored = true - } - } - - return ( -
- {this.displayLoggedInUser()} -
- ) - } -} - -export default compose( - graphql(getUserByAuthIdQuery, { // What follows is the way to pass a parameter to a query. - options: (props) => { - return { - variables: { - authId: props.authId - } - } - } - }), - withStyles(styles) -)(LoggedInUser) diff --git a/client/components/NavBar.js b/client/components/NavBar.js deleted file mode 100644 index 09d4edf3b..000000000 --- a/client/components/NavBar.js +++ /dev/null @@ -1,151 +0,0 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types' -import { withStyles } from '@material-ui/core/styles' -import classNames from 'classnames' -import AppBar from '@material-ui/core/AppBar' -import Toolbar from '@material-ui/core/Toolbar' -import Typography from '@material-ui/core/Typography' -import Button from '@material-ui/core/Button' - -// icons -import UsersIcon from '@material-ui/icons/People' -import BrowseIcon from '@material-ui/icons/ImportContacts' -import SearchIcon from '@material-ui/icons/Search' -import ContactIcon from '@material-ui/icons/ContactMail' -import AboutIcon from '@material-ui/icons/FormatShapes' - -import { Link } from 'react-router-dom' - -// components -import LoggedInUser from './LoggedInUser' - -const HomeLink = props => -const BrowseLink = props => -const SearchLink = props => -const AboutLink = props => - -const styles = theme => ({ - root: { - flexGrow: 1 - }, - flex: { - flexGrow: 1, - marginLeft: 30 - }, - menuButton: { - marginLeft: -12, - marginRight: 20 - }, - cssRoot: { - color: '#FFFFFF', - backgroundColor: theme.palette.secondary, - '&:hover': { - backgroundColor: theme.palette.dark - }, - whiteSpace: 'nowrap', - paddingRight: 2 * theme.spacing.unit, - paddingLeft: 2 * theme.spacing.unit - }, - button: { - margin: theme.spacing.unit - }, - leftIcon: { - marginRight: theme.spacing.unit - }, - rightIcon: { - marginLeft: theme.spacing.unit - }, - iconSmall: { - fontSize: 20 - } -}) - -class NavBar extends Component { - - constructor (props) { - super(props) - this.state = { - authId: null - } - } - - componentDidMount () { - let user = localStorage.getItem('user') - let authId - - if (user !== null && user !== undefined && user !== 'undefined') { - user = JSON.parse(user) - authId = user.authId - } - - if (authId !== null && authId !== undefined && authId !== 'undefined') { - this.setState({ authId: authId }) - } - } - - render () { - const { classes, user, match } = this.props - console.log('NavBar: ', user, match) - return ( -
- - - - Users Module - - - - - - - - -
- ) - } -} - -NavBar.propTypes = { - classes: PropTypes.object.isRequired, - user: PropTypes.object, - match: PropTypes.object -} - -export default withStyles(styles)(NavBar) - diff --git a/client/components/ProfileImages.js b/client/components/ProfileImages.js deleted file mode 100644 index 268efeaee..000000000 --- a/client/components/ProfileImages.js +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react' -import Button from '@material-ui/core/Button' -import Dialog from '@material-ui/core/Dialog' -import DialogActions from '@material-ui/core/DialogActions' -import DialogContent from '@material-ui/core/DialogContent' -import DialogContentText from '@material-ui/core/DialogContentText' -import DialogTitle from '@material-ui/core/DialogTitle' -import CssBaseline from '@material-ui/core/CssBaseline' - -class Contact extends React.Component { - state = { - open: true - } - - handleClickOpen = () => { - this.setState({ open: true }) - } - - handleClose = () => { - this.setState({ open: false }) - } - - render () { - return ( - - - - - - {"Section under development."} - - - - The functionality of this section has not been developed yet. We expect to have it for November 2018. Thanks for your understanding. - - - - - - - - ) - } -} - -export default Contact diff --git a/client/components/ProfileSheet.js b/client/components/ProfileSheet.js deleted file mode 100644 index 1d81a4368..000000000 --- a/client/components/ProfileSheet.js +++ /dev/null @@ -1,497 +0,0 @@ -import React, { Component } from 'react' -import {graphql, compose} from 'react-apollo' -import {getRolesQuery, updateUserMutation, getUsersQuery} from '../queries/queries' - -// Material-ui - -import { withStyles } from '@material-ui/core/styles' -import MenuItem from '@material-ui/core/MenuItem' -import TextField from '@material-ui/core/TextField' -import FormControl from '@material-ui/core/FormControl' -import InputLabel from '@material-ui/core/InputLabel' -import Input from '@material-ui/core/Input' -import Button from '@material-ui/core/Button' -import FormControlLabel from '@material-ui/core/FormControlLabel' -import Checkbox from '@material-ui/core/Checkbox' -import FormGroup from '@material-ui/core/FormGroup' -import Select from '@material-ui/core/Select' -import FormHelperText from '@material-ui/core/FormHelperText' -import Paper from '@material-ui/core/Paper' -import Grid from '@material-ui/core/Grid' -import Typography from '@material-ui/core/Typography' - -// Images -import GithubLogo from '../img/github-logo.png' -import Auth0Logo from '../img/auth0-logo.png' -import AALogo from '../img/aa-logo.png' - -const styles = theme => ({ - root: { - width: '50%', - flexGrow: 1, - padding: 10, - marginLeft: '25%', - marginTop: '2%' - }, - inputField: { - width: '80%', - marginLeft: '10%', - marginTop: 25 - }, - typography: { - width: '80%', - marginLeft: '10%', - marginTop: 40 - }, - checkbox: { - width: 150, - marginLeft: '0%', - marginTop: 20 - }, - selectEmpty: { - marginTop: theme.spacing.unit * 2 - }, - button: { - margin: theme.spacing.unit, - marginTop: theme.spacing.unit * 3 - }, - img: { - display: 'block', - marginTop: 20, - maxWidth: 120, - maxHeight: 24 - } -}) - -class ProfileSheet extends Component { - - constructor (props) { - super(props) - - this.defaultValuesSet = false - - this.state = { - id: '', - firstName: '', - middleName: '', - lastName: '', - bio: '', - email: '', - emailVerified: 0, - isDeveloper: 0, - isTrader: 0, - isDataAnalyst: 0, - roleId: '1', - firstNameError: false, - middleNameError: false, - lastNameError: false, - bioError: false - } - } - - displayRoles () { - var data = this.props.getRolesQuery // When there is more than one query binded to a single componente 'data' is replaced by thename of the query given below at the binding operation. - if (data.loading) { - return ( - Loading roles - ) - } else { - return data.users_Roles.map(role => { - return ( - { role.name } - ) - }) - } - } - - submitForm (e) { - e.preventDefault() - this.props.updateUserMutation({ - variables: { - firstName: this.state.firstName, - middleName: this.state.middleName, - lastName: this.state.lastName, - bio: this.state.bio, - isDeveloper: this.state.isDeveloper, - isTrader: this.state.isTrader, - isDataAnalyst: this.state.isDataAnalyst, - roleId: this.state.roleId - }, - refetchQueries: [{ query: getUsersQuery}] // This allow us to re run whatever queries are necesary after the mutation. - }) - - /* Before we are done, we need to update the state of the local storage. */ - - let user = JSON.parse(localStorage.getItem('loggedInUser')) - - user.firstName = this.state.firstName - user.middleName = this.state.middleName - user.lastName = this.state.lastName - user.bio = this.state.bio - user.isDeveloper = this.state.isDeveloper - user.isTrader = this.state.isTrader - user.isDataAnalyst = this.state.isDataAnalyst - user.role.id = this.state.roleId - - localStorage.setItem('loggedInUser', JSON.stringify(user)) - } - - handleCheckBoxes (e) { - let fieldValue - if (e.target.checked === true) { - fieldValue = 1 - } else { - fieldValue = 0 - - /* When the user unchecks one of the checkboxes, we need to make sure that that Role is not the one selected at the SELECT, - and if it is, then we need to automatically select another one */ - - switch (e.target.id) { - case 'isDeveloper': - if (this.state.roleId === '2') { - this.setState({ roleId: '1'}) - } - break - - case 'isTrader': - if (this.state.roleId === '3') { - this.setState({ roleId: '1'}) - } - break - - case 'isDataAnalyst': - if (this.state.roleId === '4') { - this.setState({ roleId: '1'}) - } - break - default: - } - } - this.setState({ [e.target.id]: fieldValue}) - } - - handleSelect (e) { - /* - Whenever the select component changes its value, we need to activate the type of role selected. - To do so, we change the state of the corresponding type of role here. - */ - - switch (e.target.value) { - case '2': - this.setState({ isDeveloper: 1}) - break - case '3': - this.setState({ isTrader: 1}) - break - case '4': - this.setState({ isDataAnalyst: 1}) - break - default: - } - - this.setState({ roleId: e.target.value }) - } - - handleTextField (e) { - /* - We will do some basic input validations here. If something is wrong we will turn on the error sign on the textfield. - */ - - let value = e.target.value - - switch (e.target.id) { - case 'firstName': - if (value.length > 30) { - this.setState({firstNameError: true}) - } else { - this.setState({firstNameError: false, firstName: value}) - } - break - case 'middleName': - if (value.length > 30) { - this.setState({middleNameError: true}) - } else { - this.setState({middleNameError: false, middleName: value}) - } - break - case 'lastName': - if (value.length > 50) { - this.setState({lastNameError: true}) - } else { - this.setState({lastNameError: false, lastName: value}) - } - break - case 'bio': - if (value.length > 250) { - this.setState({bioError: true}) - } else { - this.setState({bioError: false, bio: value}) - } - break - default: - } - } - - rightCheckboxValue (stateValue) { - if (stateValue === 1) { - return true - } else { return false } - } - - componentWillMount () { - if (this.defaultValuesSet === false) { - let authId = localStorage.getItem('authId') - let userData = localStorage.getItem('loggedInUser') - - if (userData === 'undefined' || userData === null) { return } - - let user = JSON.parse(userData) - this.defaultValuesSet = true - - /* To avoid console warning, we need to take care of the fields that are null. */ - - if (user.firstName === null) { user.firstName = '' } - if (user.middleName === null) { user.middleName = '' } - if (user.lastName === null) { user.lastName = '' } - if (user.bio === null) { user.bio = '' } - - /* Now we are ready to set the initial state. */ - - this.setState({ - id: user.id, - alias: user.alias, - email: user.email, - emailVerified: user.emailVerified, - firstName: user.firstName, - middleName: user.middleName, - lastName: user.lastName, - bio: user.bio, - isDeveloper: user.isDeveloper, - isTrader: user.isTrader, - isDataAnalyst: user.isDataAnalyst, - roleId: user.role.id, - authId: authId - }) - } - } - - displayIdentityProvider () { - const { classes } = this.props - let authId = this.state.authId - - if (authId !== undefined && authId !== null) { - let authArray = this.state.authId.split('|') - let identityProvider = authArray[0] - - switch (identityProvider) { - case 'github': - return ( - Github - ) - break - case 'auth0': - return ( - Auth0 - ) - break - default: - - } - } - } - - render () { - const { classes } = this.props - return ( - - - Profile Sheet - -
- - - Use this form to control the information you keep at the Advanced Algos system about yourself. - - - - - {this.displayIdentityProvider()} - - - - - This is your basic information we have gotten from the identity provider you used to sign up. This information can not be changed. - - - - - - - - } - label='Email Verified' - /> - - - - Advanced Algos - - - - - Complete your profile with the following optional information. Providing your real name might help other users trust you more. - - - - - - - - - - If you wish, you can add a short paragraph with your Bio or anything you would like to communicate to whoever finds your user profile. - - - - - - Check the following options to enable specialized tools designed for each role. You can allways come back and change these settings later. - - - - - - - } - label='Developer' - /> - - - - } - label='Trader' - /> - - - - } - label='Data Analyst' - /> - - - - -

Your current role determines how the system is going to optimize its user interface to best serves your current needs.

- - - - Current Role - - - Select from the list your current role - - - - - - - - -
- - ) - } -} - -export default compose( - graphql(getRolesQuery, {name: 'getRolesQuery'}), - graphql(updateUserMutation, {name: 'updateUserMutation'}), - withStyles(styles) -)(ProfileSheet) // This technique binds more than one query to a single component. diff --git a/client/components/Search.js b/client/components/Search.js deleted file mode 100644 index c62f79384..000000000 --- a/client/components/Search.js +++ /dev/null @@ -1,37 +0,0 @@ -import React, { Component } from 'react' -import UserSearch from './UserSearch' -import {compose} from 'react-apollo' -import CssBaseline from '@material-ui/core/CssBaseline' - -// Materia UI - -import { withStyles } from '@material-ui/core/styles' - -const styles = theme => ({ - root: { - flexGrow: 1, - padding: 60, - margin: 2 - } -}) - -class Search extends Component { - - constructor (props) { - super(props) - this.state = { - } - } - render () { - return ( - - - - - ) - } -} - -export default compose( - withStyles(styles) -)(Search) diff --git a/client/components/User.js b/client/components/User.js deleted file mode 100644 index 043f3ddaf..000000000 --- a/client/components/User.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react' -import UserTabs from './UserTabs' -import CssBaseline from '@material-ui/core/CssBaseline' - -const User = () => { - return ( - - - - - ) -} - -export default User diff --git a/client/components/UserList.js b/client/components/UserList.js deleted file mode 100644 index 4e5751836..000000000 --- a/client/components/UserList.js +++ /dev/null @@ -1,185 +0,0 @@ -import React, { Component } from 'react'; -import {graphql, compose} from 'react-apollo'; -import {getUsersQuery} from '../queries/queries'; - -// Materia UI - -import { withStyles } from '@material-ui/core/styles'; -import Card from '@material-ui/core/Card'; -import CardActionArea from '@material-ui/core/CardActionArea'; -import CardActions from '@material-ui/core/CardActions'; -import CardContent from '@material-ui/core/CardContent'; -import CardMedia from '@material-ui/core/CardMedia'; -import Button from '@material-ui/core/Button'; -import Typography from '@material-ui/core/Typography'; -import Grid from '@material-ui/core/Grid'; -import Paper from '@material-ui/core/Paper'; - -// Full screen dialog imports (still Material UI) - -import PropTypes from 'prop-types'; -import Dialog from '@material-ui/core/Dialog'; -import AppBar from '@material-ui/core/AppBar'; -import Toolbar from '@material-ui/core/Toolbar'; -import IconButton from '@material-ui/core/IconButton'; - -import CloseIcon from '@material-ui/icons/Close'; -import Slide from '@material-ui/core/Slide'; - -// components -import UserProfile from './UserProfile'; - -// Images -import PortraitImage from '../img/portrait.jpg' - -const styles = theme => ({ - root: { - flexGrow: 1, - padding: 60, - margin: 2, - }, - card: { - maxWidth: 345, - minWidth: 300, - paddingTop:'30' - }, - media: { - height: 0, - paddingTop: '56.25%', // 16:9, - marginTop:'30', - minWidth: 300 - }, - typography: { - maxWidth: 345, - minWidth: 300, - paddingTop:'30' - }, - appBar: { - position: 'relative', - }, - flex: { - flex: 1, - }, - grid: { - paddingTop: 30, - marginTop:'30' - }, -}); - -function Transition(props) { - return ; -} - -class UserList extends Component { - - constructor(props){ - super(props); - this.state = { - selected: null, - open: false - } - } - - handleClickOpen = () => { - this.setState({ open: true }); - }; - - handleClose = () => { - this.setState({ open: false }); - }; - - displayUsers(){ - - let data = this.props.getUsersQuery; - const { classes } = this.props; - - if(data.loading){ - return (
Loading Users...
); - } else { - return data.users_Users.map(user => { - - return ( - - - { - this.setState({ selected: user.id}); - } - }> - - - - - {user.alias} - - - {user.bio} - - - - - - - - - - - - - - - User Profile - - - - - - - - - - - - - - - - - ) - }); - } - } - - render() { - const { classes } = this.props; - return ( - - - {this.displayUsers()} - - - ); - } -} - -UserList.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default compose( - graphql(getUsersQuery, {name: "getUsersQuery"}), - withStyles(styles) -) (UserList); // This technique binds more than one query to a single component. diff --git a/client/components/UserProfile.js b/client/components/UserProfile.js deleted file mode 100644 index 21906da18..000000000 --- a/client/components/UserProfile.js +++ /dev/null @@ -1,112 +0,0 @@ -import React, { Component } from 'react' -import {graphql, compose} from 'react-apollo' -import {getUserProfileQuery} from '../queries/queries' - -// Materia UI - -import { withStyles } from '@material-ui/core/styles' -import Grid from '@material-ui/core/Grid' -import Card from '@material-ui/core/Card' -import CardActionArea from '@material-ui/core/CardActionArea' -import CardContent from '@material-ui/core/CardContent' -import CardMedia from '@material-ui/core/CardMedia' -import Typography from '@material-ui/core/Typography' -import Divider from '@material-ui/core/Divider' - -// Images -import PortraitImage from '../img/portrait.jpg' - -const styles = theme => ({ - root: { - flexGrow: 1, - padding: 60, - margin: 2 - }, - card: { - width: '80%', - paddingTop: '30' - }, - media: { - height: 0, - paddingTop: '56.25%', // 16:9, - marginTop: '30', - minWidth: '80%' - }, - grid: { - paddingTop: '30', - marginTop: '30' - }, - typography: { - width: '100%', - marginTop: 20, - marginBottom: 20 - } - -}) - -class UserProfile extends Component { - - displayUserProfile () { - const user = this.props.data.users_User - const { classes } = this.props - - if (user) { - return ( - - - { - this.setState({ selected: user.id}) - } - }> - - - - - { user.firstName } { user.lastName } ( {user.alias} ) - - - - - { user.role.name } - - - - - { user.bio } - - - - - - ) - } else { - return (
No User selected...
) - } - } - - render () { - return ( - - {this.displayUserProfile()} - - ) - } -} - -export default compose( - graphql(getUserProfileQuery, { // What follows is the way to pass a parameter to a query. - options: (props) => { - return { - variables: { - name: 'getUserProfileQuery', - id: props.userId - } - } - }}), - withStyles(styles) -)(UserProfile) // This technique binds more than one query to a single component. diff --git a/client/components/UserSearch.js b/client/components/UserSearch.js deleted file mode 100644 index 6f184df2e..000000000 --- a/client/components/UserSearch.js +++ /dev/null @@ -1,267 +0,0 @@ -import React, { Component } from 'react' -import {graphql, compose} from 'react-apollo' -import {getUsersBySearchFields} from '../queries/queries' - -// Materia UI - -import { withStyles } from '@material-ui/core/styles' -import Card from '@material-ui/core/Card' -import CardActionArea from '@material-ui/core/CardActionArea' -import CardActions from '@material-ui/core/CardActions' -import CardContent from '@material-ui/core/CardContent' -import CardMedia from '@material-ui/core/CardMedia' -import Button from '@material-ui/core/Button' -import Typography from '@material-ui/core/Typography' -import Grid from '@material-ui/core/Grid' - -import TextField from '@material-ui/core/TextField' - -// Images -import PortraitImage from '../img/portrait.jpg' - -const styles = theme => ({ - card: { - maxWidth: 150, - minWidth: 150, - paddingTop: '30', - marginBottom: 40 - }, - media: { - height: 0, - paddingTop: '56.25%', // 16:9, - marginTop: '30', - minWidth: 300 - }, - typography: { - maxWidth: 345, - minWidth: 300, - paddingTop: '30' - }, - appBar: { - position: 'relative' - }, - flex: { - flex: 1 - }, - grid: { - paddingTop: '30', - marginTop: 30 - }, - inputField: { - width: '80%', - marginLeft: '10%', - marginTop: 25 - }, - formTypography: { - width: '80%', - marginLeft: '10%', - marginTop: 40 - }, - button: { - margin: theme.spacing.unit, - marginTop: theme.spacing.unit * 3 - } -}) - -class UserSearch extends Component { - - constructor (props) { - super(props) - - this.state = { - alias: '', - firstName: '', - middleName: '', - lastName: '' - } - } - - submitForm (e) { - e.preventDefault() - - this.props.getUsersBySearchFields.variables.alias = this.state.alias - this.props.getUsersBySearchFields.variables.firstName = this.state.firstName - this.props.getUsersBySearchFields.variables.middleName = this.state.middleName - this.props.getUsersBySearchFields.variables.lastName = this.state.lastName - - this.props.getUsersBySearchFields.refetch({}) - } - - handleTextField (e) { - /* - We will do some basic input validations here. If something is wrong we will turn on the error sign on the textfield. - */ - - let value = e.target.value - - switch (e.target.id) { - case 'alias': - if (value.length > 30) { - this.setState({aliasError: true}) - } else { - this.setState({aliasError: false, alias: value}) - } - break - case 'firstName': - if (value.length > 30) { - this.setState({firstNameError: true}) - } else { - this.setState({firstNameError: false, firstName: value}) - } - break - case 'middleName': - if (value.length > 30) { - this.setState({middleNameError: true}) - } else { - this.setState({middleNameError: false, middleName: value}) - } - break - case 'lastName': - if (value.length > 50) { - this.setState({lastNameError: true}) - } else { - this.setState({lastNameError: false, lastName: value}) - } - break - default: - } - } - - selectText () { - if (this.props.selectButton === true) { - return ({this.props.selectText}) - } else { - return () - } - } - - selectButton (user) { - if (this.props.selectButton === true) { - return ( - - ) - } else { - return (
) - } - } - - displayUsers () { - let data = this.props.getUsersBySearchFields - const { classes } = this.props - - if (data.loading) { - return (
Loading Users...
) - } else { - if (data.users_UsersSearch === undefined) { - return (
No Users to Display
) - } else { - return data.users_UsersSearch.map(user => { - return ( - - - { - this.setState({ selected: user.id}) - } - }> - - - - - {user.alias} - - - - - - - {this.selectButton(user)} - - - - - - - ) - }) - } - } - } - - render () { - const { classes } = this.props - return ( -
-
- - - Use any of these fileds to search for users. {this.selectText()} - - - - - - - - - - - - - - - - - - - {this.displayUsers()} - -
- ) - } -} - -export default compose( - graphql(getUsersBySearchFields, {name: 'getUsersBySearchFields'}), - withStyles(styles) -)(UserSearch) // This technique binds more than one query to a single component. diff --git a/client/components/UserTabs.js b/client/components/UserTabs.js deleted file mode 100644 index 28b3ae94c..000000000 --- a/client/components/UserTabs.js +++ /dev/null @@ -1,85 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; -import AppBar from '@material-ui/core/AppBar'; -import Tabs from '@material-ui/core/Tabs'; -import Tab from '@material-ui/core/Tab'; -import ProfileSheetIcon from '@material-ui/icons/Create'; -import ProfileImagesIcon from '@material-ui/icons/Wallpaper'; -import YourReferrerIcon from '@material-ui/icons/AccessibilityNew'; -import DescendentsIcon from '@material-ui/icons/DeviceHub'; -import Typography from '@material-ui/core/Typography'; - -// Components - -import ProfileSheet from './ProfileSheet'; -import ProfileImages from './ProfileImages'; -import YourReferrer from './YourReferrer'; -import YourDescendents from './YourDescendents'; - -function TabContainer(props) { - return ( - - {props.children} - - ); -} - -TabContainer.propTypes = { - children: PropTypes.node.isRequired, -}; - -const styles = theme => ({ - root: { - flexGrow: 1, - width: '100%', - backgroundColor: theme.palette.background.paper, - padding: 0, - margin: 0, - }, -}); - -class UserTabs extends React.Component { - state = { - value: 0 - }; - - handleChange = (event, value) => { - this.setState({ value }); - }; - - render() { - const { classes } = this.props; - const { value } = this.state; - - return ( -
- - - } /> - } /> - } /> - } /> - - - {value === 0 && } - {value === 1 && } - {value === 2 && } - {value === 3 && } -
- ); - } -} - -UserTabs.propTypes = { - classes: PropTypes.object.isRequired, -}; - -export default withStyles(styles)(UserTabs); diff --git a/client/components/YourDescendents.js b/client/components/YourDescendents.js deleted file mode 100644 index dd5f4aec4..000000000 --- a/client/components/YourDescendents.js +++ /dev/null @@ -1,86 +0,0 @@ -import React, { Component } from 'react' -import {compose} from 'react-apollo' - -// Materia UI - -import { withStyles } from '@material-ui/core/styles' -import Typography from '@material-ui/core/Typography' -import Grid from '@material-ui/core/Grid' -import Paper from '@material-ui/core/Paper' - -// components -import DescendentsTree from './DescendentsTree' - -const styles = theme => ({ - root: { - width: '50%', - flexGrow: 1, - padding: 10, - marginLeft: '25%', - marginTop: '2%' - }, - typography: { - width: '80%', - marginLeft: '10%', - marginTop: 40, - marginBottom: 40 - }, - grid: { - paddingTop: '30', - marginTop: 30 - } -}) - -class YourDescendents extends Component { - - constructor (props) { - super(props) - - this.defaultValuesSet = false - - this.state = { - id: '' - } - } - - componentWillMount () { - if (this.defaultValuesSet === false) { - let userData = localStorage.getItem('loggedInUser') - - if (userData === 'undefined') { return } - - let user = JSON.parse(userData) - this.defaultValuesSet = true - - /* Now we are ready to set the initial state. */ - this.setState({ - id: user.id - }) - } - } - - render () { - const { classes } = this.props - - return ( - - - Your Descendents - - - - These are your decendents within the project. Your children referred you as the one who brought them to the project, while - your grandchildren referred your children and so on. In order to be able to see your descendents, the users who you referred - must first point to you as your referrer. - - - - - - ) - } -} - -export default compose( - withStyles(styles) -)(YourDescendents) // This technique binds more than one query to a single component. diff --git a/client/components/YourReferrer.js b/client/components/YourReferrer.js deleted file mode 100644 index 6a658ea4d..000000000 --- a/client/components/YourReferrer.js +++ /dev/null @@ -1,145 +0,0 @@ -import React, { Component } from 'react' -import {graphql, compose} from 'react-apollo' -import {updateReferrerMutation} from '../queries/queries' - -// components - -import UserSearch from './UserSearch' -import UserProfile from './UserProfile' - -// Material-ui - -import { withStyles } from '@material-ui/core/styles' -import Paper from '@material-ui/core/Paper' -import Typography from '@material-ui/core/Typography' - -const styles = theme => ({ - root: { - width: '50%', - flexGrow: 1, - padding: 10, - marginLeft: '25%', - marginTop: '2%' - }, - typography: { - width: '80%', - marginLeft: '10%', - marginTop: 40, - marginBottom: 40 - }, - button: { - margin: theme.spacing.unit, - marginTop: theme.spacing.unit * 3 - }, - inputField: { - width: '80%', - marginLeft: '10%', - marginTop: 25 - } -}) - -class YourReferrer extends Component { - - constructor (props) { - super(props) - - this.defaultValuesSet = false - - this.state = { - id: '', - referrerId: '', - firstNameError: false, - middleNameError: false, - lastNameError: false, - aliasError: false - } - } - - userSelected (referrerUser) { - this.setState({referrerId: referrerUser.id}) - - this.props.updateReferrerMutation({ - variables: { - referrerId: referrerUser.id - } - }) - - /* Before we are done, we need to update the state of the local storage. */ - - let user = JSON.parse(localStorage.getItem('loggedInUser')) - - user.referrerId = referrerUser.id - - localStorage.setItem('loggedInUser', JSON.stringify(user)) - } - - renderMode () { - const { classes } = this.props - - if (this.state.referrerId !== null) { - return ( -
- - This is the user who introduced you to the project. - - - - - - This information can not be changed. - -
- ) - } else { - return ( -
- - We know that a group often becomes more intelligent when the number of people in the group increases. - To incentivize members of the community to invite more people to join we have developed this referral - program in which you can specify who referred you to the project, and see the members who pointed at - you as their referrer. Later this information will be available at your user profile and add to your - overall reputation within the project. - - - -
- ) - } - } - - componentWillMount () { - if (this.defaultValuesSet === false) { - let userData = localStorage.getItem('loggedInUser') - - if (userData === 'undefined') { return } - - let user = JSON.parse(userData) - this.defaultValuesSet = true - - /* Now we are ready to set the initial state. */ - - this.setState({ - id: user.id, - referrerId: user.referrerId - }) - } - } - - render () { - const { classes } = this.props - return ( - - - Your Referrer - - - {this.renderMode()} - - ) - } -} - -export default compose( - graphql(updateReferrerMutation, {name: 'updateReferrerMutation'}), - withStyles(styles) -)(YourReferrer) // This technique binds more than one query to a single component. diff --git a/client/img/aa-logo-dark-8.png b/client/img/aa-logo-dark-8.png deleted file mode 100644 index a6bcfcb90..000000000 Binary files a/client/img/aa-logo-dark-8.png and /dev/null differ diff --git a/client/img/aa-logo.png b/client/img/aa-logo.png deleted file mode 100644 index 9701ee1c0..000000000 Binary files a/client/img/aa-logo.png and /dev/null differ diff --git a/client/img/auth0-logo.png b/client/img/auth0-logo.png deleted file mode 100644 index ba4c72724..000000000 Binary files a/client/img/auth0-logo.png and /dev/null differ diff --git a/client/img/email.png b/client/img/email.png deleted file mode 100644 index 93b2edf0c..000000000 Binary files a/client/img/email.png and /dev/null differ diff --git a/client/img/github-head-negative.png b/client/img/github-head-negative.png deleted file mode 100644 index 1a1d757b1..000000000 Binary files a/client/img/github-head-negative.png and /dev/null differ diff --git a/client/img/github-head.png b/client/img/github-head.png deleted file mode 100644 index a815207a3..000000000 Binary files a/client/img/github-head.png and /dev/null differ diff --git a/client/img/github-logo.png b/client/img/github-logo.png deleted file mode 100644 index 336861716..000000000 Binary files a/client/img/github-logo.png and /dev/null differ diff --git a/client/img/github-negative.png b/client/img/github-negative.png deleted file mode 100644 index 967efa057..000000000 Binary files a/client/img/github-negative.png and /dev/null differ diff --git a/client/img/github.png b/client/img/github.png deleted file mode 100644 index 92d3c954b..000000000 Binary files a/client/img/github.png and /dev/null differ diff --git a/client/img/portrait.jpg b/client/img/portrait.jpg deleted file mode 100644 index 2108ceee8..000000000 Binary files a/client/img/portrait.jpg and /dev/null differ diff --git a/client/index.js b/client/index.js deleted file mode 100644 index e77b9c49f..000000000 --- a/client/index.js +++ /dev/null @@ -1,86 +0,0 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types' -import { Route, BrowserRouter, Switch } from 'react-router-dom' -import { hot } from 'react-hot-loader' - -import { withStyles } from '@material-ui/core/styles' - -// Components -import NavBar from './components/NavBar' -import Home from './components/Home' -import User from './components/User' -import Browse from './components/Browse' -import Search from './components/Search' -import About from './components/About' -import Contact from './components/Contact' - -import { getItem } from './utils/local-storage' -import { - globalStyles -} from './theme' - -class App extends Component { - constructor (props) { - super(props) - this.state = { - user: null - } - } - - async componentDidMount () { - let user = await getItem('user') - - if (user !== null && user !== undefined && user !== 'undefined') { - user = JSON.parse(user) - this.setState({ user: user }) - } - } - - render () { - const { match } = this.props - - return ( - -
- - - - } - /> - } - /> - } - /> - } - /> - } - /> - - -
-
- ) - } -} - -App.propTypes = { - auth: PropTypes.object -} - -const StyledApp = withStyles(globalStyles)(App) -export default hot(module)(StyledApp) diff --git a/client/public/favicon.ico b/client/public/favicon.ico deleted file mode 100644 index 08c2369b0..000000000 Binary files a/client/public/favicon.ico and /dev/null differ diff --git a/client/public/index.html b/client/public/index.html deleted file mode 100644 index d5814b15e..000000000 --- a/client/public/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - Advanced Algos - Users Module - - - - - - - -
- - diff --git a/client/public/manifest.json b/client/public/manifest.json deleted file mode 100644 index ef19ec243..000000000 --- a/client/public/manifest.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - } - ], - "start_url": "./index.html", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/client/queries/queries.js b/client/queries/queries.js deleted file mode 100644 index 8a58b3d04..000000000 --- a/client/queries/queries.js +++ /dev/null @@ -1,165 +0,0 @@ -import gql from 'graphql-tag' - -const getUsersQuery = gql` -{ - users_Users { - id - alias - firstName - middleName - lastName - bio - role { - id - name - } - } -} -` -const getUserProfileQuery = gql` -query($id: ID){ - users_User (id: $id){ - id - alias - firstName - middleName - lastName - bio - avatarHandle - role { - id - name - } - } -} -` -const getUserByAuthIdQuery = gql` -query($authId: String){ - users_UserByAuthId (authId: $authId){ - id - referrerId - alias - firstName - middleName - lastName - bio - email - emailVerified - isDeveloper - isDataAnalyst - isTrader - avatarHandle - avatarChangeDate - role { - id - } - } -} -` -const getUsersBySearchFields = gql` -query( - $alias: String, - $firstName: String, - $middleName: String, - $lastName: String -){ - users_UsersSearch (alias: $alias, firstName: $firstName, middleName: $middleName, lastName: $lastName){ - id - alias - firstName - middleName - lastName - } -} -` -const getDescendentsQuery = gql` -query( - $id: String -){ - users_Descendents (id: $id){ - id - alias - firstName - middleName - lastName - referrerId - descendents { - id - alias - firstName - middleName - lastName - referrerId - descendents { - id - alias - firstName - middleName - lastName - referrerId - } - } - } -} -` -const getRolesQuery = gql` -{ - users_Roles { - id - name - } -} -` -const updateUserMutation = gql` -mutation( - $firstName:String, - $middleName:String, - $lastName:String, - $bio:String, - $isDeveloper:Int, - $isTrader:Int, - $isDataAnalyst:Int, - $roleId:String! -) - { - users_UpdateUser ( - firstName:$firstName, - middleName: $middleName, - lastName: $lastName, - bio: $bio, - isDeveloper: $isDeveloper, - isTrader: $isTrader, - isDataAnalyst: $isDataAnalyst, - roleId: $roleId - ) - { - id - alias - } -} -` -const updateReferrerMutation = gql` -mutation( - $referrerId:String! -) - { - users_UpdateUserReferrer ( - referrerId:$referrerId - ) - { - id - referrerId - } -} -` - -export { - getUsersQuery, - getUserByAuthIdQuery, - getRolesQuery, - getUserProfileQuery, - getUsersBySearchFields, - getDescendentsQuery, - updateUserMutation, - updateReferrerMutation -} diff --git a/client/src/components/ProfileSheet.js b/client/src/components/ProfileSheet.js index 56a4dd74e..1d81a4368 100644 --- a/client/src/components/ProfileSheet.js +++ b/client/src/components/ProfileSheet.js @@ -108,7 +108,6 @@ class ProfileSheet extends Component { e.preventDefault() this.props.updateUserMutation({ variables: { - id: this.state.id, firstName: this.state.firstName, middleName: this.state.middleName, lastName: this.state.lastName, diff --git a/client/src/components/YourReferrer.js b/client/src/components/YourReferrer.js index 946f2e4e7..6a658ea4d 100644 --- a/client/src/components/YourReferrer.js +++ b/client/src/components/YourReferrer.js @@ -60,7 +60,6 @@ class YourReferrer extends Component { this.props.updateReferrerMutation({ variables: { - id: this.state.id, referrerId: referrerUser.id } }) diff --git a/client/src/queries/queries.js b/client/src/queries/queries.js index 841538779..50eb8fdbd 100644 --- a/client/src/queries/queries.js +++ b/client/src/queries/queries.js @@ -112,7 +112,6 @@ const getRolesQuery = gql` ` const updateUserMutation = gql` mutation( - $id: ID!, $firstName:String, $middleName:String, $lastName:String, @@ -124,7 +123,6 @@ mutation( ) { users_UpdateUser ( - id: $id, firstName:$firstName, middleName: $middleName, lastName: $lastName, @@ -142,12 +140,10 @@ mutation( ` const updateReferrerMutation = gql` mutation( - $id: ID!, $referrerId:String! ) { users_UpdateUserReferrer ( - id: $id, referrerId:$referrerId ) { @@ -156,24 +152,6 @@ mutation( } } ` -const updateUserImagesMutation = gql` -mutation( - $id: ID!, - $avatarHandle:String, - $avatarChangeDate:String -) - { - users_UpdateUserImages ( - id: $id, - avatarHandle:$avatarHandle, - avatarChangeDate: $avatarChangeDate - ) - { - id - alias - } -} -` export { getUsersQuery, getUserByAuthIdQuery, @@ -182,6 +160,5 @@ export { getUsersBySearchFields, getDescendentsQuery, updateUserMutation, - updateReferrerMutation, - updateUserImagesMutation + updateReferrerMutation } diff --git a/client/theme.js b/client/theme.js deleted file mode 100644 index 96492c48c..000000000 --- a/client/theme.js +++ /dev/null @@ -1,65 +0,0 @@ -import { createMuiTheme } from '@material-ui/core/styles' - -export const theme = createMuiTheme({ - palette: { - primary: { main: '#303036' }, // DARK. - secondary: { main: '#CC5835' } // RUSTED_RED. - }, - typography: { - fontFamily: '"Saira","Saira Condenses", sans-serif' - }, - overrides: { - Paper: { - root: { - backgroundColor: '#ffffff' - }, - elevation: 0, - square: true - } - } -}) - -export const globalStyles = theme => ({ - '@global': { - body: { - backgroundColor: theme.palette.common.white - } - }, - appBar: { - position: 'relative' - }, - toolbarTitle: { - flex: 1 - }, - layout: { - width: 'auto', - marginLeft: theme.spacing.unit * 3, - marginRight: theme.spacing.unit * 3, - [theme.breakpoints.up(900 + theme.spacing.unit * 3 * 2)]: { - width: 900, - marginLeft: 'auto', - marginRight: 'auto' - } - }, - heroContent: { - maxWidth: 600, - margin: '0 auto', - padding: `${theme.spacing.unit * 8}px 0 ${theme.spacing.unit * 6}px` - }, - cardHeader: { - backgroundColor: theme.palette.grey[200] - }, - cardPricing: { - display: 'flex', - justifyContent: 'center', - alignItems: 'baseline', - marginBottom: theme.spacing.unit * 2 - }, - cardActions: { - [theme.breakpoints.up('sm')]: { - paddingBottom: theme.spacing.unit * 2 - } - } -}) - -export default theme diff --git a/server/app.js b/server/app.js index 2ba7662bb..b314a0f97 100644 --- a/server/app.js +++ b/server/app.js @@ -30,10 +30,15 @@ app.get('/graphql', graphqlHTTP({ graphiql: true })) -app.post('/graphql', graphqlHTTP({ - schema, - graphiql: false, - context: req => ({ ...req }) +app.post('/graphql', graphqlHTTP(req => { + return { + schema, + graphiql: false, + context: { + user: req.user, + userId: req.headers.userid + } + } })) app.post('/graphql', checkJwt, (err, req, res, next) => { diff --git a/server/package-lock.json b/server/package-lock.json index ea30295b3..6e2f22e09 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -204,6 +204,56 @@ "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" }, + "color": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/color/-/color-3.0.0.tgz", + "integrity": "sha512-jCpd5+s0s0t7p3pHQKpnJ0TpQKKdleP71LWcA0aqiljpiuAkOSUFN/dyH8ZwF0hRmFlrIuRhufds1QyEP9EB+w==", + "requires": { + "color-convert": "1.9.3", + "color-string": "1.5.3" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "color-string": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.5.3.tgz", + "integrity": "sha512-dC2C5qeWoYkxki5UAXapdjqO672AM4vZuPGRQfO8b5HKuKGBbKWpITyDYN7TOFKvRW7kOgAn3746clDBMDJyQw==", + "requires": { + "color-name": "1.1.3", + "simple-swizzle": "0.2.2" + } + }, + "colornames": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/colornames/-/colornames-1.1.1.tgz", + "integrity": "sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y=" + }, + "colors": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.2.tgz", + "integrity": "sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ==" + }, + "colorspace": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.1.tgz", + "integrity": "sha512-pI3btWyiuz7Ken0BWh9Elzsmv2bM9AhA7psXib4anUXy/orfZ/E0MbQwhSOG/9L8hLlalqrU0UhOuqxW1YjmVw==", + "requires": { + "color": "3.0.0", + "text-hex": "1.0.0" + } + }, "combined-stream": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", @@ -277,6 +327,16 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" }, + "diagnostics": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz", + "integrity": "sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ==", + "requires": { + "colorspace": "1.1.1", + "enabled": "1.0.2", + "kuler": "1.0.1" + } + }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", @@ -300,11 +360,24 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" }, + "enabled": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", + "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", + "requires": { + "env-variable": "0.0.5" + } + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, + "env-variable": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.5.tgz", + "integrity": "sha512-zoB603vQReOFvTg5xMl9I1P2PnHsHQQKTEowsKKD7nseUfJq6UWzK+4YtlWUO1nhiQUxe6XMkk+JleSZD1NZFA==" + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -406,6 +479,16 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" }, + "fast-safe-stringify": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz", + "integrity": "sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg==" + }, + "fecha": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", + "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" + }, "finalhandler": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", @@ -511,11 +594,26 @@ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" }, + "is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==" + }, + "is-stream": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -618,6 +716,14 @@ "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.2.1.tgz", "integrity": "sha512-xpDFy8OxkFM+vK6pXy6JmH92ibeEFUuDWzas5M9L7MzVmHW3jzwAHxodCPV/BYkf4A31bVDLyonrMfp9RXb/oA==" }, + "kuler": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/kuler/-/kuler-1.0.1.tgz", + "integrity": "sha512-J9nVUucG1p/skKul6DU3PUZrhs0LPulNaeUOox0IyXDi8S4CztTHs1gQphhuZmzXG7VOQSf6NJfKuzteQLv9gQ==", + "requires": { + "colornames": "1.1.1" + } + }, "limiter": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/limiter/-/limiter-1.1.3.tgz", @@ -678,6 +784,25 @@ "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", "integrity": "sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=" }, + "logform": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/logform/-/logform-1.10.0.tgz", + "integrity": "sha512-em5ojIhU18fIMOw/333mD+ZLE2fis0EzXl1ZwHx4iQzmpQi6odNiY/t+ITNr33JZhT9/KEaH+UPIipr6a9EjWg==", + "requires": { + "colors": "1.3.2", + "fast-safe-stringify": "2.0.6", + "fecha": "2.3.3", + "ms": "2.1.1", + "triple-beam": "1.3.0" + }, + "dependencies": { + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" + } + } + }, "lru-cache": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.0.2.tgz", @@ -3558,6 +3683,11 @@ "ee-first": "1.1.1" } }, + "one-time": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz", + "integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4=" + }, "parseurl": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", @@ -3573,6 +3703,11 @@ "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==" + }, "proxy-addr": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", @@ -3641,6 +3776,20 @@ } } }, + "readable-stream": { + "version": "2.3.6", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.1.1", + "util-deprecate": "1.0.2" + } + }, "regexp-clone": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/regexp-clone/-/regexp-clone-0.0.1.tgz", @@ -3756,6 +3905,14 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" }, + "simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo=", + "requires": { + "is-arrayish": "0.3.2" + } + }, "sliced": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/sliced/-/sliced-1.0.1.tgz", @@ -3777,11 +3934,29 @@ "tweetnacl": "0.14.5" } }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA=" + }, "statuses": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "5.1.1" + } + }, + "text-hex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", + "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==" + }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", @@ -3791,6 +3966,11 @@ "punycode": "1.4.1" } }, + "triple-beam": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz", + "integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw==" + }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -3819,6 +3999,11 @@ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -3849,6 +4034,31 @@ "resolved": "https://registry.npmjs.org/very-fast-args/-/very-fast-args-1.1.0.tgz", "integrity": "sha1-4W0dH6+KbllqJGQh/ZCneWPQs5Y=" }, + "winston": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.1.0.tgz", + "integrity": "sha512-FsQfEE+8YIEeuZEYhHDk5cILo1HOcWkGwvoidLrDgPog0r4bser1lEIOco2dN9zpDJ1M88hfDgZvxe5z4xNcwg==", + "requires": { + "async": "2.6.1", + "diagnostics": "1.1.1", + "is-stream": "1.1.0", + "logform": "1.10.0", + "one-time": "0.0.4", + "readable-stream": "2.3.6", + "stack-trace": "0.0.10", + "triple-beam": "1.3.0", + "winston-transport": "4.2.0" + } + }, + "winston-transport": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.2.0.tgz", + "integrity": "sha512-0R1bvFqxSlK/ZKTH86nymOuKv/cT1PQBMuDdA7k7f0S9fM44dNH6bXnuxwXPrN8lefJgtZq08BKdyZ0DZIy/rg==", + "requires": { + "readable-stream": "2.3.6", + "triple-beam": "1.3.0" + } + }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", diff --git a/server/package.json b/server/package.json index a59e515a4..db1a3063b 100644 --- a/server/package.json +++ b/server/package.json @@ -18,6 +18,7 @@ "jwks-rsa": "^1.3.0", "lodash": "^4.17.10", "mongoose": "^5.2.12", - "npm": "^6.4.1" + "npm": "^6.4.1", + "winston": "^3.1.0" } } diff --git a/server/schema/schema.js b/server/schema/schema.js index b3495821f..9b3cba2f4 100644 --- a/server/schema/schema.js +++ b/server/schema/schema.js @@ -3,7 +3,7 @@ const MODULE_NAME = 'schema' const graphql = require('graphql') const _ = require('lodash') const User = require('../models/user') - +const logger = require('../utils/logger') const tokenDecoder = require('../auth/token-decoder') const { @@ -104,22 +104,22 @@ const RootQuery = new GraphQLObjectType({ resolve (parent, args) { // Code to get data from data source. - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Entering function.') } /* In order to be able to wait for asyc calls to the database, we need to return a promise to GraphQL. */ const promiseToGraphQL = new Promise((resolve, reject) => { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> Entering function.') } - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> args.authId = ' + args.authId) } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> args.authId = ' + args.authId) } findUserByAuthId(args.authId, onUserFound) function onUserFound (err, responseToGraphQL) { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> onUserFound -> Entering function.') } - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> onUserFound -> responseToGraphQL = ' + JSON.stringify(responseToGraphQL)) } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> onUserFound -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> onUserFound -> responseToGraphQL = ' + JSON.stringify(responseToGraphQL)) } if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> onUserFound -> err.message = ' + err.message) } + if (global.ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> RootQuery -> userByAuthId -> resolve -> Promise -> onUserFound -> err.message = ' + err.message) } reject(responseToGraphQL) } else { resolve(responseToGraphQL) @@ -154,7 +154,7 @@ const RootQuery = new GraphQLObjectType({ type: new GraphQLList(UserType), args: {alias: {type: GraphQLString}, firstName: {type: GraphQLString}, middleName: {type: GraphQLString}, lastName: {type: GraphQLString}}, resolve (parent, args) { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> RootQuery -> usersSearch -> resolve -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> RootQuery -> usersSearch -> resolve -> Entering function.') } let mongoQuery = { $or: [] } @@ -172,7 +172,7 @@ const RootQuery = new GraphQLObjectType({ type: new GraphQLList(DescendentType), args: {id: {type: GraphQLString}}, resolve (parent, args) { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> RootQuery -> descendents -> resolve -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> RootQuery -> descendents -> resolve -> Entering function.') } return User.find({referrerId: args.id}) } @@ -191,20 +191,20 @@ const Mutation = new GraphQLObjectType({ idToken: {type: new GraphQLNonNull(GraphQLString)} }, resolve (parent, args) { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Entering function.') } /* In order to be able to wait for asyc calls to the database, and authorization authority, we need to return a promise to GraphQL. */ const promiseToGraphQL = new Promise((resolve, reject) => { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Promise -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Promise -> Entering function.') } authenticate(args.idToken, onAuthenticated) function onAuthenticated (err, responseToGraphQL) { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Promise -> onAuthenticated -> Entering function.') } - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Promise -> onAuthenticated -> responseToGraphQL = ' + JSON.stringify(responseToGraphQL)) } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Promise -> onAuthenticated -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Promise -> onAuthenticated -> responseToGraphQL = ' + JSON.stringify(responseToGraphQL)) } if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Promise -> onAuthenticated -> err.message = ' + err.message) } + if (global.ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> Mutation -> authenticate -> resolve -> Promise -> onAuthenticated -> err.message = ' + err.message) } reject(responseToGraphQL) } else { resolve(responseToGraphQL) @@ -289,12 +289,12 @@ const Mutation = new GraphQLObjectType({ function findUserByAuthId (authId, callBackFunction) { try { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> Entering function.') } - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> authId = ' + authId) } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> authId = ' + authId) } if (authId === null || authId === undefined) { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> User requested not specified.') } - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> args.authId = ' + authId) } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> User requested not specified.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> args.authId = ' + authId) } callBackFunction(global.DEFAULT_FAIL_RESPONSE, { error: 'Bad Request' }) return @@ -304,13 +304,13 @@ function findUserByAuthId (authId, callBackFunction) { function onUserReceived (err, user) { if (err) { - if (ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> Database Error.') } - if (ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> err = ' + err) } + if (ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> Database Error.') } + if (ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> err = ' + err) } callBackFunction(global.DEFAULT_FAIL_RESPONSE, { error: err }) } else { if (user === null) { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> User not found at Database.') } - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> args.authId = ' + authId) } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> User not found at Database.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> args.authId = ' + authId) } let customResponse = { result: global.CUSTOM_OK_RESPONSE.result, @@ -322,15 +322,15 @@ function findUserByAuthId (authId, callBackFunction) { } if (user.authId === authId && user.authId !== undefined) { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> User found at Database.') } - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> args.authId = ' + authId) } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> User found at Database.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> args.authId = ' + authId) } callBackFunction(global.DEFAULT_OK_RESPONSE, user) return } else { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> User found at Database is not the user requested.') } - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> args.authId = ' + authId) } - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> user.authId = ' + user.authId) } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> User found at Database is not the user requested.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> args.authId = ' + authId) } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> findUserByAuthId -> onUserReceived -> user.authId = ' + user.authId) } callBackFunction(global.DEFAULT_FAIL_RESPONSE, { error: err }) return @@ -338,14 +338,14 @@ function findUserByAuthId (authId, callBackFunction) { } } } catch (err) { - if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> findUserByAuthId -> err.message = ' + err.message) } + if (global.ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> findUserByAuthId -> err.message = ' + err.message) } callBackFunction(global.DEFAULT_FAIL_RESPONSE, { error: err }) } } function authenticate (encodedToken, callBackFunction) { try { - if (INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> authenticate -> Entering function.') } + if (INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> authenticate -> Entering function.') } let authId = '' let alias = '' @@ -355,10 +355,10 @@ function authenticate (encodedToken, callBackFunction) { tokenDecoder(encodedToken, onValidated) function onValidated (err, decodedToken) { - if (global.INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> Entering function.') } + if (global.INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> Entering function.') } if (err.result !== global.DEFAULT_OK_RESPONSE.result) { - if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> err.message = ' + err.message) } + if (global.ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> err.message = ' + err.message) } callBackFunction(global.DEFAULT_FAIL_RESPONSE, { error: err }) return } @@ -378,18 +378,18 @@ function authenticate (encodedToken, callBackFunction) { findUserByAuthId(authId, onUserFound) function onUserFound (err, user) { - if (global.INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> Entering function.') } + if (global.INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> Entering function.') } if (err.result === global.DEFAULT_FAIL_RESPONSE.result) { - if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> err.message = ' + err.message) } + if (global.ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> err.message = ' + err.message) } callBackFunction(global.DEFAULT_FAIL_RESPONSE, { error: err }) return } if (err.result === global.DEFAULT_OK_RESPONSE.result) { - if (global.INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> User already exists at database') } + if (global.INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> User already exists at database') } - if (global.INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> Existing User: ' + JSON.stringify(user)) } + if (global.INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> Existing User: ' + JSON.stringify(user)) } /* @@ -408,7 +408,7 @@ function authenticate (encodedToken, callBackFunction) { err.result === global.CUSTOM_OK_RESPONSE.result && err.message === 'User Not Found' ) { - if (global.INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> User does not exist at database') } + if (global.INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> User does not exist at database') } /* @@ -427,8 +427,8 @@ function authenticate (encodedToken, callBackFunction) { socialAccountProvider !== 'github' && socialAccountProvider !== 'auth0' ) { - if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> Social Account Provider not Supoorted. ') } - if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> socialAccountProvider = ' + socialAccountProvider) } + if (global.ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> Social Account Provider not Supoorted. ') } + if (global.ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> socialAccountProvider = ' + socialAccountProvider) } callBackFunction(global.DEFAULT_FAIL_RESPONSE, { error: err }) return @@ -446,20 +446,20 @@ function authenticate (encodedToken, callBackFunction) { roleId: '1' }) - if (global.INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> ' + alias + ' being added to the database') } + if (global.INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> ' + alias + ' being added to the database') } newUser.save(onSaved) function onSaved (err, savedUser) { - if (global.INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> onSaved -> Entering function.') } + if (global.INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> onSaved -> Entering function.') } if (err) { - if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> onSaved -> err = ' + err) } + if (global.ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> onSaved -> err = ' + err) } callBackFunction(global.DEFAULT_FAIL_RESPONSE, { error: err }) return } - if (global.INFO_LOG === true) { console.log('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> onSaved -> Saved User: ' + JSON.stringify(savedUser)) } + if (global.INFO_LOG === true) { logger.info('[INFO] ' + MODULE_NAME + ' -> authenticate -> onValidated -> onUserFound -> onSaved -> Saved User: ' + JSON.stringify(savedUser)) } /* @@ -476,7 +476,7 @@ function authenticate (encodedToken, callBackFunction) { } } } catch (err) { - if (global.ERROR_LOG === true) { console.log('[ERROR] ' + MODULE_NAME + ' -> authenticate -> err.message = ' + err.message) } + if (global.ERROR_LOG === true) { logger.error('[ERROR] ' + MODULE_NAME + ' -> authenticate -> err.message = ' + err.message) } callBackFunction(global.DEFAULT_FAIL_RESPONSE, { error: err }) } } diff --git a/client/utils/local-storage.js b/server/utils/local-storage.js similarity index 100% rename from client/utils/local-storage.js rename to server/utils/local-storage.js diff --git a/client/config/logger.js b/server/utils/logger.js similarity index 100% rename from client/config/logger.js rename to server/utils/logger.js