|
|
@ -11,7 +11,7 @@ import { |
|
|
|
ToggleOption, |
|
|
|
User |
|
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
|
import { hasPermission, hasReadRestrictedAccessPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
|
import type { AiPromptMode, GroupBy } from '@ghostfolio/common/types'; |
|
|
|
import { translate } from '@ghostfolio/ui/i18n'; |
|
|
|
|
|
|
@ -51,6 +51,7 @@ 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`; |
|
|
@ -93,7 +94,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
get savingsRate() { |
|
|
|
const savingsRatePerMonth = |
|
|
|
this.hasImpersonationId || this.user.settings.isRestrictedView |
|
|
|
(this.hasImpersonationId && this.hasRestrictedAccess) || this.user.settings.isRestrictedView |
|
|
|
? undefined |
|
|
|
: this.user?.settings?.savingsRate; |
|
|
|
|
|
|
@ -110,6 +111,15 @@ 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.user as any |
|
|
|
}); |
|
|
|
} else { |
|
|
|
this.hasRestrictedAccess = false; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
this.userService.stateChanged |
|
|
@ -118,6 +128,15 @@ 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.user as any |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
this.benchmark = this.benchmarks.find(({ id }) => { |
|
|
|
return id === this.user.settings?.benchmark; |
|
|
|
}); |
|
|
|