@ -70,8 +70,7 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy {
) { }
) { }
public ngOnInit() {
public ngOnInit() {
this . initializeCustomCurrencies ( ) ;
this . initialize ( ) ;
this . initializeExchangeRateDataSource ( ) ;
this . createAssetProfileForm = this . formBuilder . group (
this . createAssetProfileForm = this . formBuilder . group (
{
{
@ -121,14 +120,7 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy {
} )
} )
. pipe (
. pipe (
switchMap ( ( ) = > {
switchMap ( ( ) = > {
// Add the currency asset profile first
// Gather historical data for the currency
return this . adminService . addAssetProfile ( {
dataSource : this.exchangeRateDataSource ,
symbol : ` ${ currency } ${ DEFAULT_CURRENCY } `
} ) ;
} ) ,
switchMap ( ( ) = > {
// Then gather historical data for the currency
return this . adminService . gatherSymbol ( {
return this . adminService . gatherSymbol ( {
dataSource : this.exchangeRateDataSource ,
dataSource : this.exchangeRateDataSource ,
symbol : ` ${ currency } ${ DEFAULT_CURRENCY } `
symbol : ` ${ currency } ${ DEFAULT_CURRENCY } `
@ -190,28 +182,18 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy {
return { atLeastOneValid : true } ;
return { atLeastOneValid : true } ;
}
}
private initializeCustomCurrencies () {
private initialize() {
this . adminService
this . adminService
. fetchAdminData ( )
. fetchAdminData ( )
. pipe ( takeUntil ( this . unsubscribeSubject ) )
. pipe ( takeUntil ( this . unsubscribeSubject ) )
. subscribe ( ( { settings } ) = > {
. subscribe ( ( { settings , dataProviders } ) = > {
this . customCurrencies = settings [ PROPERTY_CURRENCIES ] as string [ ] ;
this . customCurrencies = settings [ PROPERTY_CURRENCIES ] as string [ ] ;
this . changeDetectorRef . markForCheck ( ) ;
} ) ;
}
private initializeExchangeRateDataSource() {
this . adminService
. fetchAdminData ( )
. pipe ( takeUntil ( this . unsubscribeSubject ) )
. subscribe ( ( { dataProviders } ) = > {
const exchangeRateProvider = dataProviders . find (
const exchangeRateProvider = dataProviders . find (
( provider ) = > provider . useForExchangeRates
( provider ) = > provider . useForExchangeRates
) ;
) ;
this . exchangeRateDataSource =
this . exchangeRateDataSource = exchangeRateProvider ? . dataSource ;
exchangeRateProvider ? . dataSource || DataSource . MANUAL ;
this . changeDetectorRef . markForCheck ( ) ;
this . changeDetectorRef . markForCheck ( ) ;
} ) ;
} ) ;