|
@ -26,8 +26,8 @@ import { |
|
|
} from '@prisma/client'; |
|
|
} from '@prisma/client'; |
|
|
import { format } from 'date-fns'; |
|
|
import { format } from 'date-fns'; |
|
|
import { parse as csvToJson } from 'papaparse'; |
|
|
import { parse as csvToJson } from 'papaparse'; |
|
|
import { Subject } from 'rxjs'; |
|
|
import { EMPTY, Subject } from 'rxjs'; |
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
import { catchError, takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
import { AssetProfileDialogParams } from './interfaces/interfaces'; |
|
|
import { AssetProfileDialogParams } from './interfaces/interfaces'; |
|
|
|
|
|
|
|
@ -51,12 +51,12 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
assetClass: new FormControl<AssetClass>(undefined), |
|
|
assetClass: new FormControl<AssetClass>(undefined), |
|
|
assetSubClass: new FormControl<AssetSubClass>(undefined), |
|
|
assetSubClass: new FormControl<AssetSubClass>(undefined), |
|
|
comment: '', |
|
|
comment: '', |
|
|
name: ['', Validators.required], |
|
|
|
|
|
scraperConfiguration: '', |
|
|
|
|
|
symbolMapping: '', |
|
|
|
|
|
historicalData: this.formBuilder.group({ |
|
|
historicalData: this.formBuilder.group({ |
|
|
csvString: '' |
|
|
csvString: '' |
|
|
}) |
|
|
}), |
|
|
|
|
|
name: ['', Validators.required], |
|
|
|
|
|
scraperConfiguration: '', |
|
|
|
|
|
symbolMapping: '' |
|
|
}); |
|
|
}); |
|
|
public assetProfileSubClass: string; |
|
|
public assetProfileSubClass: string; |
|
|
public benchmarks: Partial<SymbolProfile>[]; |
|
|
public benchmarks: Partial<SymbolProfile>[]; |
|
@ -132,14 +132,14 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
assetClass: this.assetProfile.assetClass ?? null, |
|
|
assetClass: this.assetProfile.assetClass ?? null, |
|
|
assetSubClass: this.assetProfile.assetSubClass ?? null, |
|
|
assetSubClass: this.assetProfile.assetSubClass ?? null, |
|
|
comment: this.assetProfile?.comment ?? '', |
|
|
comment: this.assetProfile?.comment ?? '', |
|
|
|
|
|
historicalData: { |
|
|
|
|
|
csvString: AssetProfileDialog.HISTORICAL_DATA_TEMPLATE |
|
|
|
|
|
}, |
|
|
name: this.assetProfile.name ?? this.assetProfile.symbol, |
|
|
name: this.assetProfile.name ?? this.assetProfile.symbol, |
|
|
scraperConfiguration: JSON.stringify( |
|
|
scraperConfiguration: JSON.stringify( |
|
|
this.assetProfile?.scraperConfiguration ?? {} |
|
|
this.assetProfile?.scraperConfiguration ?? {} |
|
|
), |
|
|
), |
|
|
symbolMapping: JSON.stringify(this.assetProfile?.symbolMapping ?? {}), |
|
|
symbolMapping: JSON.stringify(this.assetProfile?.symbolMapping ?? {}) |
|
|
historicalData: { |
|
|
|
|
|
csvString: AssetProfileDialog.HISTORICAL_DATA_TEMPLATE |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
this.assetProfileForm.markAsPristine(); |
|
|
this.assetProfileForm.markAsPristine(); |
|
@ -188,12 +188,24 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
}, |
|
|
}, |
|
|
symbol: this.data.symbol |
|
|
symbol: this.data.symbol |
|
|
}) |
|
|
}) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe( |
|
|
|
|
|
takeUntil(this.unsubscribeSubject), |
|
|
|
|
|
catchError(({ error, message }) => { |
|
|
|
|
|
this.snackBar.open(`${error}: ${message[0]}`, undefined, { |
|
|
|
|
|
duration: 3000 |
|
|
|
|
|
}); |
|
|
|
|
|
return EMPTY; |
|
|
|
|
|
}) |
|
|
|
|
|
) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.initialize(); |
|
|
this.initialize(); |
|
|
}); |
|
|
}); |
|
|
} catch (err) { |
|
|
} catch { |
|
|
this.snackBar.open('Unable to parse data', undefined, { duration: 3000 }); |
|
|
this.snackBar.open( |
|
|
|
|
|
$localize`Oops! Could not parse historical data`, |
|
|
|
|
|
undefined, |
|
|
|
|
|
{ duration: 3000 } |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|