Skip to content

Commit

Permalink
Merge pull request ThePersonaProject#170 from davidinoa/dashboard
Browse files Browse the repository at this point in the history
Dashboard
  • Loading branch information
PattyKovash authored Feb 20, 2018
2 parents 5331ac7 + ea84ae9 commit 35cf33f
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 63 deletions.
2 changes: 1 addition & 1 deletion client/components/barLang.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular
.module('app')
.controller('barLangCtrl', function($scope) {
.controller('barLangCtrl', function ($scope) {
$scope.labels = ['Analytical', 'Confident', 'Tentative'];

$scope.series = ['Language'];
Expand Down
9 changes: 4 additions & 5 deletions client/components/line.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
angular
.module('app')
.controller('lineCtrl', function($scope) {
.controller('lineCtrl', function ($scope) {

$scope.labels = ['1', '2', '3', '4', '5'];
// $scope.onClick = function (points, evt) {
// console.log(points, evt);
// };

$scope.series = ['Analytical', 'Confident', 'Tentative'];

$scope.data = [
Expand Down Expand Up @@ -40,7 +39,7 @@ angular
}
}
};

if ($scope.$ctrl.output) {
for (let i = 0; i < $scope.labels.length; i += 1) {
for (let k = 0; k < $scope.$ctrl.output.length; k += 1) {
Expand Down
9 changes: 3 additions & 6 deletions client/components/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ angular.module('app')
this.interviewTones = watsonService.interviewAnalysis;
this.interviewFillers = watsonService.interviewFillers;

//Analysis per question
// Analysis per question
this.questions = interviewService.prompts;
this.answers = this.watsonService.responses;

this.tones = this.watsonService.answerAnalysis;
this.fillers = this.watsonService.answerFillers;


//Arrange analysis into object per question
// Arrange analysis into object per question
this.arranged = [];
console.log('preloop:', this.arranged)

Expand All @@ -37,25 +37,22 @@ angular.module('app')
}
};
this.arrangeAnswers();
console.log(this.arranged);

//Arrange overall interview analysis into one object
// Arrange overall interview analysis into one object
this.overall = [];
this.arrangeOverall = () => {
const output = {};
if (this.interviewTones[0].tone_categories) {
output.tones = this.interviewTones[0].tone_categories[0].tones;
output.language = this.interviewTones[0].tone_categories[1].tones;
output.social = this.interviewTones[0].tone_categories[2].tones;

}
output.fillers = this.interviewFillers[0];
output.overall = true;
this.overall.push(output);
};
this.arrangeOverall();

console.log(this.overall);
this.resultsLoaded = true;
$scope.$apply();
});
Expand Down
103 changes: 64 additions & 39 deletions client/components/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
angular
.module('app')
.controller('userCtrl', function($location, userService, interviewService, $scope) {
.controller('userCtrl', function ($location, userService, interviewService, $scope) {
this.userService = userService;
this.isLoggedIn = this.userService.isLoggedIn;
this.userData = this.userService.userData;
Expand All @@ -15,6 +15,14 @@ angular
this.interviewService.getInterviews(this.userData.id)
.then(({ data }) => {
this.interviews = data;
this.getOverallLanguage();
this.getOverallTone();
this.getOverallPersonality();
this.historyGraphData = this.interviews.map(interview => (
interview.overallTones.tone_categories[1].tones
));
this.dataLoaded = true;
console.log(this.historyGraphData);
console.log('USER INTERVIEWS IN CLIENT: ', this.interviews);
});
};
Expand Down Expand Up @@ -46,46 +54,63 @@ angular
});
};

this.analysis = [
{
language: [
{ score: 0.920175, tone_id: 'analytical', tone_name: 'Analytical' },
{ score: 0.85, tone_id: 'confident', tone_name: 'Confident' },
{ score: 0.462727, tone_id: 'tentative', tone_name: 'Tentative' }
],
social: [
{ score: 0.746622, tone_id: 'openness_big5', tone_name: 'Openness' },
{
score: 0.357534,
tone_id: 'conscientiousness_big5',
tone_name: 'Conscientiousness'
},
{
score: 0.627449,
tone_id: 'extraversion_big5',
tone_name: 'Extraversion'
},
{
score: 0.889633,
tone_id: 'agreeableness_big5',
tone_name: 'Agreeableness'
},
{
score: 0.596624,
tone_id: 'emotional_range_big5',
tone_name: 'Emotional Range'
this.getOverallTone = () => {
this.overallTone = this.interviews
.map(interview => (
interview.overallTones.tone_categories[0].tones
))
.reduce((output, interview) => {
for (let i = 0; i < interview.length; i += 1) {
const averageScore = (output[i].score + interview[i].score) / 2 || interview[i].score;
output[i].score = averageScore;
}
],
return output;
}, [
{ tone_id: 'anger', tone_name: 'Anger' },
{ tone_id: 'disgust', tone_name: 'Disgust' },
{ tone_id: 'fear', tone_name: 'Fear' },
{ tone_id: 'joy', tone_name: 'Joy' },
{ tone_id: 'sadness', tone_name: 'Sadness' }
]);
};

tones: [
{ score: 0.081541, tone_id: 'anger', tone_name: 'Anger' },
{ score: 0.0168, tone_id: 'disgust', tone_name: 'Disgust' },
{ score: 0.334638, tone_id: 'fear', tone_name: 'Fear' },
{ score: 0.740808, tone_id: 'joy', tone_name: 'Joy' },
{ score: 0.1278, tone_id: 'sadness', tone_name: 'Sadness' }
]
}
];
this.getOverallLanguage = () => {
this.overallLanguage = this.interviews
.map(interview => (
interview.overallTones.tone_categories[1].tones
))
.reduce((output, interview) => {
for (let i = 0; i < interview.length; i += 1) {
const averageScore = (output[i].score + interview[i].score) / 2 || interview[i].score;
output[i].score = averageScore;
}
return output;
}, [
{ tone_id: 'analytical', tone_name: 'Analytical' },
{ tone_id: 'confident', tone_name: 'Confident' },
{ tone_id: 'tentative', tone_name: 'Tentative' }
]);
};

this.getOverallPersonality = () => {
this.overallPersonality = this.interviews
.map(interview => (
interview.overallTones.tone_categories[1].tones
))
.reduce((output, interview) => {
for (let i = 0; i < interview.length; i += 1) {
const averageScore = (output[i].score + interview[i].score) / 2 || interview[i].score;
output[i].score = averageScore;
}
return output;
}, [
{ tone_id: 'openness_big5', tone_name: 'Openness' },
{ tone_id: 'conscientiousness_big5', tone_name: 'Conscientiousness' },
{ tone_id: 'extraversion_big5', tone_name: 'Extraversion' },
{ tone_id: 'agreeableness_big5', tone_name: 'Agreeableness' },
{ tone_id: 'emotional_range_big5', tone_name: 'Emotional Range' }
]);
};

this.refreshInterviews = (e) => {
this.removeActiveSub(e);
Expand Down
Binary file added client/images/interviewBackground.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/images/interviewBackground2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion client/services/interviewService.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ angular.module('app')
this.getPrompts = () => this.prompts;

this.getNextPrompt = () => {
console.log('here are the prompts:', this.prompts);
this.currentPromptsIndex = this.currentPromptsIndex + 1;
broadcastService.send('update', this.currentPromptsIndex);
};
Expand Down
2 changes: 0 additions & 2 deletions client/services/recordingService.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ angular.module('app')
this.recording = [];

this.startRecording = () => {
console.log('recording started');
broadcastService.send('recording');
};

this.submitRecording = () => {
console.log('recording submitted');
broadcastService.send('submit');
};
});
16 changes: 9 additions & 7 deletions client/templates/userDashboard.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<div id="dashboard" class="nine wide column" style="height: auto">
<h2 class="Language Analysis History" style="text-align: center"> Interview History - Past 5 Interviews</h2>
<div ng-if="$ctrl.dataLoaded" id="dashboard" class="nine wide column" style="height: auto">
<h2 class="Language Analysis History" style="text-align: center">
Interview History - Past 5 Interviews
</h2>
<div>
<line></line>
<line output="$ctrl.historyGraphData"></line>
</div>
</div>
<div class="ui three column stackable row">
<div ng-if="$ctrl.dataLoaded"class="ui three column stackable row">
<div class="column">
<div class="columnContainer">
<h3 class="ui header">Overall Language Analysis</h3>
<barlang output="$ctrl.analysis[0].language"></barlang>
<barlang output="$ctrl.overallLanguage"></barlang>
</div>
</div>
<div class="column">
<h3 class="ui header">Overall Tone Analysis</h3>
<bar output="$ctrl.analysis[0].tones"></bar>
<bar output="$ctrl.overallTone"></bar>
</div>
<div class="column">
<h3 class="ui header">Overall Personality Analysis</h3>
<radar output="$ctrl.analysis[0].social"></radar>
<radar output="$ctrl.overallPersonality"></radar>
</div>
</div>
4 changes: 2 additions & 2 deletions server/passport/authRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function (app, passport) {
// FACEBOOK STRATEGY

passport.use(new FacebookStrategy({ // travis is getting it from the .travis.yml so it's probably looking for it in there
clientID: '797346707115664',
clientID: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
callbackURL: 'http://localhost:3000/auth/facebook/callback',
profileFields: ['id', 'displayName', 'photos', 'email']
Expand Down Expand Up @@ -64,7 +64,7 @@ module.exports = function (app, passport) {
// GOOGLE STRATEGY

passport.use(new GoogleStrategy({
clientID: '544526537829-bgsghiocur95tm6br5smpf0t8uh5tkef.apps.googleusercontent.com',
clientID: process.env.googleID,
clientSecret: process.env.googleSECRET,
callbackURL: 'http://localhost:3000/auth/google/callback'
},
Expand Down

0 comments on commit 35cf33f

Please sign in to comment.