diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts index 286bfecf4..2bd3096d4 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts @@ -11,8 +11,8 @@ import { ToggleOption, User } from '@ghostfolio/common/interfaces'; -import { hasPermission, hasReadRestrictedAccessPermission, permissions } from '@ghostfolio/common/permissions'; -import type { AiPromptMode, GroupBy, UserWithSettings } from '@ghostfolio/common/types'; +import { hasPermission, permissions } from '@ghostfolio/common/permissions'; +import type { AiPromptMode, GroupBy } from '@ghostfolio/common/types'; import { translate } from '@ghostfolio/ui/i18n'; import { Clipboard } from '@angular/cdk/clipboard'; @@ -51,7 +51,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { public dividendTimelineDataLabel = $localize`Dividend`; public firstOrderDate: Date; public hasImpersonationId: boolean; - public hasRestrictedAccess = false; public hasPermissionToReadAiPrompt: boolean; public investments: InvestmentItem[]; public investmentTimelineDataLabel = $localize`Investment`; @@ -94,7 +93,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { get savingsRate() { const savingsRatePerMonth = - (this.hasImpersonationId && this.hasRestrictedAccess) || this.user.settings.isRestrictedView + this.hasImpersonationId || this.user.settings.isRestrictedView ? undefined : this.user?.settings?.savingsRate; @@ -103,27 +102,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { : savingsRatePerMonth; } - // Helper method to convert User to UserWithSettings format required by hasReadRestrictedAccessPermission - private convertUserToUserWithSettings(user: User): UserWithSettings { - return { - ...user, - Access: user.access.map(access => ({ - ...access, - createdAt: new Date(), - updatedAt: new Date(), - granteeUserId: '', - userId: '' - })), - Settings: { - createdAt: new Date(), - updatedAt: new Date(), - id: user.id, - settings: user.settings, - userId: user.id - } - } as UserWithSettings; - } - public ngOnInit() { this.deviceType = this.deviceService.getDeviceInfo().deviceType; @@ -132,15 +110,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { .pipe(takeUntil(this.unsubscribeSubject)) .subscribe((impersonationId) => { this.hasImpersonationId = !!impersonationId; - - if (this.hasImpersonationId && this.user) { - this.hasRestrictedAccess = hasReadRestrictedAccessPermission({ - impersonationId, - user: this.convertUserToUserWithSettings(this.user) - }); - } else { - this.hasRestrictedAccess = false; - } }); this.userService.stateChanged @@ -149,15 +118,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { if (state?.user) { this.user = state.user; - // Update hasRestrictedAccess when user changes - const impersonationId = this.impersonationStorageService.getId(); - if (impersonationId) { - this.hasRestrictedAccess = hasReadRestrictedAccessPermission({ - impersonationId, - user: this.convertUserToUserWithSettings(this.user) - }); - } - this.benchmark = this.benchmarks.find(({ id }) => { return id === this.user.settings?.benchmark; }); diff --git a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html index 6acf5f569..f318d0bb6 100644 --- a/apps/client/src/app/pages/portfolio/analysis/analysis-page.html +++ b/apps/client/src/app/pages/portfolio/analysis/analysis-page.html @@ -351,7 +351,7 @@ [benchmarkDataLabel]="portfolioEvolutionDataLabel" [currency]="user?.settings?.baseCurrency" [historicalDataItems]="performanceDataItems" - [isInPercent]="user.settings.isRestrictedView || (hasImpersonationId && hasRestrictedAccess)" + [isInPercent]="user.settings.isRestrictedView || hasImpersonationId" [isLoading]="isLoadingInvestmentChart" [locale]="user?.settings?.locale" /> @@ -407,7 +407,7 @@ [benchmarkDataLabel]="investmentTimelineDataLabel" [currency]="user?.settings?.baseCurrency" [groupBy]="mode" - [isInPercent]="user.settings.isRestrictedView || (hasImpersonationId && hasRestrictedAccess)" + [isInPercent]="user.settings.isRestrictedView || hasImpersonationId" [isLoading]="isLoadingInvestmentTimelineChart" [locale]="user?.settings?.locale" [savingsRate]="savingsRate" @@ -442,7 +442,7 @@ [benchmarkDataLabel]="dividendTimelineDataLabel" [currency]="user?.settings?.baseCurrency" [groupBy]="mode" - [isInPercent]="user.settings.isRestrictedView || (hasImpersonationId && hasRestrictedAccess)" + [isInPercent]="user.settings.isRestrictedView || hasImpersonationId" [isLoading]="isLoadingDividendTimelineChart" [locale]="user?.settings?.locale" />