|
|
@ -11,6 +11,7 @@ import { |
|
|
|
AdminMarketDataDetails, |
|
|
|
AssetProfileIdentifier, |
|
|
|
LineChartItem, |
|
|
|
ScraperConfiguration, |
|
|
|
User |
|
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
|
import { translate } from '@ghostfolio/ui/i18n'; |
|
|
@ -41,6 +42,7 @@ import { |
|
|
|
AssetClass, |
|
|
|
AssetSubClass, |
|
|
|
MarketData, |
|
|
|
Prisma, |
|
|
|
SymbolProfile |
|
|
|
} from '@prisma/client'; |
|
|
|
import { format } from 'date-fns'; |
|
|
@ -343,7 +345,10 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
public async onSubmitAssetProfileForm() { |
|
|
|
let countries = []; |
|
|
|
let scraperConfiguration = {}; |
|
|
|
let scraperConfiguration: ScraperConfiguration = { |
|
|
|
selector: '', |
|
|
|
url: '' |
|
|
|
}; |
|
|
|
let sectors = []; |
|
|
|
let symbolMapping = {}; |
|
|
|
|
|
|
@ -354,9 +359,9 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
try { |
|
|
|
scraperConfiguration = { |
|
|
|
defaultMarketPrice: |
|
|
|
this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
(this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'defaultMarketPrice' |
|
|
|
].value, |
|
|
|
].value as number) || undefined, |
|
|
|
headers: JSON.parse( |
|
|
|
this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'headers' |
|
|
@ -365,10 +370,10 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
locale: |
|
|
|
this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'locale' |
|
|
|
].value, |
|
|
|
].value || undefined, |
|
|
|
mode: this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'mode' |
|
|
|
].value, |
|
|
|
].value as ScraperConfiguration['mode'], |
|
|
|
selector: |
|
|
|
this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'selector' |
|
|
@ -377,6 +382,10 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
'url' |
|
|
|
].value |
|
|
|
}; |
|
|
|
|
|
|
|
if (!scraperConfiguration.selector || !scraperConfiguration.url) { |
|
|
|
scraperConfiguration = undefined; |
|
|
|
} |
|
|
|
} catch {} |
|
|
|
|
|
|
|
try { |
|
|
@ -391,7 +400,6 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
|
|
|
|
const assetProfile: UpdateAssetProfileDto = { |
|
|
|
countries, |
|
|
|
scraperConfiguration, |
|
|
|
sectors, |
|
|
|
symbolMapping, |
|
|
|
assetClass: this.assetProfileForm.get('assetClass').value, |
|
|
@ -400,6 +408,8 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
currency: this.assetProfileForm.get('currency').value, |
|
|
|
isActive: this.assetProfileForm.get('isActive').value, |
|
|
|
name: this.assetProfileForm.get('name').value, |
|
|
|
scraperConfiguration: |
|
|
|
scraperConfiguration as unknown as Prisma.InputJsonObject, |
|
|
|
url: this.assetProfileForm.get('url').value || null |
|
|
|
}; |
|
|
|
|
|
|
@ -493,11 +503,10 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
this.adminService |
|
|
|
.testMarketData({ |
|
|
|
dataSource: this.data.dataSource, |
|
|
|
scraperConfiguration: JSON.stringify({ |
|
|
|
defaultMarketPrice: |
|
|
|
this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'defaultMarketPrice' |
|
|
|
].value, |
|
|
|
scraperConfiguration: { |
|
|
|
defaultMarketPrice: this.assetProfileForm.controls[ |
|
|
|
'scraperConfiguration' |
|
|
|
].controls['defaultMarketPrice'].value as number, |
|
|
|
headers: JSON.parse( |
|
|
|
this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'headers' |
|
|
@ -506,7 +515,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
locale: |
|
|
|
this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'locale' |
|
|
|
].value, |
|
|
|
].value || undefined, |
|
|
|
mode: this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'mode' |
|
|
|
].value, |
|
|
@ -517,7 +526,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
|
url: this.assetProfileForm.controls['scraperConfiguration'].controls[ |
|
|
|
'url' |
|
|
|
].value |
|
|
|
}), |
|
|
|
}, |
|
|
|
symbol: this.data.symbol |
|
|
|
}) |
|
|
|
.pipe( |
|
|
|