Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
[#345] - shared dialog page for charts
  • Loading branch information
X-tina committed Nov 16, 2017
commit a6c24806cc8978aaa8da2ecb8bc5ff0306c0e983
33 changes: 33 additions & 0 deletions frontend/app/components/shared-dialogs/charts-dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import config from 'flaredown/config/environment';
import CryptoJS from 'cryptojs';
import Component from '@ember/component';
import { get, set, computed } from '@ember/object';

export default Component.extend({
classNames: ['flaredown-white-box', 'sharedChartsDialog'],

secretPhrase: config.encryptionSecret,
staticUrl: config.staticUrl,

encryptedUrl: computed('session.isAuthenticated', 'session.email', function() {
if(get(this, 'session.isAuthenticated')) {
const email = get(this, 'session.email');
const encryptedEmail = CryptoJS.AES.encrypt(email, get(this, 'secretPhrase'));

return `${get(this, 'staticUrl')}/charts/${encodeURIComponent(encryptedEmail)}`;
} else {
return '';
}
}),

actions: {
sendEmail() {
const encryptedUrl = encodeURIComponent(get(this, 'encryptedUrl'));
const currentUser = get(this, 'session.currentUser');
const screenName = currentUser ? get(currentUser, 'profile.screenName') : "";
const subject = `${screenName} would like to share their health charts with you`;

window.location.href = `mailto:?subject=${subject}&body=${encryptedUrl}`;
},
},
});
6 changes: 6 additions & 0 deletions frontend/app/routes/charts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import AuthenticatedRouteMixin from 'flaredown/mixins/authenticated-route-mixin';
import Route from '@ember/routing/route';
import { get } from '@ember/object';

export default Route.extend(AuthenticatedRouteMixin, {
});
6 changes: 6 additions & 0 deletions frontend/app/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,12 @@ input[type="submit"] {
// Sharing Charts
.sharedChartsBtn {
width: 100%;
background-color: $primary;

&:hover,
&:focus {
background-color: darken($primary, 10%);
}
}

.sharedChartsUrl {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<h3 class="centered">{{t "sharedCharts.dialog.title"}}</h3>

{{input type="submit" class="sharedChartsBtn" value=(t "sharedCharts.dialog.buttonText")}}
<button class="sharedChartsBtn" {{action "sendEmail"}}>
{{t "sharedCharts.dialog.buttonText"}}
</button>

<div class="sharedChartsUrl centered">
<label>{{t "sharedCharts.dialog.sharedUrl"}}</label>
{{input value=encryptedUrl}}
</div>
<div class="sharedChartsUrl centered">
<label>{{t "sharedCharts.dialog.sharedUrl"}}</label>
{{input value=encryptedUrl}}
</div>

<div class="sharedBottom centered">
{{#link-to 'chart'}}{{t "sharedCharts.dialog.done"}}{{/link-to}}
Expand Down