diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d03715a7..d6b316c1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Improved the empty state of the portfolio proportion chart component + ### Fixed - Fixed an issue with dates in the value component diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 272721e76..a47f43035 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -106,16 +106,6 @@ export class PortfolioController { @Headers('impersonation-id') impersonationId: string, @Query('range') range ): Promise { - if ( - this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && - this.request.user.subscription.type === 'Basic' - ) { - throw new HttpException( - getReasonPhrase(StatusCodes.FORBIDDEN), - StatusCodes.FORBIDDEN - ); - } - let hasError = false; const { accounts, holdings, hasErrors } = @@ -162,7 +152,11 @@ export class PortfolioController { } } - return { accounts, hasError, holdings }; + const isBasicUser = + this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && + this.request.user.subscription.type === 'Basic'; + + return { accounts, hasError, holdings: isBasicUser ? {} : holdings }; } @Get('investments') diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index c94c5a458..feed46434 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -147,13 +147,6 @@ export class UserService { user.subscription = this.subscriptionService.getSubscription( userFromDatabase?.Subscription ); - - if (user.subscription.type === SubscriptionType.Basic) { - user.permissions = user.permissions.filter((permission) => { - return permission !== permissions.updateViewMode; - }); - user.Settings.viewMode = ViewMode.ZEN; - } } return user; diff --git a/apps/client/src/app/components/positions-table/positions-table.component.html b/apps/client/src/app/components/positions-table/positions-table.component.html index 38f5110b6..1c8f1539f 100644 --- a/apps/client/src/app/components/positions-table/positions-table.component.html +++ b/apps/client/src/app/components/positions-table/positions-table.component.html @@ -123,17 +123,6 @@ }" > -
- -
-
View Mode -
diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts index 5d7be99c4..da5e07025 100644 --- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts +++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.component.ts @@ -13,7 +13,6 @@ import { UniqueAsset, User } from '@ghostfolio/common/interfaces'; -import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { Market, ToggleOption } from '@ghostfolio/common/types'; import { Account, AssetClass, DataSource } from '@prisma/client'; import { DeviceDetectorService } from 'ngx-device-detector'; @@ -41,7 +40,6 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { }; public deviceType: string; public hasImpersonationId: boolean; - public hasPermissionToCreateOrder: boolean; public markets: { [key in Market]: { name: string; value: number }; }; @@ -139,11 +137,6 @@ export class AllocationsPageComponent implements OnDestroy, OnInit { if (state?.user) { this.user = state.user; - this.hasPermissionToCreateOrder = hasPermission( - this.user.permissions, - permissions.createOrder - ); - this.changeDetectorRef.markForCheck(); } }); diff --git a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html index 679570998..dac241b1d 100644 --- a/apps/client/src/app/pages/portfolio/allocations/allocations-page.html +++ b/apps/client/src/app/pages/portfolio/allocations/allocations-page.html @@ -30,9 +30,14 @@
- By Asset Class + By Currency @@ -54,9 +59,14 @@
- By Currency + By Asset Class @@ -78,7 +88,14 @@
- By Symbol + By Symbol - By Sector + By Sector - By Continent + By Continent - By Country + By Country - Regions + Regions diff --git a/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts b/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts index 803e52fea..207c9b3ca 100644 --- a/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts +++ b/libs/ui/src/lib/portfolio-proportion-chart/portfolio-proportion-chart.component.ts @@ -246,6 +246,12 @@ export class PortfolioProportionChartComponent labels = labelSubCategory.concat(labels); } + if (datasets[0]?.data?.length === 0 || datasets[0]?.data?.[0] === 0) { + labels = ['']; + datasets[0].backgroundColor = [this.colorMap[UNKNOWN_KEY]]; + datasets[0].data[0] = Number.MAX_SAFE_INTEGER; + } + const data = { datasets, labels @@ -323,7 +329,9 @@ export class PortfolioProportionChartComponent const percentage = (context.parsed * 100) / sum; - if (this.isInPercent) { + if (context.raw === Number.MAX_SAFE_INTEGER) { + return 'No data available'; + } else if (this.isInPercent) { return [`${name ?? symbol}`, `${percentage.toFixed(2)}%`]; } else { const value = context.raw;