diff --git a/backend/server.js b/backend/server.js
index a7a0de8..a0b03a8 100644
--- a/backend/server.js
+++ b/backend/server.js
@@ -17,22 +17,27 @@ const imageRequest = require('./aws');
mongoose.connect('mongodb://localhost/ReelLecture',
{ useNewUrlParser: true, useUnifiedTopology: true });
-let student = 'student';
-let password = 'password';
-let s = new User({ username: 'sabhya@gmail.com', name: 'Sabhya', role: student });
-s.setPassword(password).then(() => s.save());
-let c = new User({ username: 'chris@gmail.com', name: 'Chris', role: 'instructor' });
-c.setPassword(password).then(() => c.save());
-let a = new User({ username: 'alex@gmail.com', name: 'Alex', role: 'instructor' });
-a.setPassword(password).then(() => a.save());
+// let student = 'student';
+// let password = 'password';
+// let s = new User({ username: 'sabhya@gmail.com', name: 'Sabhya', role: student });
+// s.setPassword(password).then(() => s.save());
-let am = new User({ username: 'amanda@gmail.com', name: 'Amanda', role: student });
-am.setPassword(password).then(() => am.save());
+// let c = new User({ username: 'chris@gmail.com', name: 'Chris', role: 'instructor' });
+// c.setPassword(password).then(() => c.save());
+
+// let a = new User({ username: 'alex@gmail.com', name: 'Alex', role: 'instructor' });
+// a.setPassword(password).then(() => a.save());
+
+// let am = new User({ username: 'amanda@gmail.com', name: 'Amanda', role: student });
+// am.setPassword(password).then(() => am.save());
+
+User.find({ }).exec((err, docs) => console.log(docs))
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.urlencoded({ extended: true }));
+app.use(bodyParser.json());
app.use(session({ secret: 'keyboard cat' }));
app.use(passport.initialize());
app.use(passport.session());
@@ -93,10 +98,10 @@ calcValues = (data, name) => {
apiRouter.post('/register', async (req, res) => {
let newUser = new User({
name: req.body.name,
- email: req.body.email,
- password: req.body.password,
+ username: req.body.email,
role: req.body.role
});
+ await newUser.setPassword(req.body.password);
let doc = await newUser.save();
res.send(doc);
});
diff --git a/frontend/src/component/analysis.js b/frontend/src/component/analysis.js
new file mode 100644
index 0000000..7635eba
--- /dev/null
+++ b/frontend/src/component/analysis.js
@@ -0,0 +1,25 @@
+import React from 'react';
+import { ListGroup, Badge } from 'react-bootstrap';
+import { PieChart } from 'react-minimal-pie-chart';
+import Nav from '../pages/nav';
+import LoadingPage from '../pages/LoadingPage';
+
+class Analysis extends React.Component {
+ render() {
+ let { data } = this.props;
+ if (data === null) return
+
+ let emotions = Object.keys(data);
+
+ return (
+
+ {emotions.map(el => {
+ if (Object.keys(data[el]).length !== 0)
+ return {el} {Object.values(data[el]).reduce((a,b) => a+b)}
+ })}
+
+ );
+ }
+}
+
+export default Analysis;
\ No newline at end of file
diff --git a/frontend/src/pages/Analysis.js b/frontend/src/pages/Analysis.js
index 6456ae4..bad8fbb 100644
--- a/frontend/src/pages/Analysis.js
+++ b/frontend/src/pages/Analysis.js
@@ -1,49 +1,29 @@
-import React from 'react';
-import { PieChart } from 'react-minimal-pie-chart';
-import LoadingPage from './LoadingPage';
-
-class Analysis extends React.Component {
- state = {
- analytics: null,
- redirect: false
- }
+import React from 'react';
+import {
+ Container
+} from 'react-bootstrap';
+import AnalysisComponent from '../component/analysis';
+import Nav from './nav';
+class AnalysisPage extends React.Component {
componentDidMount() {
fetch("/api/analytics")
.then(res => res.json())
.then(data => {
this.setState({ analytics: data })
})
- .catch(err => this.setState({ redirect: true }));
}
render() {
- let { analytics } = this.state;
- if (analytics === null) return
return (
-
-
-
{JSON.stringify(analytics)}
-
{analytics.eyesClosed}
-
{JSON.stringify(analytics).happy} :
-
- {/* analytics.forEach(element => {
-
- }) */}
-
- {/*
By Emotion */}
-
-
-
-
- )
+
+
+
+
+
+
+ );
}
}
-
-export default Analysis;
\ No newline at end of file
+
+export default AnalysisPage;
\ No newline at end of file
diff --git a/frontend/src/pages/Login.js b/frontend/src/pages/Login.js
index fec44fd..9d2006a 100644
--- a/frontend/src/pages/Login.js
+++ b/frontend/src/pages/Login.js
@@ -5,6 +5,7 @@ import {
Button,
Form
} from 'react-bootstrap';
+import Nav from './nav';
class Login extends React.Component {
state = {
@@ -22,26 +23,34 @@ class Login extends React.Component {
render() {
console.log(this.props.match)
return (
-
-
- {this.state.showDialog && (
-
- You must be logged in to access that page.
-
- )}
-
-
-
+
+
+
+
+ {this.state.showDialog && (
+
+ You must be logged in to access that page.
+
+ )}
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
);
}
}
diff --git a/frontend/src/pages/Register.js b/frontend/src/pages/Register.js
index ae30ca6..07e4492 100644
--- a/frontend/src/pages/Register.js
+++ b/frontend/src/pages/Register.js
@@ -1,5 +1,6 @@
import React from 'react';
-import Nav from './nav';
+import { Redirect } from 'react-router-dom';
+import Nav from './nav';
class Register extends React.Component {
@@ -9,8 +10,10 @@ class Register extends React.Component {
name: '',
email: '',
password: '',
- role: '',
+ role: 'student',
+ redirect: false
}
+ this.onSubmitSignIn = this.onSubmitSignIn.bind(this);
}
onNameChange = (event) => {
@@ -29,7 +32,7 @@ class Register extends React.Component {
this.setState({role: event.target.value})
}
- onSubmitSignIn = () => {
+ onSubmitSignIn() {
fetch('http://localhost:3000/api/register', {
method: 'post',
headers: {'Content-Type': 'application/json'},
@@ -42,15 +45,15 @@ class Register extends React.Component {
})
.then(response => response.json())
.then(user => {
- console.log(user)
- if (user.id) {
- this.props.loadUser(user)
- // this.props.onRouteChange('home');
+ if (user._id) {
+ this.setState({ redirect: true });
}
})
- }
+ }
render() {
+ if (this.state.redirect)
+ return
return (
@@ -76,29 +79,17 @@ class Register extends React.Component {
-
+
-
-
+
+
+
);
diff --git a/frontend/src/pages/User.js b/frontend/src/pages/User.js
index 3783533..d0e91df 100644
--- a/frontend/src/pages/User.js
+++ b/frontend/src/pages/User.js
@@ -14,7 +14,7 @@ function User() {
});
const [sessionName, setSessionName] = useState('');
-
+ console.log(userInfo)
useEffect(() => {
fetch('/api/user')
.then(res => res.json())
@@ -24,7 +24,7 @@ function User() {
}, []);
return (
- <>
+
Hello, {userInfo.name}!
@@ -43,7 +43,7 @@ function User() {
)
}
- >
+
)
}
diff --git a/frontend/src/pages/VideoChat.js b/frontend/src/pages/VideoChat.js
index a6593fe..edf4fb8 100644
--- a/frontend/src/pages/VideoChat.js
+++ b/frontend/src/pages/VideoChat.js
@@ -9,7 +9,7 @@ import Nav from './nav';
import { connect, createLocalTracks } from 'twilio-video';
import ws from 'ws';
import { ImageCapture } from 'image-capture';
-
+import Analysis from '../component/analysis';
class VideoChat extends React.Component {
constructor(props) {
@@ -127,7 +127,7 @@ class VideoChat extends React.Component {
connect(this.state.token, {
audio: 'true',
name: this.props.match.params.roomID,
- video: { width: 1080 }
+ video: { width: 1080 },
}).then(room => this.setState({ room: room }, () => {
room.on('participantConnected', this.createTracks);
room.on('participantDisconnected', this.createTracks);
@@ -239,7 +239,7 @@ class VideoChat extends React.Component {
{role === 'instructor' &&
Analytics
- {JSON.stringify(analytics)}
+
}
@@ -288,5 +288,3 @@ class VideoChat extends React.Component {
}
export default VideoChat;
-
-