Browse Source

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

* Lazy load platforms via API

* Update changelog
pull/6137/head^2
Omkar Gujja 1 week ago
committed by GitHub
parent
commit
95cbd01a4c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 44
      apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.component.ts
  3. 5
      apps/client/src/app/services/data.service.ts

1
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

44
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() {

5
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

Loading…
Cancel
Save