Browse Source

Refactoring

pull/5434/head
Thomas Kaul 4 months ago
parent
commit
d9e19537fc
  1. 20
      apps/api/src/app/admin/admin.service.ts
  2. 13
      apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts

20
apps/api/src/app/admin/admin.service.ts

@ -136,11 +136,13 @@ export class AdminService {
public async get(): Promise<AdminData> {
const dataSources = Object.values(DataSource);
const [settings, transactionCount, userCount] = await Promise.all([
this.propertyService.get(),
this.prismaService.order.count(),
this.countUsersWithAnalytics()
]);
const [enabledDataSources, settings, transactionCount, userCount] =
await Promise.all([
this.dataProviderService.getDataSources(),
this.propertyService.get(),
this.prismaService.order.count(),
this.countUsersWithAnalytics()
]);
const dataProviders = (
await Promise.all(
@ -152,7 +154,13 @@ export class AdminService {
}
});
if (assetProfileCount > 0 || dataSource === 'GHOSTFOLIO') {
const isEnabled = enabledDataSources.includes(dataSource);
if (
assetProfileCount > 0 ||
dataSource === 'GHOSTFOLIO' ||
isEnabled
) {
const dataProviderInfo = this.dataProviderService
.getDataProvider(dataSource)
.getDataProviderInfo();

13
apps/client/src/app/components/admin-market-data/create-asset-profile-dialog/create-asset-profile-dialog.component.ts

@ -120,10 +120,9 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy {
})
.pipe(
switchMap(() => {
// Gather historical data for the currency
return this.adminService.gatherSymbol({
dataSource: this.exchangeRateDataSource,
symbol: `${currency}${DEFAULT_CURRENCY}`
symbol: `${DEFAULT_CURRENCY}${currency}`
});
}),
takeUntil(this.unsubscribeSubject)
@ -186,14 +185,14 @@ export class GfCreateAssetProfileDialogComponent implements OnInit, OnDestroy {
this.adminService
.fetchAdminData()
.pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ settings, dataProviders }) => {
.subscribe(({ dataProviders, settings }) => {
this.customCurrencies = settings[PROPERTY_CURRENCIES] as string[];
const exchangeRateProvider = dataProviders.find(
(provider) => provider.useForExchangeRates
);
const { dataSource } = dataProviders.find(({ useForExchangeRates }) => {
return useForExchangeRates;
});
this.exchangeRateDataSource = exchangeRateProvider?.dataSource;
this.exchangeRateDataSource = dataSource;
this.changeDetectorRef.markForCheck();
});

Loading…
Cancel
Save