|
@ -11,8 +11,8 @@ import { |
|
|
ToggleOption, |
|
|
ToggleOption, |
|
|
User |
|
|
User |
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
import { hasPermission, hasReadRestrictedAccessPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
import { hasPermission, permissions } from '@ghostfolio/common/permissions'; |
|
|
import type { AiPromptMode, GroupBy, UserWithSettings } from '@ghostfolio/common/types'; |
|
|
import type { AiPromptMode, GroupBy } from '@ghostfolio/common/types'; |
|
|
import { translate } from '@ghostfolio/ui/i18n'; |
|
|
import { translate } from '@ghostfolio/ui/i18n'; |
|
|
|
|
|
|
|
|
import { Clipboard } from '@angular/cdk/clipboard'; |
|
|
import { Clipboard } from '@angular/cdk/clipboard'; |
|
@ -51,7 +51,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { |
|
|
public dividendTimelineDataLabel = $localize`Dividend`; |
|
|
public dividendTimelineDataLabel = $localize`Dividend`; |
|
|
public firstOrderDate: Date; |
|
|
public firstOrderDate: Date; |
|
|
public hasImpersonationId: boolean; |
|
|
public hasImpersonationId: boolean; |
|
|
public hasRestrictedAccess = false; |
|
|
|
|
|
public hasPermissionToReadAiPrompt: boolean; |
|
|
public hasPermissionToReadAiPrompt: boolean; |
|
|
public investments: InvestmentItem[]; |
|
|
public investments: InvestmentItem[]; |
|
|
public investmentTimelineDataLabel = $localize`Investment`; |
|
|
public investmentTimelineDataLabel = $localize`Investment`; |
|
@ -94,7 +93,7 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
|
get savingsRate() { |
|
|
get savingsRate() { |
|
|
const savingsRatePerMonth = |
|
|
const savingsRatePerMonth = |
|
|
(this.hasImpersonationId && this.hasRestrictedAccess) || this.user.settings.isRestrictedView |
|
|
this.hasImpersonationId || this.user.settings.isRestrictedView |
|
|
? undefined |
|
|
? undefined |
|
|
: this.user?.settings?.savingsRate; |
|
|
: this.user?.settings?.savingsRate; |
|
|
|
|
|
|
|
@ -103,27 +102,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { |
|
|
: savingsRatePerMonth; |
|
|
: 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() { |
|
|
public ngOnInit() { |
|
|
this.deviceType = this.deviceService.getDeviceInfo().deviceType; |
|
|
this.deviceType = this.deviceService.getDeviceInfo().deviceType; |
|
|
|
|
|
|
|
@ -132,15 +110,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.subscribe((impersonationId) => { |
|
|
.subscribe((impersonationId) => { |
|
|
this.hasImpersonationId = !!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 |
|
|
this.userService.stateChanged |
|
@ -149,15 +118,6 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { |
|
|
if (state?.user) { |
|
|
if (state?.user) { |
|
|
this.user = 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 }) => { |
|
|
this.benchmark = this.benchmarks.find(({ id }) => { |
|
|
return id === this.user.settings?.benchmark; |
|
|
return id === this.user.settings?.benchmark; |
|
|
}); |
|
|
}); |
|
|