Skip to content

Commit

Permalink
feat(sessions): implement session initialization ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
brionmario committed Apr 18, 2019
1 parent 4b90674 commit 7f18de8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const API_ENDPOINTS = {
getQuestionnaireInfo: `${BASE_API}/questionnaires/{}/`,
updateQuestionnaire: `${BASE_API}/questionnaires/{}/`,
createQuestionnaire: `${BASE_API}/questionnaires/`,
initializeSession: `${BASE_API}/sessions/`,
};

export { API_ENDPOINTS };
2 changes: 1 addition & 1 deletion src/routes/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const dashboard = [
path: '/new-session/emotions', hide: true, name: 'Expected Emotions', icon: testIcon, component: EmotionsView, restrictionLevel: 0,
},
{
path: '/evaluation', hide: true, name: 'Evaluation', icon: testIcon, component: EvaluationView, restrictionLevel: 0,
path: '/new-session/evaluation', hide: true, name: 'Evaluation', icon: testIcon, component: EvaluationView, restrictionLevel: 0,
},
{
redirect: true, path: '/', pathTo: '/dashboard', name: 'Dashboard', restrictionLevel: 0,
Expand Down
3 changes: 3 additions & 0 deletions src/services/gobal.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export function navigate(route, searchParams) {
if(route === 'emotions') {
path = '/new-session/emotions';
}
if(route === 'evaluation') {
path = '/new-session/evaluation';
}
history.push({
pathname: path,
search: searchParams
Expand Down
21 changes: 20 additions & 1 deletion src/views/sessions/emotions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ class Emotions extends Component {
}
}

componentWillReceiveProps(nextProps) {
const {actions, expectedEmotions} = this.props;
if (nextProps.expectedEmotions) {
if (!_.isEqual(expectedEmotions, nextProps.expectedEmotions)) {
actions.sessions.initializeSession(nextProps.sessionTemp);
}
}
if (nextProps.isSessionInitialized) {
if (nextProps.currentSession && nextProps.currentSession.id) {
const searchParams = '?session_id=' + nextProps.currentSession.id;
navigate('evaluation', searchParams);
}
}
}

handleEmotionSelect = emotion => {
const { emotions, selectedEmotions } = this.state;
// clone object to avoid mutating
Expand Down Expand Up @@ -201,7 +216,7 @@ class Emotions extends Component {
type="submit"
bsStyle="primary"
disabled={selectedEmotions.length < 1}
bsSize="sm"
bsSize="md"
wd
fill
onClick={this.handleEmotionSubmit}
Expand All @@ -228,7 +243,11 @@ Emotions.propTypes = {
function mapStateToProps(state) {
return {
selectedQuestionnaire: state.sessions.selectedQuestionnaire,
currentSession: state.sessions.currentSession,
sessionTemp: state.sessions.sessionTemp,
isSessionInitialized: state.sessions.isSessionInitialized,
selectedApplication: state.sessions.selectedApplication,
expectedEmotions: state.sessions.expectedEmotions,
viewConfig: state.sessions.sessionViewConfig
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/sessions/evaluation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Evaluation extends Component {
<img src={'data:image/jpg;base64,' + rawPhoneFeedWSData}/>
:
<EmptyPlaceholder title={'Mobile Phone Feed'} subTitle={'Phone feed is not connected'}
extraContext={'Please enter the websocket address bellow. ex: http://192.168.8.103:8123'}
extraContext={'Please enter the URL to obtain websocket connection address. ex: http://192.168.8.103:8123'}
icon={phoneIcon}/>
}
</div>
Expand Down Expand Up @@ -195,8 +195,8 @@ class Evaluation extends Component {
<Row>
<Col md={12}>
<div className="text-center mt-2">
<Button type="submit" bsStyle="primary" bsSize="sm" wd fill>
Select
<Button type="submit" bsStyle="primary" bsSize="lg" disabled={!(isRawPhoneFeedWSConnected && isCameraConnected) } fillSecondary fill>
Start Session
</Button>
</div>
</Col>
Expand Down

0 comments on commit 7f18de8

Please sign in to comment.