From 2a1339b61ebfb81dbbba03f26e94afdc79d897f4 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 5 Nov 2022 09:12:41 +0100 Subject: [PATCH] Feature/improve usage of premium indicator component (#1421) * Improve usage of premium indicator component * Update changelog --- CHANGELOG.md | 1 + .../src/app/portfolio/portfolio.controller.ts | 48 ++++++++++++------- .../benchmark-comparator.component.html | 1 + .../benchmark-comparator.module.ts | 2 + .../app/pages/portfolio/fire/fire-page.html | 16 ++++++- .../pages/portfolio/fire/fire-page.module.ts | 2 + .../app/pages/portfolio/portfolio-page.html | 32 ++----------- .../pages/portfolio/portfolio-page.module.ts | 2 - .../pages/portfolio/report/report-page.html | 24 ++++++++-- .../portfolio/report/report-page.module.ts | 8 +++- 10 files changed, 84 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec11d772..008db78b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Improved the usage of the premium indicator component - Removed the intro image in dark mode ## 1.208.0 - 03.11.2022 diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 16f916cf..2596f5e3 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -71,8 +71,13 @@ export class PortfolioController { @Query('range') dateRange: DateRange = 'max', @Query('tags') filterByTags?: string ): Promise { + let hasDetails = true; let hasError = false; + if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { + hasDetails = this.request.user.subscription.type === 'Premium'; + } + const filters = this.apiService.buildFiltersFromQueryParams({ filterByAccounts, filterByAssetClasses, @@ -133,7 +138,13 @@ export class PortfolioController { accounts[name].current = current / totalValue; accounts[name].original = original / totalInvestment; } + } + if ( + hasDetails === false || + impersonationId || + this.userService.isRestrictedView(this.request.user) + ) { portfolioSummary = nullifyValuesInObject(summary, [ 'cash', 'committedFunds', @@ -151,11 +162,6 @@ export class PortfolioController { ]); } - let hasDetails = true; - if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { - hasDetails = this.request.user.subscription.type === 'Premium'; - } - for (const [symbol, portfolioPosition] of Object.entries(holdings)) { holdings[symbol] = { ...portfolioPosition, @@ -175,7 +181,7 @@ export class PortfolioController { hasError, holdings, totalValueInBaseCurrency, - summary: hasDetails ? portfolioSummary : undefined + summary: portfolioSummary }; } @@ -186,16 +192,6 @@ export class PortfolioController { @Query('range') dateRange: DateRange = 'max', @Query('groupBy') groupBy?: GroupBy ): Promise { - if ( - this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && - this.request.user.subscription.type === 'Basic' - ) { - throw new HttpException( - getReasonPhrase(StatusCodes.FORBIDDEN), - StatusCodes.FORBIDDEN - ); - } - let investments: InvestmentItem[]; if (groupBy === 'month') { @@ -226,6 +222,15 @@ export class PortfolioController { })); } + if ( + this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && + this.request.user.subscription.type === 'Basic' + ) { + investments = investments.map((item) => { + return nullifyValuesInObject(item, ['investment']); + }); + } + return { investments }; } @@ -274,6 +279,17 @@ export class PortfolioController { ); } + if ( + this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && + this.request.user.subscription.type === 'Basic' + ) { + performanceInformation.chart = performanceInformation.chart.map( + (item) => { + return nullifyValuesInObject(item, ['totalInvestment', 'value']); + } + ); + } + return performanceInformation; } diff --git a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html index 95b7e272..df2b6f89 100644 --- a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html +++ b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.html @@ -18,6 +18,7 @@ Compare with... diff --git a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.module.ts b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.module.ts index 16440d3a..23b0a48a 100644 --- a/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.module.ts +++ b/apps/client/src/app/components/benchmark-comparator/benchmark-comparator.module.ts @@ -2,6 +2,7 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatSelectModule } from '@angular/material/select'; +import { GfPremiumIndicatorModule } from '@ghostfolio/ui/premium-indicator'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { BenchmarkComparatorComponent } from './benchmark-comparator.component'; @@ -12,6 +13,7 @@ import { BenchmarkComparatorComponent } from './benchmark-comparator.component'; imports: [ CommonModule, FormsModule, + GfPremiumIndicatorModule, MatSelectModule, NgxSkeletonLoaderModule, ReactiveFormsModule diff --git a/apps/client/src/app/pages/portfolio/fire/fire-page.html b/apps/client/src/app/pages/portfolio/fire/fire-page.html index 5da8d248..f57ead45 100644 --- a/apps/client/src/app/pages/portfolio/fire/fire-page.html +++ b/apps/client/src/app/pages/portfolio/fire/fire-page.html @@ -3,7 +3,13 @@

FIRE

-

Calculator

+

+ Calculator +

-

4% Rule

+

+ 4% Rule +

-

- Allocations - -

+

Allocations

Check the allocations of your portfolio by account, asset class, currency, sector and region. @@ -65,13 +59,7 @@
-

- Analysis - -

+

Analysis

Ghostfolio Analysis visualizes your portfolio and shows your top and bottom performers. @@ -90,13 +78,7 @@
-

- X-ray - -

+

X-ray

Ghostfolio X-ray uses static analysis to identify potential issues and risks in your portfolio. @@ -111,13 +93,7 @@
-

- FIRE - -

+

FIRE

Ghostfolio FIRE calculates metrics for the Financial Independence, Retire Early lifestyle. diff --git a/apps/client/src/app/pages/portfolio/portfolio-page.module.ts b/apps/client/src/app/pages/portfolio/portfolio-page.module.ts index da2bd99d..7c3977f0 100644 --- a/apps/client/src/app/pages/portfolio/portfolio-page.module.ts +++ b/apps/client/src/app/pages/portfolio/portfolio-page.module.ts @@ -3,7 +3,6 @@ import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; import { RouterModule } from '@angular/router'; -import { GfPremiumIndicatorModule } from '@ghostfolio/ui/premium-indicator'; import { PortfolioPageRoutingModule } from './portfolio-page-routing.module'; import { PortfolioPageComponent } from './portfolio-page.component'; @@ -12,7 +11,6 @@ import { PortfolioPageComponent } from './portfolio-page.component'; declarations: [PortfolioPageComponent], imports: [ CommonModule, - GfPremiumIndicatorModule, MatButtonModule, MatCardModule, PortfolioPageRoutingModule, diff --git a/apps/client/src/app/pages/portfolio/report/report-page.html b/apps/client/src/app/pages/portfolio/report/report-page.html index 5237f910..e2e1d71a 100644 --- a/apps/client/src/app/pages/portfolio/report/report-page.html +++ b/apps/client/src/app/pages/portfolio/report/report-page.html @@ -14,21 +14,39 @@ >

-

Currency Cluster Risks

+

+ Currency Cluster Risks +

-

Account Cluster Risks

+

+ Account Cluster Risks +

-

Fees

+

+ Fees +