diff --git a/frontend/app/components/health-dashboard.js b/frontend/app/components/health-dashboard.js index 0f636ed4b..39308760c 100644 --- a/frontend/app/components/health-dashboard.js +++ b/frontend/app/components/health-dashboard.js @@ -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(), diff --git a/frontend/app/components/pattern/index-step.js b/frontend/app/components/pattern/index-step.js index 1756bbfca..2d273566e 100644 --- a/frontend/app/components/pattern/index-step.js +++ b/frontend/app/components/pattern/index-step.js @@ -142,9 +142,5 @@ export default Component.extend({ setProperties(this, { startAt: startAt, endAt: endAt }); }, - - sharePattern() { - this.transitionTo('patterns'); - }, } }); diff --git a/frontend/app/components/shared-dialogs/charts-dialog.js b/frontend/app/components/shared-dialogs/charts-dialog.js new file mode 100644 index 000000000..384a48830 --- /dev/null +++ b/frontend/app/components/shared-dialogs/charts-dialog.js @@ -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}`; + }, + }, +}); diff --git a/frontend/app/components/shared-patterns/dialog.js b/frontend/app/components/shared-dialogs/patterns-dialog.js similarity index 100% rename from frontend/app/components/shared-patterns/dialog.js rename to frontend/app/components/shared-dialogs/patterns-dialog.js diff --git a/frontend/app/locales/en/translations.js b/frontend/app/locales/en/translations.js index 40e6ceea8..5eff65096 100644 --- a/frontend/app/locales/en/translations.js +++ b/frontend/app/locales/en/translations.js @@ -81,6 +81,10 @@ export default { }, history: { + charts: { + shareButtonText: 'Share Charts', + }, + step: { initial: { title: 'History', @@ -100,7 +104,7 @@ export default { }, index: { newPatternText: '+ Create new pattern', - sharePatternText: 'Share Patterns', + shareButtonText: 'Share Patterns', } } }, @@ -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', + } + }, }; diff --git a/frontend/app/router.js b/frontend/app/router.js index 5b50c12f7..7bcc2511d 100644 --- a/frontend/app/router.js +++ b/frontend/app/router.js @@ -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' }); }); diff --git a/frontend/app/routes/charts/index.js b/frontend/app/routes/charts/index.js new file mode 100644 index 000000000..4b5417d84 --- /dev/null +++ b/frontend/app/routes/charts/index.js @@ -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, { +}); diff --git a/frontend/app/styles/global.scss b/frontend/app/styles/global.scss index 4a9c8fc48..50aa0ebd5 100644 --- a/frontend/app/styles/global.scss +++ b/frontend/app/styles/global.scss @@ -512,7 +512,7 @@ input[type="submit"] { } } -.sharePatternLink { +.shareHistoryBtn { display: flex; justify-content: center; margin-bottom: 10px; @@ -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; +} + diff --git a/frontend/app/templates/charts/index.hbs b/frontend/app/templates/charts/index.hbs new file mode 100644 index 000000000..1a631596f --- /dev/null +++ b/frontend/app/templates/charts/index.hbs @@ -0,0 +1 @@ +{{shared-dialogs/charts-dialog}} diff --git a/frontend/app/templates/components/health-chart.hbs b/frontend/app/templates/components/health-chart.hbs index 7b391d478..7c1f062b3 100644 --- a/frontend/app/templates/components/health-chart.hbs +++ b/frontend/app/templates/components/health-chart.hbs @@ -1,3 +1,13 @@ +{{#if authorPage}} +
+{{else}} +