|
|
|
@ -5,6 +5,7 @@ import { |
|
|
|
PROPERTY_IS_DATA_GATHERING_ENABLED |
|
|
|
} from '@ghostfolio/common/config'; |
|
|
|
import { UpdateAssetProfileDto } from '@ghostfolio/common/dtos'; |
|
|
|
import { ConfirmationDialogType } from '@ghostfolio/common/enums'; |
|
|
|
import { |
|
|
|
canDeleteAssetProfile, |
|
|
|
DATE_FORMAT, |
|
|
|
@ -278,7 +279,10 @@ export class GfAssetProfileDialogComponent implements OnInit { |
|
|
|
@Inject(MAT_DIALOG_DATA) protected data: AssetProfileDialogParams, |
|
|
|
private dataService: DataService, |
|
|
|
private destroyRef: DestroyRef, |
|
|
|
private dialogRef: MatDialogRef<GfAssetProfileDialogComponent>, |
|
|
|
private dialogRef: MatDialogRef< |
|
|
|
GfAssetProfileDialogComponent, |
|
|
|
AssetProfileIdentifier |
|
|
|
>, |
|
|
|
private formBuilder: FormBuilder, |
|
|
|
private notificationService: NotificationService, |
|
|
|
private snackBar: MatSnackBar, |
|
|
|
@ -469,13 +473,20 @@ export class GfAssetProfileDialogComponent implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
protected onConvertToManualDataSource() { |
|
|
|
this.notificationService.confirm({ |
|
|
|
confirmFn: () => { |
|
|
|
const newAssetProfileIdentifier: AssetProfileIdentifier = { |
|
|
|
dataSource: DataSource.MANUAL, |
|
|
|
symbol: crypto.randomUUID() |
|
|
|
}; |
|
|
|
|
|
|
|
const convertedAssetProfile: UpdateAssetProfileDto = { |
|
|
|
assetClass: this.assetProfile?.assetClass ?? undefined, |
|
|
|
assetSubClass: this.assetProfile?.assetSubClass ?? undefined, |
|
|
|
countries: this.assetProfile?.countries?.map(({ code, weight }) => { |
|
|
|
return { code, weight }; |
|
|
|
}), |
|
|
|
dataSource: DataSource.MANUAL, |
|
|
|
dataSource: newAssetProfileIdentifier.dataSource, |
|
|
|
holdings: this.assetProfile?.holdings?.map( |
|
|
|
({ allocationInPercentage, name }) => { |
|
|
|
return { allocationInPercentage, name }; |
|
|
|
@ -485,7 +496,7 @@ export class GfAssetProfileDialogComponent implements OnInit { |
|
|
|
sectors: this.assetProfile?.sectors?.map(({ name, weight }) => { |
|
|
|
return { name, weight }; |
|
|
|
}), |
|
|
|
symbol: crypto.randomUUID(), |
|
|
|
symbol: newAssetProfileIdentifier.symbol, |
|
|
|
url: this.assetProfile?.url ?? undefined |
|
|
|
}; |
|
|
|
|
|
|
|
@ -513,13 +524,12 @@ export class GfAssetProfileDialogComponent implements OnInit { |
|
|
|
takeUntilDestroyed(this.destroyRef) |
|
|
|
) |
|
|
|
.subscribe(() => { |
|
|
|
const newAssetProfileIdentifier = { |
|
|
|
dataSource: convertedAssetProfile.dataSource, |
|
|
|
symbol: convertedAssetProfile.symbol |
|
|
|
}; |
|
|
|
|
|
|
|
this.dialogRef.close(newAssetProfileIdentifier); |
|
|
|
}); |
|
|
|
}, |
|
|
|
confirmType: ConfirmationDialogType.Primary, |
|
|
|
title: $localize`Do you really want to convert this asset profile to ${DataSource.MANUAL}?` |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
protected onDeleteProfileData({ |
|
|
|
@ -721,13 +731,16 @@ export class GfAssetProfileDialogComponent implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
protected async onSubmitAssetProfileIdentifierForm() { |
|
|
|
const newAssetProfileIdentifier = |
|
|
|
this.assetProfileIdentifierForm.controls.assetProfileIdentifier.value; |
|
|
|
|
|
|
|
if (!newAssetProfileIdentifier?.dataSource) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const assetProfileIdentifier: UpdateAssetProfileDto = { |
|
|
|
dataSource: |
|
|
|
this.assetProfileIdentifierForm.controls.assetProfileIdentifier.value |
|
|
|
?.dataSource ?? undefined, |
|
|
|
symbol: |
|
|
|
this.assetProfileIdentifierForm.controls.assetProfileIdentifier.value |
|
|
|
?.symbol ?? undefined |
|
|
|
dataSource: newAssetProfileIdentifier.dataSource, |
|
|
|
symbol: newAssetProfileIdentifier.symbol |
|
|
|
}; |
|
|
|
|
|
|
|
try { |
|
|
|
@ -742,6 +755,8 @@ export class GfAssetProfileDialogComponent implements OnInit { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.notificationService.confirm({ |
|
|
|
confirmFn: () => { |
|
|
|
this.adminService |
|
|
|
.patchAssetProfile( |
|
|
|
{ |
|
|
|
@ -775,13 +790,12 @@ export class GfAssetProfileDialogComponent implements OnInit { |
|
|
|
takeUntilDestroyed(this.destroyRef) |
|
|
|
) |
|
|
|
.subscribe(() => { |
|
|
|
const newAssetProfileIdentifier = { |
|
|
|
dataSource: assetProfileIdentifier.dataSource, |
|
|
|
symbol: assetProfileIdentifier.symbol |
|
|
|
}; |
|
|
|
|
|
|
|
this.dialogRef.close(newAssetProfileIdentifier); |
|
|
|
}); |
|
|
|
}, |
|
|
|
confirmType: ConfirmationDialogType.Primary, |
|
|
|
title: $localize`Do you really want to convert this asset profile to ${newAssetProfileIdentifier.symbol} (${newAssetProfileIdentifier.dataSource})?` |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
protected onTestMarketData() { |
|
|
|
|