From 183ac8fa2b976992eb25ec2bbf646f5c1175a4c8 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 12 Aug 2023 21:51:35 +0200 Subject: [PATCH] Feature/add data export to user account page (#2234) * Add data export * Update changelog --- CHANGELOG.md | 20 ++++++++----- .../pages/account/account-page.component.ts | 23 ++++++++++++++- .../src/app/pages/account/account-page.html | 8 ++++++ apps/client/src/locales/messages.de.xlf | 28 ++++++++++++------- apps/client/src/locales/messages.es.xlf | 28 ++++++++++++------- apps/client/src/locales/messages.fr.xlf | 28 ++++++++++++------- apps/client/src/locales/messages.it.xlf | 28 ++++++++++++------- apps/client/src/locales/messages.nl.xlf | 28 ++++++++++++------- apps/client/src/locales/messages.pt.xlf | 28 ++++++++++++------- apps/client/src/locales/messages.xlf | 27 +++++++++++------- 10 files changed, 168 insertions(+), 78 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0db0895aa..9cd9ed8c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Added + +- Added the data export feature to the user account page + ## 1.300.0 - 2023-08-11 ### Added @@ -611,7 +617,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Changed the slide toggles to checkboxes on the account page +- Changed the slide toggles to checkboxes on the user account page - Changed the slide toggles to checkboxes in the admin control panel - Increased the density of the theme - Migrated the style of various components to `@angular/material` `15` (mdc) @@ -1173,7 +1179,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Improved the language selector on the account page +- Improved the language selector on the user account page - Improved the wording in the _X-ray_ section (net worth instead of investment) - Extended the asset profile details dialog in the admin control panel - Updated the browserslist database @@ -1591,7 +1597,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Added a language selector to the account page +- Added a language selector to the user account page - Added support for translated labels in the value component ### Changed @@ -1920,7 +1926,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Added the user id to the account page +- Added the user id to the user account page - Added a new view with jobs of the queue to the admin control panel ### Changed @@ -3575,7 +3581,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Respected the cash balance on the analysis page -- Improved the settings selectors on the account page +- Improved the settings selectors on the user account page - Harmonized the slogan to "Open Source Wealth Management Software" ### Fixed @@ -4041,7 +4047,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added a gradient to the line charts -- Added a selector to set the base currency on the account page +- Added a selector to set the base currency on the user account page ## 0.81.0 - 06.04.2021 @@ -4355,7 +4361,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- Added the membership status to the account page +- Added the membership status to the user account page ### Fixed diff --git a/apps/client/src/app/pages/account/account-page.component.ts b/apps/client/src/app/pages/account/account-page.component.ts index 5ab140265..0e4527eeb 100644 --- a/apps/client/src/app/pages/account/account-page.component.ts +++ b/apps/client/src/app/pages/account/account-page.component.ts @@ -21,7 +21,7 @@ import { } from '@ghostfolio/client/services/settings-storage.service'; import { UserService } from '@ghostfolio/client/services/user/user.service'; import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; -import { getDateFormatString } from '@ghostfolio/common/helper'; +import { downloadAsFile, getDateFormatString } from '@ghostfolio/common/helper'; import { Access, User } from '@ghostfolio/common/interfaces'; import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { uniq } from 'lodash'; @@ -31,6 +31,7 @@ import { EMPTY, Subject } from 'rxjs'; import { catchError, switchMap, takeUntil } from 'rxjs/operators'; import { CreateOrUpdateAccessDialog } from './create-or-update-access-dialog/create-or-update-access-dialog.component'; +import { format, parseISO } from 'date-fns'; @Component({ host: { class: 'page' }, @@ -237,6 +238,26 @@ export class AccountPageComponent implements OnDestroy, OnInit { }); } + public onExport() { + this.dataService + .fetchExport() + .pipe(takeUntil(this.unsubscribeSubject)) + .subscribe((data) => { + for (const activity of data.activities) { + delete activity.id; + } + + downloadAsFile({ + content: data, + fileName: `ghostfolio-export-${format( + parseISO(data.meta.date), + 'yyyyMMddHHmm' + )}.json`, + format: 'json' + }); + }); + } + public onRedeemCoupon() { let couponCode = prompt($localize`Please enter your coupon code:`); couponCode = couponCode?.trim(); diff --git a/apps/client/src/app/pages/account/account-page.html b/apps/client/src/app/pages/account/account-page.html index fbf14544a..aeba71320 100644 --- a/apps/client/src/app/pages/account/account-page.html +++ b/apps/client/src/app/pages/account/account-page.html @@ -273,6 +273,14 @@