Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Task/lazy load platforms via API in create or update account dialog (#6130)

Omkar Gujja95cbd01a4c5b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8cabbc605b..91fc2bc395 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
+- Integrated the endpoint to get all platforms (`GET api/v1/platforms`) into the create or update account dialog
- Extracted the scraper configuration to a dedicated tab in the asset profile details dialog of the admin control panel
## 2.227.0 - 2026-01-02
diff --git a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
index 5e18f25cf0..ceb11a0115 100644
--- a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
+++ b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
@@ -59,7 +59,7 @@ export class GfCreateOrUpdateAccountDialogComponent implements OnDestroy {
public accountForm: FormGroup;
public currencies: string[] = [];
public filteredPlatforms: Observable<Platform[]>;
- public platforms: Platform[];
+ public platforms: Platform[] = [];
private unsubscribeSubject = new Subject<void>();
@@ -71,10 +71,8 @@ export class GfCreateOrUpdateAccountDialogComponent implements OnDestroy {
) {}
public ngOnInit() {
- const { currencies, platforms } = this.dataService.fetchInfo();
-
+ const { currencies } = this.dataService.fetchInfo();
this.currencies = currencies;
- this.platforms = platforms;
this.accountForm = this.formBuilder.group({
accountId: [{ disabled: true, value: this.data.account.id }],
@@ -83,23 +81,33 @@ export class GfCreateOrUpdateAccountDialogComponent implements OnDestroy {
currency: [this.data.account.currency, Validators.required],
isExcluded: [this.data.account.isExcluded],
name: [this.data.account.name, Validators.required],
- platformId: [
- this.platforms.find(({ id }) => {
- return id === this.data.account.platformId;
- }),
- this.autocompleteObjectValidator()
- ]
+ platformId: [null, this.autocompleteObjectValidator()]
});
- this.filteredPlatforms = this.accountForm
- .get('platformId')
- .valueChanges.pipe(
- startWith(''),
- map((value) => {
- const name = typeof value === 'string' ? value : value?.name;
- return name ? this.filter(name as string) : this.platforms.slice();
- })
+ this.dataService.fetchPlatforms().subscribe(({ platforms }) => {
+ this.platforms = platforms;
+
+ const selectedPlatform = this.platforms.find(({ id }) => {
+ return id === this.data.account.platformId;
+ });
+
+ this.accountForm.patchValue(
+ {
+ platformId: selectedPlatform
+ },
+ { emitEvent: false }
);
+
+ this.filteredPlatforms = this.accountForm
+ .get('platformId')
+ .valueChanges.pipe(
+ startWith(''),
+ map((value) => {
+ const name = typeof value === 'string' ? value : value?.name;
+ return name ? this.filter(name as string) : this.platforms.slice();
+ })
+ );
+ });
}
public autoCompleteCheck() {
diff --git a/apps/client/src/app/services/data.service.ts b/apps/client/src/app/services/data.service.ts
index 31b0fef738..21eec06c3b 100644
--- a/apps/client/src/app/services/data.service.ts
+++ b/apps/client/src/app/services/data.service.ts
@@ -42,6 +42,7 @@ import {
MarketDataDetailsResponse,
MarketDataOfMarketsResponse,
OAuthResponse,
+ PlatformsResponse,
PortfolioDetails,
PortfolioDividendsResponse,
PortfolioHoldingResponse,
@@ -521,6 +522,10 @@ export class DataService {
);
}
+ public fetchPlatforms() {
+ return this.http.get<PlatformsResponse>('/api/v1/platforms');
+ }
+
public fetchPortfolioDetails({
filters,
withMarkets = false