Browse Source

Merge db53ccf617 into 156b6e2d7f

pull/7034/merge
Matt Van Horn 2 weeks ago
committed by GitHub
parent
commit
b8a420eb0e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 34
      apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts
  2. 12
      apps/client/src/app/pages/portfolio/analysis/analysis-page.html

34
apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts

@ -87,7 +87,8 @@ export class GfAnalysisPageComponent implements OnInit {
protected isLoadingInvestmentChart: boolean; protected isLoadingInvestmentChart: boolean;
protected isLoadingInvestmentTimelineChart: boolean; protected isLoadingInvestmentTimelineChart: boolean;
protected isLoadingPortfolioPrompt: boolean; protected isLoadingPortfolioPrompt: boolean;
protected readonly mode = signal<GroupBy>('month'); protected readonly dividendGroupBy = signal<GroupBy>('month');
protected readonly investmentGroupBy = signal<GroupBy>('month');
protected readonly modeOptions: ToggleOption[] = [ protected readonly modeOptions: ToggleOption[] = [
{ label: $localize`Monthly`, value: 'month' }, { label: $localize`Monthly`, value: 'month' },
{ label: $localize`Yearly`, value: 'year' } { label: $localize`Yearly`, value: 'year' }
@ -137,7 +138,7 @@ export class GfAnalysisPageComponent implements OnInit {
return undefined; return undefined;
} }
return this.mode() === 'year' return this.investmentGroupBy() === 'year'
? savingsRatePerMonth * 12 ? savingsRatePerMonth * 12
: savingsRatePerMonth; : savingsRatePerMonth;
} }
@ -186,9 +187,14 @@ export class GfAnalysisPageComponent implements OnInit {
}); });
} }
protected onChangeGroupBy(aMode: GroupBy) { protected onChangeDividendGroupBy(aMode: GroupBy) {
this.mode.set(aMode); this.dividendGroupBy.set(aMode);
this.fetchDividendsAndInvestments(); this.fetchDividends();
}
protected onChangeInvestmentGroupBy(aMode: GroupBy) {
this.investmentGroupBy.set(aMode);
this.fetchInvestments();
} }
protected onCopyPromptToClipboard(mode: AiPromptMode) { protected onCopyPromptToClipboard(mode: AiPromptMode) {
@ -232,14 +238,13 @@ export class GfAnalysisPageComponent implements OnInit {
}); });
} }
private fetchDividendsAndInvestments() { private fetchDividends() {
this.isLoadingDividendTimelineChart = true; this.isLoadingDividendTimelineChart = true;
this.isLoadingInvestmentTimelineChart = true;
this.dataService this.dataService
.fetchDividends({ .fetchDividends({
filters: this.userService.getFilters(), filters: this.userService.getFilters(),
groupBy: this.mode(), groupBy: this.dividendGroupBy(),
range: this.user?.settings?.dateRange ?? DEFAULT_DATE_RANGE range: this.user?.settings?.dateRange ?? DEFAULT_DATE_RANGE
}) })
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(takeUntilDestroyed(this.destroyRef))
@ -250,11 +255,15 @@ export class GfAnalysisPageComponent implements OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}); });
}
private fetchInvestments() {
this.isLoadingInvestmentTimelineChart = true;
this.dataService this.dataService
.fetchInvestments({ .fetchInvestments({
filters: this.userService.getFilters(), filters: this.userService.getFilters(),
groupBy: this.mode(), groupBy: this.investmentGroupBy(),
range: this.user?.settings?.dateRange ?? DEFAULT_DATE_RANGE range: this.user?.settings?.dateRange ?? DEFAULT_DATE_RANGE
}) })
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(takeUntilDestroyed(this.destroyRef))
@ -262,7 +271,7 @@ export class GfAnalysisPageComponent implements OnInit {
this.investmentsByGroup = investments; this.investmentsByGroup = investments;
this.streaks = streaks; this.streaks = streaks;
this.unitCurrentStreak = this.unitCurrentStreak =
this.mode() === 'year' this.investmentGroupBy() === 'year'
? this.streaks?.currentStreak === 1 ? this.streaks?.currentStreak === 1
? translate('YEAR') ? translate('YEAR')
: translate('YEARS') : translate('YEARS')
@ -270,7 +279,7 @@ export class GfAnalysisPageComponent implements OnInit {
? translate('MONTH') ? translate('MONTH')
: translate('MONTHS'); : translate('MONTHS');
this.unitLongestStreak = this.unitLongestStreak =
this.mode() === 'year' this.investmentGroupBy() === 'year'
? this.streaks?.longestStreak === 1 ? this.streaks?.longestStreak === 1
? translate('YEAR') ? translate('YEAR')
: translate('YEARS') : translate('YEARS')
@ -381,7 +390,8 @@ export class GfAnalysisPageComponent implements OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
}); });
this.fetchDividendsAndInvestments(); this.fetchDividends();
this.fetchInvestments();
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }

12
apps/client/src/app/pages/portfolio/analysis/analysis-page.html

@ -442,10 +442,10 @@
</div> </div>
<gf-toggle <gf-toggle
class="d-none d-lg-block" class="d-none d-lg-block"
[defaultValue]="mode()" [defaultValue]="investmentGroupBy()"
[isLoading]="false" [isLoading]="false"
[options]="modeOptions" [options]="modeOptions"
(valueChange)="onChangeGroupBy($event.value)" (valueChange)="onChangeInvestmentGroupBy($event.value)"
/> />
</div> </div>
@if (streaks) { @if (streaks) {
@ -476,7 +476,7 @@
[benchmarkDataItems]="investmentsByGroup" [benchmarkDataItems]="investmentsByGroup"
[benchmarkDataLabel]="investmentTimelineDataLabel" [benchmarkDataLabel]="investmentTimelineDataLabel"
[currency]="user?.settings?.baseCurrency" [currency]="user?.settings?.baseCurrency"
[groupBy]="mode()" [groupBy]="investmentGroupBy()"
[isInPercentage]=" [isInPercentage]="
hasImpersonationId || user.settings.isRestrictedView hasImpersonationId || user.settings.isRestrictedView
" "
@ -501,10 +501,10 @@
</div> </div>
<gf-toggle <gf-toggle
class="d-none d-lg-block" class="d-none d-lg-block"
[defaultValue]="mode()" [defaultValue]="dividendGroupBy()"
[isLoading]="false" [isLoading]="false"
[options]="modeOptions" [options]="modeOptions"
(valueChange)="onChangeGroupBy($event.value)" (valueChange)="onChangeDividendGroupBy($event.value)"
/> />
</div> </div>
<div class="chart-container"> <div class="chart-container">
@ -513,7 +513,7 @@
[benchmarkDataItems]="dividendsByGroup" [benchmarkDataItems]="dividendsByGroup"
[benchmarkDataLabel]="dividendTimelineDataLabel" [benchmarkDataLabel]="dividendTimelineDataLabel"
[currency]="user?.settings?.baseCurrency" [currency]="user?.settings?.baseCurrency"
[groupBy]="mode()" [groupBy]="dividendGroupBy()"
[isInPercentage]=" [isInPercentage]="
hasImpersonationId || user.settings.isRestrictedView hasImpersonationId || user.settings.isRestrictedView
" "

Loading…
Cancel
Save