|
@ -6,12 +6,10 @@ import { |
|
|
OnDestroy, |
|
|
OnDestroy, |
|
|
OnInit |
|
|
OnInit |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { FormBuilder } from '@angular/forms'; |
|
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
|
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; |
|
|
import { AdminService } from '@ghostfolio/client/services/admin.service'; |
|
|
import { AdminService } from '@ghostfolio/client/services/admin.service'; |
|
|
import { |
|
|
import { EnhancedSymbolProfile } from '@ghostfolio/common/interfaces'; |
|
|
EnhancedSymbolProfile, |
|
|
|
|
|
UniqueAsset |
|
|
|
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
|
|
|
import { MarketData } from '@prisma/client'; |
|
|
import { MarketData } from '@prisma/client'; |
|
|
import { Subject } from 'rxjs'; |
|
|
import { Subject } from 'rxjs'; |
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
import { takeUntil } from 'rxjs/operators'; |
|
@ -27,6 +25,9 @@ import { AssetProfileDialogParams } from './interfaces/interfaces'; |
|
|
}) |
|
|
}) |
|
|
export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
public assetProfile: EnhancedSymbolProfile; |
|
|
public assetProfile: EnhancedSymbolProfile; |
|
|
|
|
|
public assetProfileForm = this.formBuilder.group({ |
|
|
|
|
|
symbolMapping: '' |
|
|
|
|
|
}); |
|
|
public countries: { |
|
|
public countries: { |
|
|
[code: string]: { name: string; value: number }; |
|
|
[code: string]: { name: string; value: number }; |
|
|
}; |
|
|
}; |
|
@ -41,7 +42,8 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
private adminService: AdminService, |
|
|
private adminService: AdminService, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
private changeDetectorRef: ChangeDetectorRef, |
|
|
public dialogRef: MatDialogRef<AssetProfileDialog>, |
|
|
public dialogRef: MatDialogRef<AssetProfileDialog>, |
|
|
@Inject(MAT_DIALOG_DATA) public data: AssetProfileDialogParams |
|
|
@Inject(MAT_DIALOG_DATA) public data: AssetProfileDialogParams, |
|
|
|
|
|
private formBuilder: FormBuilder |
|
|
) {} |
|
|
) {} |
|
|
|
|
|
|
|
|
public ngOnInit(): void { |
|
|
public ngOnInit(): void { |
|
@ -58,14 +60,25 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public onSubmit() { |
|
|
|
|
|
const assetProfile = { |
|
|
|
|
|
symbolMapping: this.assetProfileForm.controls['symbolMapping'].value |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
console.log(assetProfile); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
public ngOnDestroy() { |
|
|
this.unsubscribeSubject.next(); |
|
|
this.unsubscribeSubject.next(); |
|
|
this.unsubscribeSubject.complete(); |
|
|
this.unsubscribeSubject.complete(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fetchAdminMarketDataBySymbol({ dataSource, symbol }: UniqueAsset) { |
|
|
private initialize() { |
|
|
this.adminService |
|
|
this.adminService |
|
|
.fetchAdminMarketDataBySymbol({ dataSource, symbol }) |
|
|
.fetchAdminMarketDataBySymbol({ |
|
|
|
|
|
dataSource: this.data.dataSource, |
|
|
|
|
|
symbol: this.data.symbol |
|
|
|
|
|
}) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.subscribe(({ assetProfile, marketData }) => { |
|
|
.subscribe(({ assetProfile, marketData }) => { |
|
|
this.assetProfile = assetProfile; |
|
|
this.assetProfile = assetProfile; |
|
@ -91,14 +104,11 @@ export class AssetProfileDialog implements OnDestroy, OnInit { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.assetProfileForm.setValue({ |
|
|
|
|
|
symbolMapping: JSON.stringify(this.assetProfile?.symbolMapping) |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private initialize() { |
|
|
this.changeDetectorRef.markForCheck(); |
|
|
this.fetchAdminMarketDataBySymbol({ |
|
|
|
|
|
dataSource: this.data.dataSource, |
|
|
|
|
|
symbol: this.data.symbol |
|
|
|
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|