Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactors answers codes to parse user data from jwt token. Moves pars… #274

Merged
merged 52 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ed8e993
Add share button svg, add react-collapse
christianlomboy Apr 16, 2020
fa27c2f
Merge branch 'small-icon-redesign' into social-menu
christianlomboy Apr 17, 2020
1073f3f
Merge remote-tracking branch 'upstream/master' into social-menu
christianlomboy Apr 17, 2020
824a49c
Animate share menu expand and button color, cleanup TODOs
christianlomboy Apr 18, 2020
5990672
Fix QuestionCard box-shadow in CSS color function
christianlomboy Apr 18, 2020
6caa54f
Merge remote-tracking branch 'origin/master' into social-menu
christianlomboy Apr 18, 2020
3df3c6e
Modify social menu animation to expand upwards, add animated social i…
christianlomboy Apr 19, 2020
fb2fd28
Implement Twitter button
christianlomboy Apr 19, 2020
38c4719
Merge pull request #164 from nthopinion/integration/webapp
raynman1 Apr 20, 2020
015c44f
Merge pull request #166 from nthopinion/integration/webapp
sethuraj Apr 20, 2020
41edf1a
Merge pull request #170 from nthopinion/production-release
raynman1 Apr 20, 2020
07df3ae
Update navLink.json
raynman1 Apr 20, 2020
5c502bb
Update navLink.json
raynman1 Apr 20, 2020
6f977ff
Update navLink.json
raynman1 Apr 20, 2020
882d962
Merge pull request #171 from nthopinion/raynman1-patch-1
raynman1 Apr 20, 2020
69208c0
Merge pull request #172 from nthopinion/integration/webapp
raynman1 Apr 20, 2020
983db74
Merge pull request #173 from nthopinion/production-release
raynman1 Apr 20, 2020
5260a08
Add Facebook SDK, fix button color
christianlomboy Apr 20, 2020
9dc6a36
Merge remote-tracking branch 'upstream/master' into social-menu
christianlomboy Apr 20, 2020
77584bd
Comment out Facebook code for now, fix CSS
christianlomboy Apr 20, 2020
79dac25
Fix mobile styling
christianlomboy Apr 20, 2020
995229a
Merge pull request #179 from christianlomboy/social-menu
raynman1 Apr 21, 2020
f99f1c0
Merge pull request #181 from nthopinion/integration/webapp
raynman1 Apr 21, 2020
83de058
Create CODE_OF_CONDUCT.md
nnation Apr 21, 2020
6e8a18c
Merge remote-tracking branch 'upstream/master'
christianlomboy Apr 21, 2020
2a4f0c7
Merge branch 'social-menu'
christianlomboy Apr 21, 2020
2ea48e4
Add Televideo button to patient facing board, fix mobile styling
christianlomboy Apr 21, 2020
ce64670
Merge pull request #183 from christianlomboy/televideo-icon-button
raynman1 Apr 23, 2020
ee30405
Update televideo outbound link
raynman1 Apr 25, 2020
1788b7e
Merge branches 'integration/webapp' and 'develop/refactorQnA' of gith…
aviskarkc10 Apr 25, 2020
406a87b
Merge pull request #239 from nthopinion/integration/webapp
sethuraj Apr 26, 2020
ebac419
Merge pull request #240 from nthopinion/production-release
sethuraj Apr 27, 2020
78cdba4
Update TelevideoButton.js
raynman1 Apr 28, 2020
d15d535
Merge pull request #244 from nthopinion/develop/refactorQnA
sethuraj Apr 28, 2020
f4c5164
Merge pull request #245 from nthopinion/integration/webapp
sethuraj Apr 28, 2020
167a2aa
Merge pull request #246 from nthopinion/production-release
sethuraj Apr 28, 2020
4c9ebc0
Merge pull request #248 from nthopinion/develop/refactorQnA
sethuraj Apr 28, 2020
20a299b
Merge pull request #249 from nthopinion/integration/webapp
sethuraj Apr 28, 2020
969a676
Merge pull request #251 from nthopinion/develop/refactorQnA
sethuraj Apr 28, 2020
0ad249b
Merge pull request #252 from nthopinion/integration/webapp
sethuraj Apr 28, 2020
38af035
Merge pull request #255 from nthopinion/develop/refactorQnA
sethuraj Apr 30, 2020
1aacbcb
Merge pull request #256 from nthopinion/integration/webapp
sethuraj Apr 30, 2020
cf5bdf1
Merge pull request #258 from nthopinion/develop/refactorQnA
sethuraj Apr 30, 2020
248d88a
Merge pull request #259 from nthopinion/integration/webapp
sethuraj Apr 30, 2020
5196eca
Merge pull request #260 from nthopinion/production-release
sethuraj Apr 30, 2020
686b844
Merge pull request #262 from nthopinion/develop/refactorQnA
sethuraj Apr 30, 2020
be3ab4c
Merge pull request #263 from nthopinion/integration/webapp
sethuraj Apr 30, 2020
d454a61
Merge pull request #266 from nthopinion/develop/refactorQnA
sethuraj May 1, 2020
301b236
Merge pull request #268 from nthopinion/production-release
sethuraj May 1, 2020
95b0907
Merge pull request #267 from nthopinion/integration/webapp
sethuraj May 1, 2020
3873924
Merge pull request #269 from nthopinion/production-release
sethuraj May 1, 2020
e048a0b
refactors answers codes to parse user data from jwt token. Moves pars…
qckpckt May 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team on [Slack](https://join.slack.com/t/hackingcovid19/shared_invite/zt-cs0oy49c-bwn5uoilSme1iqFDDK7~zg "Hacking Covid19"). The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
12 changes: 12 additions & 0 deletions api/routes/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const jose = require('jose');

export const parseToken = (jwtToken) => {
const item = jose.JWT.decode(jwtToken);
const user = new User();
user.profilestatus = "level 0";
user.fullname = item.given_name + " " + item.family_name;
user.b2cid = item.sub;
user.lastsignintime = item.auth_time;
user.email = item.emails[0];
Comment on lines +6 to +10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to use camelCase variable naming. Will make our code consistent

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aviskarkc10 The class variables for the class user is matched with how the fields in the NoSQL container. CosmosDB is case sensitive. In C# we can map the class variable to database field , not sure how it is in node.js, so kept exactly the same. That is my code. We can discuss more in slack. Thanks

return user;
};
41 changes: 20 additions & 21 deletions api/routes/questionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ const getUrls = require('get-urls');

const QuestionDao = require('../models/questionDao')


import { parseToken } from './common';
import { answerContainerId } from '../config';

/**
* @swagger
* definitions:
Expand Down Expand Up @@ -314,6 +318,12 @@ class PostList {
let sources = [];
let youtubeLinks = [];
let answer = req.body;
let userData = parseToken(answer.jwt);

const userDetails = {
id: userData.id,
name: userData.anonymous ? userData.fullname : null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't name be null when anonymous is true? I am thinking this should be reversed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aviskarkc10 If anonymous, we should call it "Anonymous". I am going to merge this code from Alex to test and test. Thanks Jay

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be reversed. I will make this change.
const userDetails = {
id: userData.id,
name: userData.anonymous ? "Dr. Anonymous" : userData.fullname
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this should be reversed. Sorry!

}

const urls = getUrls(answer.text);

Expand All @@ -332,22 +342,19 @@ class PostList {

return {
...answer,
userDetails,
country: userData.country,
sources,
youtubeLinks
};
}

async addAnswer (req, res) {
const answer = this.parseAnswer(req)
var firstAnsweredBy = {}, lastAnsweredBy = {};
firstAnsweredBy.name = "Nth Opinion"
firstAnsweredBy.loginId = "e060f24a-bd81-4d65-877f-857f31f2cf31"
lastAnsweredBy.name = "Nth Opinion"
lastAnsweredBy.loginId = "e060f24a-bd81-4d65-877f-857f31f2cf31"
answer["firstAnsweredBy"] = firstAnsweredBy;
answer["lastAnsweredBy"] = lastAnsweredBy;
var date = new Date();
var timestamp = Math.floor(date.getTime()/1000.0);
answer["firstAnsweredBy"] = answer.userDetails;
answer["lastAnsweredBy"] = answer.userDetails;
let date = new Date();
let timestamp = Math.floor(date.getTime()/1000.0);
answer.firstAnsweredOn = timestamp;
answer.lastAnsweredOn = timestamp;
await this.questionDao.addAnswer(answer)
Expand All @@ -356,20 +363,12 @@ class PostList {

async editAnswer (req, res) {
const answer = this.parseAnswer(req)
if (answer.lastAnsweredBy === undefined)
{
var lastAnsweredBy = {};
lastAnsweredBy.name = "Nth Opinion"
lastAnsweredBy.loginId = "e060f24a-bd81-4d65-877f-857f31f2cf31"
answer["lastAnsweredBy"] = lastAnsweredBy;
}
else
if (answer.lastAnsweredBy === undefined || answer.lastAnsweredBy != answer.userDetails.name)
{
answer.lastAnsweredBy.name = "Nth Opinion"
answer.lastAnsweredBy.loginId = "e060f24a-bd81-4d65-877f-857f31f2cf31"
answer.lastAnsweredBy = answer.userDetails;
}
var date = new Date();
var timestamp = Math.floor(date.getTime()/1000.0);
let date = new Date();
let timestamp = Math.floor(date.getTime()/1000.0);
answer.lastAnsweredOn = timestamp;
await this.questionDao.editAnswer(answer)
res.send('ok')
Expand Down
19 changes: 4 additions & 15 deletions api/routes/userList.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const Pusher = require('pusher');
const getUrls = require('get-urls');
const jose = require('jose');

const UserDao = require('../models/questionDao')

import { parseToken } from './common';

const config = require('../config')

class User{
Expand Down Expand Up @@ -73,7 +74,7 @@ class UserList{

async validateUser (req, res) {
const jwtToken = req.body;
const user = this.parsetoken(jwtToken.jwt);
const user = parseToken(jwtToken.jwt);
const verifiedUser = await this.userDao.getUser(user.email);
user.profilestatus = "level 0"; //initializing the access
if (verifiedUser !== undefined)
Expand All @@ -91,18 +92,6 @@ class UserList{
res.send(user);
}

parsetoken(jwtToken)
{
const item = jose.JWT.decode(jwtToken);
const user = new User();
user.profilestatus = "level 0";
user.fullname = item.given_name + " " + item.family_name;
user.b2cid = item.sub;
user.lastsignintime = item.auth_time;
user.email = item.emails[0];
return user;
}

async addUser (req, res) {
// console.log('req' + JSON.stringify(req.body))
const item = req.body;
Expand Down Expand Up @@ -137,4 +126,4 @@ class UserList{
}

}
module.exports = UserList;
module.exports = UserList;
4 changes: 2 additions & 2 deletions client/public/locales/en/navLink.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"getInvolved": "GET INVOLVED",
"partners": "PARTNERS",
"contactUs": "DISCLAIMER",
"language": "LANGUAGE"
"televideo": "TELEVIDEO"
"language": "LANGUAGE",
"teleVideo": "TELEVIDEO"
}
8 changes: 3 additions & 5 deletions client/src/actions/question.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
NEW_QUESTION_ANSWERED,
DELETE_ANSWERED_QUESTION_SUCCESS,
DELETE_UNANSWERED_QUESTION_SUCCESS,
CHANGE_LANGUAGE,
} from '../constants/ActionTypes';

import config from '../config';
Expand Down Expand Up @@ -136,14 +135,14 @@ export const handleNewQuestionAnswered = (question) => (dispatch) => {
};

export const changeLanguage = (selectLanguage) => {
let lang = selectLanguage;
const lang = selectLanguage;
return (dispatch) => {
return fetch(`${config.domainURL}/api/changeLanguage`,{
return fetch(`${config.domainURL}/api/changeLanguage`, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'language': lang,
language: lang,
},
body: JSON.stringify({ language: lang }),
})
Expand Down Expand Up @@ -279,4 +278,3 @@ export const handleAnswerLike = (questionId, answerId) => {
});
};
};

2 changes: 1 addition & 1 deletion client/src/components/FlagButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class FlagButton extends React.Component {
ref={(e) => {
this.itemToChangeColor = e;
}}
className={this.state.selected ? 'flag-button-clicked' : ''}
className={this.state.selected ? 'flag-button-clicked' : 'button'}
viewBox="0 0 15 13"
width="15"
xmlns="http://www.w3.org/2000/svg"
Expand Down
9 changes: 3 additions & 6 deletions client/src/components/LikeButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ class LikeButton extends React.Component {
ref={(e) => {
this.itemToChangeColor = e;
}}
className={
this.state.changeColor ? 'like-button-clicked' : 'like-button'
}
className={this.state.changeColor ? 'like-button-clicked' : 'button'}
viewBox="0 0 15 13"
width="15"
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -54,14 +52,13 @@ class LikeButton extends React.Component {
</g>
</svg>
<div
className={
this.state.changeColor ? 'like-button-clicked' : 'like-button'
}
className={this.state.changeColor ? 'like-button-clicked' : 'button'}
style={{ marginLeft: '0.5em' }}
ref={(e) => {
this.itemToChangeColor = e;
}}
>
{/* TODO animate the text when it changes */}
{this.props.likes}
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/PhysicianView.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class PhysicianView extends Component {
<a
href="https://ai-passion.appspot.com/"
target="_blank"
class="active item"
rel="noopener noreferrer"
className="active item"
>
Televideo
</a>
Expand Down
36 changes: 36 additions & 0 deletions client/src/components/TelevideoButton.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions client/src/containers/PatientBoard.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class PatientBoard extends Component {
this.props.searchQuestions(this.props.questions, this.props.searchTerm);
}, 500);

/* // submit question
/* // submit question
if (this.props.results.length !== 0) return;
// var self = this
if (
Expand All @@ -106,13 +106,13 @@ class PatientBoard extends Component {
this.handleSubmitNewQuestion();
}, 1000);
}
*/
*/
};

handleSubmitNewQuestion = () => {
this.props.postQuestion(this.props.searchTerm);

this.setState({ prevSearchTerm: this.props.searchTerm });
// this.setState({ prevSearchTerm: this.props.searchTerm });
// dispatch(resetSearchResult());
// dispatch(searchQuestions(this.props.questions, this.props.searchTerm))
};
Expand Down Expand Up @@ -192,9 +192,7 @@ class PatientBoard extends Component {
</div>
<div className="board-link">
<Link to="/bIiOOIIqgwEXwUU3SaD0F9">
{this.props.t(
'patientBoard:addQuestion.areyouphysician'
)}
{this.props.t('patientBoard:addQuestion.areyouphysician')}
</Link>
</div>
</div>
Expand Down
Loading