From 2a854e25743ebe69128707fc8cf922ce2db32340 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 6 Apr 2022 21:21:53 +0200 Subject: [PATCH] Various improvements (#807) --- .../src/app/portfolio/portfolio.controller.ts | 10 ++++++++ apps/api/src/app/user/user.service.ts | 2 +- .../portfolio-performance.component.ts | 5 ++-- .../src/app/core/http-response.interceptor.ts | 9 ++++++- .../app/pages/portfolio/portfolio-page.html | 24 +++++-------------- libs/ui/src/lib/value/value.component.ts | 4 ++++ 6 files changed, 32 insertions(+), 22 deletions(-) diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 1bb42a0ed..272721e76 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -320,6 +320,16 @@ export class PortfolioController { public async getSummary( @Headers('impersonation-id') impersonationId ): Promise { + if ( + this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && + this.request.user.subscription.type === 'Basic' + ) { + throw new HttpException( + getReasonPhrase(StatusCodes.FORBIDDEN), + StatusCodes.FORBIDDEN + ); + } + let summary = await this.portfolioServiceStrategy .get() .getSummary(impersonationId); diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index a4e9267ef..c94c5a458 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -67,7 +67,7 @@ export class UserService { settings: { ...(Settings.settings), baseCurrency: Settings?.currency ?? UserService.DEFAULT_CURRENCY, - locale: (Settings.settings).locale ?? aLocale, + locale: (Settings.settings)?.locale ?? aLocale, viewMode: Settings?.viewMode ?? ViewMode.DEFAULT } }; diff --git a/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts b/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts index f1daa7e72..aae5e5f5e 100644 --- a/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts +++ b/apps/client/src/app/components/portfolio-performance/portfolio-performance.component.ts @@ -70,9 +70,10 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit { 'value', this.performance?.currentNetPerformancePercent * 100, { + decimal: getNumberFormatDecimal(this.locale), decimalPlaces: 2, - duration: 0.75, - separator: `'` + duration: 1, + separator: getNumberFormatGroup(this.locale) } ).start(); } diff --git a/apps/client/src/app/core/http-response.interceptor.ts b/apps/client/src/app/core/http-response.interceptor.ts index 9ac221e62..b76884ffa 100644 --- a/apps/client/src/app/core/http-response.interceptor.ts +++ b/apps/client/src/app/core/http-response.interceptor.ts @@ -17,12 +17,14 @@ import { DataService } from '@ghostfolio/client/services/data.service'; import { TokenStorageService } from '@ghostfolio/client/services/token-storage.service'; import { WebAuthnService } from '@ghostfolio/client/services/web-authn.service'; import { InfoItem } from '@ghostfolio/common/interfaces'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { StatusCodes } from 'http-status-codes'; import { Observable, throwError } from 'rxjs'; import { catchError, tap } from 'rxjs/operators'; @Injectable() export class HttpResponseInterceptor implements HttpInterceptor { + public hasPermissionForSubscription: boolean; public info: InfoItem; public snackBarRef: MatSnackBarRef; @@ -34,6 +36,11 @@ export class HttpResponseInterceptor implements HttpInterceptor { private webAuthnService: WebAuthnService ) { this.info = this.dataService.fetchInfo(); + + this.hasPermissionForSubscription = hasPermission( + this.info?.globalPermissions, + permissions.enableSubscription + ); } public intercept( @@ -56,7 +63,7 @@ export class HttpResponseInterceptor implements HttpInterceptor { } else { this.snackBarRef = this.snackBar.open( 'This feature requires a subscription.', - 'Upgrade Plan', + this.hasPermissionForSubscription ? 'Upgrade Plan' : undefined, { duration: 6000 } ); } diff --git a/apps/client/src/app/pages/portfolio/portfolio-page.html b/apps/client/src/app/pages/portfolio/portfolio-page.html index d0717805d..f7bc75f91 100644 --- a/apps/client/src/app/pages/portfolio/portfolio-page.html +++ b/apps/client/src/app/pages/portfolio/portfolio-page.html @@ -25,7 +25,7 @@

Allocations @@ -38,7 +38,6 @@ Open Allocations @@ -52,7 +51,7 @@

Analysis @@ -65,7 +64,6 @@ Open Analysis @@ -79,7 +77,7 @@

X-ray @@ -89,12 +87,7 @@ risks in your portfolio.
- + Open X-ray @@ -106,7 +99,7 @@

FIRE @@ -116,12 +109,7 @@ Financial Independence, Retire Early lifestyle.

- + Open FIRE diff --git a/libs/ui/src/lib/value/value.component.ts b/libs/ui/src/lib/value/value.component.ts index 08fdb413e..7bd15076f 100644 --- a/libs/ui/src/lib/value/value.component.ts +++ b/libs/ui/src/lib/value/value.component.ts @@ -119,5 +119,9 @@ export class ValueComponent implements OnChanges { if (this.formattedValue === '0.00') { this.useAbsoluteValue = true; } + + if (this.isPercent) { + this.formattedValue = '– '; + } } }