|
|
|
@ -17,7 +17,10 @@ import { |
|
|
|
User |
|
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
|
import { DateRange } from '@ghostfolio/common/types'; |
|
|
|
import { validateObjectForForm } from '@ghostfolio/common/utils'; |
|
|
|
import { |
|
|
|
validateObjectForForm, |
|
|
|
jsonValidator |
|
|
|
} from '@ghostfolio/common/utils/form.util'; |
|
|
|
import { GfCurrencySelectorComponent } from '@ghostfolio/ui/currency-selector'; |
|
|
|
import { GfEntityLogoComponent } from '@ghostfolio/ui/entity-logo'; |
|
|
|
import { GfHistoricalMarketDataEditorComponent } from '@ghostfolio/ui/historical-market-data-editor'; |
|
|
|
@ -150,7 +153,7 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit { |
|
|
|
assetClass: new FormControl<AssetClass>(undefined), |
|
|
|
assetSubClass: new FormControl<AssetSubClass>(undefined), |
|
|
|
comment: '', |
|
|
|
countries: ['', this.jsonValidator()], |
|
|
|
countries: ['', jsonValidator()], |
|
|
|
currency: '', |
|
|
|
historicalData: this.formBuilder.group({ |
|
|
|
csvString: '' |
|
|
|
@ -159,14 +162,14 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit { |
|
|
|
name: ['', Validators.required], |
|
|
|
scraperConfiguration: this.formBuilder.group({ |
|
|
|
defaultMarketPrice: null, |
|
|
|
headers: [JSON.stringify({}), this.jsonValidator()], |
|
|
|
headers: [JSON.stringify({}), jsonValidator()], |
|
|
|
locale: '', |
|
|
|
mode: '', |
|
|
|
selector: '', |
|
|
|
url: '' |
|
|
|
}), |
|
|
|
sectors: ['', this.jsonValidator()], |
|
|
|
symbolMapping: ['', this.jsonValidator()], |
|
|
|
sectors: ['', jsonValidator()], |
|
|
|
symbolMapping: ['', jsonValidator()], |
|
|
|
url: '' |
|
|
|
}); |
|
|
|
|
|
|
|
@ -722,17 +725,4 @@ export class GfAssetProfileDialogComponent implements OnDestroy, OnInit { |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private jsonValidator() { |
|
|
|
return (control: AbstractControl): ValidationErrors | null => { |
|
|
|
try { |
|
|
|
if (control.value) { |
|
|
|
JSON.parse(control.value); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} catch { |
|
|
|
return { invalidJson: true }; |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|