@ -16,7 +16,11 @@ 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' ;
import { GfPremiumIndicatorComponent } from '@ghostfolio/ui/premium-indicator' ;
@ -79,8 +83,8 @@ export class GfAnalysisPageComponent implements OnInit {
protected bottom3 : PortfolioPosition [ ] ;
protected dividendsByGroup : InvestmentItem [ ] ;
protected readonly dividendTimelineDataLabel = $localize ` Dividend ` ;
protected hasImpersonationId : boolean ;
protected hasPermissionToReadAiPrompt : boolean ;
protected impersonationId : string | null ;
protected investments : InvestmentItem [ ] ;
protected readonly investmentTimelineDataLabel = $localize ` Invested Capital ` ;
protected investmentsByGroup : InvestmentItem [ ] ;
@ -100,6 +104,7 @@ export class GfAnalysisPageComponent implements OnInit {
protected performanceDataItemsInPercentage : HistoricalDataItem [ ] ;
protected readonly portfolioEvolutionDataLabel = $localize ` Investment ` ;
protected precision = 2 ;
protected savingsRatePerMonth : number | undefined ;
protected streaks : PortfolioInvestmentsResponse [ 'streaks' ] ;
protected top3 : PortfolioPosition [ ] ;
protected unitCurrentStreak : string ;
@ -131,18 +136,13 @@ export class GfAnalysisPageComponent implements OnInit {
}
get savingsRate() {
const savingsRatePerMonth =
this . hasImpersonationId || this . user . settings . isRestrictedView
? undefined
: this . user ? . settings ? . savingsRate ;
if ( savingsRatePerMonth === undefined ) {
if ( ! this . savingsRatePerMonth ) {
return undefined ;
}
return this . mode ( ) === 'year'
? savingsRatePerMonth * 12
: savingsRatePerMonth ;
? this . savingsRatePerMonth * 12
: this . savingsRatePerMonth ;
}
public ngOnInit() {
@ -150,7 +150,7 @@ export class GfAnalysisPageComponent implements OnInit {
. onChangeHasImpersonation ( )
. pipe ( takeUntilDestroyed ( this . destroyRef ) )
. subscribe ( ( impersonationId ) = > {
this . hasImpersonationId = ! ! impersonationId ;
this . impersonationId = impersonationId ;
this . changeDetectorRef . markForCheck ( ) ;
} ) ;
@ -241,6 +241,15 @@ export class GfAnalysisPageComponent implements OnInit {
} ) ;
}
protected showValuesInPercentage() {
return (
hasReadRestrictedAccessPermission ( {
accesses : this.user?.access ,
impersonationId : this.impersonationId
} ) || this . user ? . settings ? . isRestrictedView
) ;
}
private fetchDividendsAndInvestments() {
this . isLoadingDividendTimelineChart = true ;
this . isLoadingInvestmentTimelineChart = true ;
@ -267,8 +276,9 @@ export class GfAnalysisPageComponent implements OnInit {
range : this.user?.settings?.dateRange ? ? DEFAULT_DATE_RANGE
} )
. pipe ( takeUntilDestroyed ( this . destroyRef ) )
. subscribe ( ( { investments , streaks } ) = > {
. subscribe ( ( { investments , savingsRate , s treaks } ) = > {
this . investmentsByGroup = investments ;
this . savingsRatePerMonth = savingsRate ;
this . streaks = streaks ;
this . unitCurrentStreak =
this . mode ( ) === 'year'