Migration to MasterApp part 1

This commit is contained in:
Luis Fernando Molina committed 2018-10-14 07:45:41 +02:00
1 parent ccd1a7084f
commit 558ed31180
14 files changed
+8796 -5821

No files matched your search

+1
View File
@@ -0,0 +1 @@
build/
+8723 -5628
View File
File diff suppressed because it is too large. Load diff
+17 -14
View File
@@ -1,29 +1,32 @@
{
"name": "client",
"version": "0.1.0",
"private": true,
"name": "@advancedalgos/users-client",
"description": "Advanced Algos Users client-side web app",
"version": "0.0.8",
"main": "src/index.js",
"dependencies": {
"@material-ui/core": "^3.0.2",
"@material-ui/icons": "^3.0.1",
"auth0-lock": "^11.9.0",
"filestack-js": "^1.5.1",
"filestack-react": "^2.0.0",
"react": "^16.4.2",
"react-apollo": "^2.1.11",
"react-dom": "^16.4.2",
"react-hot-loader": "^4.3.11",
"react-router-dom": "^4.3.1",
"react-scripts": "^2.0.4",
"apollo-cache-inmemory": "^1.2.9",
"apollo-client": "^2.4.1",
"apollo-link": "^1.2.2",
"apollo-link-context": "^1.0.8",
"apollo-link-error": "^1.1.0",
"apollo-link-http": "^1.5.4",
"auth0-lock": "^11.9.0",
"filestack-js": "^1.5.1",
"filestack-react": "^2.0.0",
"classnames": "^2.2.6",
"graphql": "^14.0.0",
"graphql-tag": "^2.9.2",
"react": "^16.4.2",
"react-apollo": "^2.1.11",
"react-dom": "^16.4.2",
"react-easy-chart": "^1.0.0",
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.5",
"redux": "^4.0.0"
"prop-types": "^15.6.2",
"react-router": "^4.3.1",
"recompose": "^0.30.0"
},
"scripts": {
"start": "react-scripts start",
-109
View File
@@ -1,109 +0,0 @@
import React, { Component } from 'react'
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { ApolloProvider } from 'react-apollo'
import { ApolloLink } from 'apollo-link'
import { HttpLink } from 'apollo-link-http'
import { onError } from 'apollo-link-error'
import { setContext } from 'apollo-link-context'
import { Route, BrowserRouter, Switch } from 'react-router-dom'
// Material UI
import { MuiThemeProvider } from '@material-ui/core/styles'
import theme from './theme'
// 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 Logout from './components/Logout'
import Post from './components/Post'
// import Footer from './components/Footer'
import Callback from './components/Callback'
import Auth from './auth/Auth'
import {
// NavBar,
Footer
} from './views'
// Apollo Client Setup
const httpLink = new HttpLink({ uri: 'http://localhost:4000/graphql', changeOrigin: true })
const errorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors) {
graphQLErrors.map(({ message, locations, path }) =>
console.log(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`,
),
)
}
if (networkError) console.log(`[Network error]: ${networkError}`)
})
const authLink = setContext((_, { headers }) => {
// get the authentication token from local storage if it exists
const token = localStorage.getItem('access_token')
// return the headers to the context so httpLink can read them
return {
headers: {
...headers,
Authorization: token ? `Bearer ${token}` : ``
}
}
})
export const client = new ApolloClient({
link: ApolloLink.from([errorLink, authLink, httpLink]),
cache: new InMemoryCache()
})
/*
export const client = new ApolloClient({
uri:'http://localhost:4000/graphql'
})
*/
export const auth = new Auth(result => console.log('auth result', result), client)
class App extends Component {
render () {
return (
<BrowserRouter>
<ApolloProvider client={client}>
<MuiThemeProvider theme={theme}>
<div className='App'>
<NavBar />
<Switch>
<Route exact path='/' component={Home} />
<Route path='/user' component={User} />
<Route path='/browse' component={Browse} />
<Route path='/search' component={Search} />
<Route path='/about' component={About} />
<Route path='/contact' component={Contact} />
<Route path='/logout' component={Logout} />
<Route path='/:post_id' component={Post} />
<Route path='/callback' render={(props) => {
auth.handleAuthentication(props)
return <Callback {...props} />
}} />
</Switch>
<Footer />
</div>
</MuiThemeProvider>
</ApolloProvider>
</BrowserRouter>
)
}
}
export default App
+2 -2
View File
@@ -188,10 +188,10 @@ class DescendentsTree extends Component {
if (data.loading) {
return (<div> Loading Descendents... </div>)
} else {
if (data.descendents === undefined) {
if (data.users_Descendents === undefined) {
return (<div> No Descendents to Display </div>)
} else {
return data.descendents.map(descendent => {
return data.users_Descendents.map(descendent => {
return (
<div key={descendent.alias}>
+1 -2
View File
@@ -1,7 +1,6 @@
import React, { Component } from 'react'
import { compose } from 'recompose'
import { withStyles } from '@material-ui/core/styles'
import {LineChart} from 'react-easy-chart'
import Grid from '@material-ui/core/Grid'
import Typography from '@material-ui/core/Typography'
import CssBaseline from '@material-ui/core/CssBaseline'
@@ -65,7 +64,7 @@ class Home extends Component {
color='textSecondary'
component='h3'
>
Welcome to Advanced Algos Users Module
Welcome to Advanced Algos Users Module This is the Source Version 2
</Typography>
</div>
</main>
-11
View File
@@ -15,12 +15,6 @@ import AboutIcon from '@material-ui/icons/FormatShapes'
import { Link } from 'react-router-dom'
// components
import LoggedInUser from './LoggedInUser'
// Images
import AALogo from '../assets/logos/advanced-algos/aa-logo-dark.svg'
const AboutLink = props => <Link to='/about' {...props} />
const ContactLink = props => <Link to='/contact' {...props} />
const SearchLink = props => <Link to='/search' {...props} />
@@ -68,10 +62,6 @@ class NavBar extends Component {
<div className={classes.root}>
<AppBar position='static'>
<Toolbar>
<img className={classes.img} src={AALogo} alt='Advanced Algos' />
<Typography variant='title' color='inherit' className={classes.flex}>
Users
</Typography>
<IconButton
className={classes.menuButton}
color='inherit'
@@ -107,7 +97,6 @@ class NavBar extends Component {
component={AboutLink}>
<AboutIcon />
</IconButton>
<LoggedInUser authId={this.state.authId} />
</Toolbar>
</AppBar>
</div>
+1 -1
View File
@@ -96,7 +96,7 @@ class ProfileSheet extends Component {
<MenuItem><em>Loading roles</em></MenuItem>
)
} else {
return data.roles.map(role => {
return data.users_Roles.map(role => {
return (
<MenuItem key={role.id} value={role.id}>{ role.name }</MenuItem>
)
+2 -1
View File
@@ -89,13 +89,14 @@ class UserList extends Component {
};
displayUsers(){
let data = this.props.getUsersQuery;
const { classes } = this.props;
if(data.loading){
return ( <div> Loading Users... </div>);
} else {
return data.users.map(user => {
return data.users_Users.map(user => {
return (
+2 -2
View File
@@ -156,10 +156,10 @@ class UserSearch extends Component {
if (data.loading) {
return (<div> Loading Users... </div>)
} else {
if (data.usersSearch === undefined) {
if (data.users_UsersSearch === undefined) {
return (<div> No Users to Display </div>)
} else {
return data.usersSearch.map(user => {
return data.users_UsersSearch.map(user => {
return (
<Grid key={user.id} item>
-1
View File
@@ -1 +0,0 @@
+38 -5
View File
@@ -1,6 +1,39 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import React, { Component } from 'react'
ReactDOM.render(<App />, document.getElementById('root'));
import { Route, BrowserRouter, Switch } from 'react-router-dom'
// Material UI
import { MuiThemeProvider } from '@material-ui/core/styles'
import theme from './theme'
// 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'
class App extends Component {
render () {
return (
<BrowserRouter basename={window.location.pathname}>
<MuiThemeProvider theme={theme}>
<NavBar />
<Switch>
<Route exact path='/' component={Home} />
<Route path='/user' component={User} />
<Route path='/browse' component={Browse} />
<Route path='/search' component={Search} />
<Route path='/about' component={About} />
<Route path='/contact' component={Contact} />
</Switch>
</MuiThemeProvider>
</BrowserRouter>
)
}
}
export default App
-36
View File
@@ -1,36 +0,0 @@
mutation {
addUser (alias: "aaa", firstName:"fff", lastName: "lll", roleId: "1", isTrader: 1, isDeveloper: 0) {
alias
isTrader
isDeveloper
}
}
mutation {
updateUser (
id: "5b8d152f6f4d5b3db44ee103" ,
alias: "luis",
firstName:"Luis",
lastName: "Molina",
isDeveloper: 1,
isTrader: 1,
isDataAnalyst: 1,
roleId: "2"
) {
alias
}
}
query {
users{
alias
firstName
isDeveloper
role{
id
name
}
}
}
+9 -9
View File
@@ -2,7 +2,7 @@ import gql from 'graphql-tag'
const getUsersQuery = gql`
{
users {
users_Users {
id
alias
firstName
@@ -18,7 +18,7 @@ const getUsersQuery = gql`
`
const getUserProfileQuery = gql`
query($id: ID){
user (id: $id){
users_User (id: $id){
id
alias
firstName
@@ -35,7 +35,7 @@ query($id: ID){
`
const getUserByAuthIdQuery = gql`
query($authId: String){
userByAuthId (authId: $authId){
users_UserByAuthId (authId: $authId){
id
referrerId
alias
@@ -63,7 +63,7 @@ query(
$middleName: String,
$lastName: String
){
usersSearch (alias: $alias, firstName: $firstName, middleName: $middleName, lastName: $lastName){
users_UsersSearch (alias: $alias, firstName: $firstName, middleName: $middleName, lastName: $lastName){
id
alias
firstName
@@ -76,7 +76,7 @@ const getDescendentsQuery = gql`
query(
$id: String
){
descendents (id: $id){
users_Descendents (id: $id){
id
alias
firstName
@@ -104,7 +104,7 @@ query(
`
const getRolesQuery = gql`
{
roles {
users_Roles {
id
name
}
@@ -123,7 +123,7 @@ mutation(
$roleId:String!
)
{
updateUser (
users_UpdateUser (
id: $id,
firstName:$firstName,
middleName: $middleName,
@@ -146,7 +146,7 @@ mutation(
$referrerId:String!
)
{
updateUserReferrer (
users_UpdateUserReferrer (
id: $id,
referrerId:$referrerId
)
@@ -163,7 +163,7 @@ mutation(
$avatarChangeDate:String
)
{
updateUserImages (
users_UpdateUserImages (
id: $id,
avatarHandle:$avatarHandle,
avatarChangeDate: $avatarChangeDate