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

345 sharing old charts #648

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions frontend/app/components/health-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const {
} = Ember;

export default Component.extend(CheckinByDate, {
patternsVisible: true,
chartVisible: false,
patternsVisible: false,
chartVisible: true,
journalIsVisible: alias('chartJournalSwitcher.journalIsVisible'),
chartJournalSwitcher: service(),
i18n: service(),
Expand Down
4 changes: 0 additions & 4 deletions frontend/app/components/pattern/index-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,5 @@ export default Component.extend({

setProperties(this, { startAt: startAt, endAt: endAt });
},

sharePattern() {
this.transitionTo('patterns');
},
}
});
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}`;
},
},
});
15 changes: 14 additions & 1 deletion frontend/app/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ export default {
},

history: {
charts: {
shareButtonText: 'Share Charts',
},

step: {
initial: {
title: 'History',
Expand All @@ -100,7 +104,7 @@ export default {
},
index: {
newPatternText: '+ Create new pattern',
sharePatternText: 'Share Patterns',
shareButtonText: 'Share Patterns',
}
}
},
Expand All @@ -114,4 +118,13 @@ export default {
loadMore: 'Load more...',
},
},

sharedCharts: {
dialog: {
title: 'You will share all visible Charts',
buttonText: 'Share via Email',
sharedUrl: 'Or copy this link to share anywhere',
done: 'Done',
}
},
};
4 changes: 4 additions & 0 deletions frontend/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Router.map(function() {
this.route('signup');
this.route('chart');

this.route('charts', function() {
this.route('shared', { path: '/:friendly_id' });
});

this.route('patterns', function() {
this.route('shared', { path: '/:friendly_id' });
});
Expand Down
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, {
});
17 changes: 16 additions & 1 deletion frontend/app/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ input[type="submit"] {
}
}

.sharePatternLink {
.shareHistoryBtn {
display: flex;
justify-content: center;
margin-bottom: 10px;
Expand Down Expand Up @@ -579,3 +579,18 @@ input[type="submit"] {
margin-top: 0.5em;
}

// Sharing Charts
.sharedChartsBtn {
width: 100%;
background-color: $primary;

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

.sharedChartsUrl {
margin-top: 20px;
}

1 change: 1 addition & 0 deletions frontend/app/templates/charts/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{shared-dialogs/charts-dialog}}
10 changes: 10 additions & 0 deletions frontend/app/templates/components/health-chart.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{{#if authorPage}}
<div class="shareHistoryBtn">
{{#link-to 'charts' class="history-index-btn btn"}}
{{t "history.step.index.shareButtonText"}}
{{/link-to}}
</div>
{{else}}
<h3 class="centered">{{authorName}}'s Health History</h3>
{{/if}}

{{#if chartLoaded }}
<svg width='100%' height={{SVGHeight}}>
<g class="health-chart-viewport" transform="translate(0, {{seriePadding}})">
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/templates/components/health-dashboard.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="btn-group vert-offset-top-1 vert-offset-bottom-1">
<button {{action "showPatterns"}} class={{ if (or journalIsVisible chartVisible) "" "active" }}>Patterns</button>
<button {{action "showChart"}} class={{if (or journalIsVisible patternsVisible) "" "active"}}>Charts</button>
<button {{action "showPatterns"}} class={{if (or journalIsVisible chartVisible) "" "active" }}>Patterns</button>
<button {{action "showJournal"}} class={{if (or chartVisible patternsVisible) "" "active"}}>Journal</button>
</div>

{{#if journalIsVisible}}
{{journal-list}}
{{else if chartVisible}}
{{health-chart onDateClicked=(action "routeToCheckin")}}
{{health-chart onDateClicked=(action "routeToCheckin") authorPage=true}}
{{else}}
{{chart-patterns}}
{{/if}}
4 changes: 2 additions & 2 deletions frontend/app/templates/components/pattern/index-step.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{#if authorPage}}
<div class="sharePatternLink">
<div class="shareHistoryBtn">
{{#link-to 'patterns' class="history-index-btn btn"}}
Share Patterns
{{t "history.step.index.shareButtonText"}}
{{/link-to}}
</div>
{{else}}
Expand Down
14 changes: 14 additions & 0 deletions frontend/app/templates/components/shared-dialogs/charts-dialog.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<h3 class="centered">{{t "sharedCharts.dialog.title"}}</h3>

<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="sharedBottom centered">
{{#link-to 'chart'}}{{t "sharedCharts.dialog.done"}}{{/link-to}}
</div>
2 changes: 1 addition & 1 deletion frontend/app/templates/patterns/index.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{shared-patterns/dialog patterns=model}}
{{shared-dialogs/patterns-dialog patterns=model}}