Browse Source

refactor: refine state management dependent on mode

pull/4426/head
tobikugel 1 month ago
parent
commit
982c482c91
  1. 15
      apps/client/src/app/pages/portfolio/analysis/analysis-page.component.ts
  2. 4
      apps/client/src/app/pages/portfolio/analysis/analysis-page.html

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

@ -55,11 +55,12 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
public investments: InvestmentItem[]; public investments: InvestmentItem[];
public investmentTimelineDataLabel = $localize`Investment`; public investmentTimelineDataLabel = $localize`Investment`;
public investmentsByGroup: InvestmentItem[]; public investmentsByGroup: InvestmentItem[];
public isLoadingAiPrompt: boolean; public isLoadingAnalysisPrompt: boolean;
public isLoadingBenchmarkComparator: boolean; public isLoadingBenchmarkComparator: boolean;
public isLoadingDividendTimelineChart: boolean; public isLoadingDividendTimelineChart: boolean;
public isLoadingInvestmentChart: boolean; public isLoadingInvestmentChart: boolean;
public isLoadingInvestmentTimelineChart: boolean; public isLoadingInvestmentTimelineChart: boolean;
public isLoadingPortfolioPrompt: boolean;
public mode: GroupBy = 'month'; public mode: GroupBy = 'month';
public modeOptions: ToggleOption[] = [ public modeOptions: ToggleOption[] = [
{ label: $localize`Monthly`, value: 'month' }, { label: $localize`Monthly`, value: 'month' },
@ -153,7 +154,11 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
} }
public onCopyPromptToClipboard(mode: AiPromptMode) { public onCopyPromptToClipboard(mode: AiPromptMode) {
this.isLoadingAiPrompt = true; if (mode === 'analysis') {
this.isLoadingAnalysisPrompt = true;
} else if (mode === 'portfolio') {
this.isLoadingPortfolioPrompt = true;
}
this.dataService this.dataService
.fetchPrompt(mode) .fetchPrompt(mode)
@ -178,7 +183,11 @@ export class AnalysisPageComponent implements OnDestroy, OnInit {
this.actionsMenuButton.closeMenu(); this.actionsMenuButton.closeMenu();
this.isLoadingAiPrompt = false; if (mode === 'analysis') {
this.isLoadingAnalysisPrompt = false;
} else if (mode === 'portfolio') {
this.isLoadingPortfolioPrompt = false;
}
}); });
} }

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

@ -28,7 +28,7 @@
@if (user?.subscription?.type === 'Basic') { @if (user?.subscription?.type === 'Basic') {
<gf-premium-indicator class="mr-2" /> <gf-premium-indicator class="mr-2" />
} @else { } @else {
@if (isLoadingAiPrompt) { @if (isLoadingPortfolioPrompt) {
<mat-spinner class="mr-2" [diameter]="20" /> <mat-spinner class="mr-2" [diameter]="20" />
} @else { } @else {
<ion-icon class="mr-2" name="copy-outline" /> <ion-icon class="mr-2" name="copy-outline" />
@ -49,7 +49,7 @@
@if (user?.subscription?.type === 'Basic') { @if (user?.subscription?.type === 'Basic') {
<gf-premium-indicator class="mr-2" /> <gf-premium-indicator class="mr-2" />
} @else { } @else {
@if (isLoadingAiPrompt) { @if (isLoadingAnalysisPrompt) {
<mat-spinner class="mr-2" [diameter]="20" /> <mat-spinner class="mr-2" [diameter]="20" />
} @else { } @else {
<ion-icon class="mr-2" name="copy-outline" /> <ion-icon class="mr-2" name="copy-outline" />

Loading…
Cancel
Save