Browse Source

Fix review comments

pull/4281/head
Amandee Ellawala 7 months ago
committed by Thomas Kaul
parent
commit
dd32bd629a
  1. 18
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts
  2. 10
      apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html
  3. 1
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor.component.html

18
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.component.ts

@ -7,7 +7,6 @@ import { UserService } from '@ghostfolio/client/services/user/user.service';
import { NUMERICAL_PRECISION_THRESHOLD } from '@ghostfolio/common/config'; import { NUMERICAL_PRECISION_THRESHOLD } from '@ghostfolio/common/config';
import { DATE_FORMAT, downloadAsFile } from '@ghostfolio/common/helper'; import { DATE_FORMAT, downloadAsFile } from '@ghostfolio/common/helper';
import { import {
AdminMarketDataDetails,
DataProviderInfo, DataProviderInfo,
EnhancedSymbolProfile, EnhancedSymbolProfile,
Filter, Filter,
@ -52,7 +51,6 @@ import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
import { AssetProfileDialogParams } from '../admin-market-data/asset-profile-dialog/interfaces/interfaces';
import { HoldingDetailDialogParams } from './interfaces/interfaces'; import { HoldingDetailDialogParams } from './interfaces/interfaces';
@Component({ @Component({
@ -86,7 +84,6 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
public activityForm: FormGroup; public activityForm: FormGroup;
public accounts: Account[]; public accounts: Account[];
public assetClass: string; public assetClass: string;
public assetProfile: AdminMarketDataDetails['assetProfile'];
public assetSubClass: string; public assetSubClass: string;
public averagePrice: number; public averagePrice: number;
public benchmarkDataItems: LineChartItem[]; public benchmarkDataItems: LineChartItem[];
@ -132,7 +129,6 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
public constructor( public constructor(
@Inject(MAT_DIALOG_DATA) public assetProfileData: AssetProfileDialogParams,
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService, private dataService: DataService,
public dialogRef: MatDialogRef<GfHoldingDetailDialogComponent>, public dialogRef: MatDialogRef<GfHoldingDetailDialogComponent>,
@ -399,7 +395,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
}; };
} }
); );
this.fetchMarketData();
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
); );
@ -421,7 +417,6 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
this.changeDetectorRef.markForCheck(); this.changeDetectorRef.markForCheck();
} }
}); });
this.onFetchMarketData();
} }
public onCloneActivity(aActivity: Activity) { public onCloneActivity(aActivity: Activity) {
@ -456,15 +451,14 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
}); });
} }
public onFetchMarketData() { public fetchMarketData() {
this.dataService this.dataService
.fetchMarketDataBySymbol({ .fetchMarketDataBySymbol({
dataSource: this.assetProfileData.dataSource, dataSource: this.data.dataSource,
symbol: this.assetProfileData.symbol symbol: this.data.symbol
}) })
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ assetProfile, marketData }) => { .subscribe(({ marketData }) => {
this.assetProfile = assetProfile;
this.marketDataItems = marketData; this.marketDataItems = marketData;
this.historicalDataItems = marketData.map(({ date, marketPrice }) => { this.historicalDataItems = marketData.map(({ date, marketPrice }) => {
return { return {
@ -478,7 +472,7 @@ export class GfHoldingDetailDialogComponent implements OnDestroy, OnInit {
public onMarketDataChanged(withRefresh: boolean = false) { public onMarketDataChanged(withRefresh: boolean = false) {
if (withRefresh) { if (withRefresh) {
this.onFetchMarketData(); this.fetchMarketData();
} }
} }

10
apps/client/src/app/components/holding-detail-dialog/holding-detail-dialog.html

@ -370,12 +370,12 @@
<div class="d-none d-sm-block ml-2" i18n>Market Data</div> <div class="d-none d-sm-block ml-2" i18n>Market Data</div>
</ng-template> </ng-template>
<gf-historical-market-data-editor <gf-historical-market-data-editor
[currency]="assetProfile?.currency" [currency]="SymbolProfile?.currency"
[dataSource]="assetProfileData.dataSource" [dataSource]="SymbolProfile?.dataSource"
[dateOfFirstActivity]="assetProfile?.dateOfFirstActivity" [dateOfFirstActivity]="firstBuyDate"
[locale]="assetProfileData.locale" [locale]="data.locale"
[marketData]="marketDataItems" [marketData]="marketDataItems"
[symbol]="assetProfileData.symbol" [symbol]="SymbolProfile?.symbol"
[user]="user" [user]="user"
(marketDataChanged)="onMarketDataChanged($event)" (marketDataChanged)="onMarketDataChanged($event)"
/> />

1
libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor.component.html

@ -48,6 +48,7 @@
cdkTextareaAutosize cdkTextareaAutosize
formControlName="csvString" formControlName="csvString"
matInput matInput
rows="2"
type="text" type="text"
(keyup.enter)="$event.stopPropagation()" (keyup.enter)="$event.stopPropagation()"
></textarea> ></textarea>

Loading…
Cancel
Save