Browse Source

Refactoring

pull/4080/head
Thomas Kaul 9 months ago
parent
commit
1ffac115b4
  1. 20
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts
  2. 2
      apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html
  3. 15
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.component.ts
  4. 0
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.html
  5. 0
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.scss
  6. 2
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/interfaces/interfaces.ts
  7. 31
      libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor.component.ts

20
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.component.ts

@ -77,7 +77,7 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
public ghostfolioScraperApiSymbolPrefix = ghostfolioScraperApiSymbolPrefix; public ghostfolioScraperApiSymbolPrefix = ghostfolioScraperApiSymbolPrefix;
public historicalDataItems: LineChartItem[]; public historicalDataItems: LineChartItem[];
public isBenchmark = false; public isBenchmark = false;
public marketDataDetails: MarketData[] = []; public marketDataItems: MarketData[] = [];
public sectors: { public sectors: {
[name: string]: { name: string; value: number }; [name: string]: { name: string; value: number };
}; };
@ -111,6 +111,8 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
} }
public initialize() { public initialize() {
this.historicalDataItems = undefined;
this.userService.stateChanged this.userService.stateChanged
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe((state) => { .subscribe((state) => {
@ -136,16 +138,14 @@ export class AssetProfileDialog implements OnDestroy, OnInit {
return id === this.assetProfile.id; return id === this.assetProfile.id;
}); });
this.historicalDataItems = this.marketDataDetails.map( this.historicalDataItems = marketData.map(({ date, marketPrice }) => {
({ date, marketPrice }) => { return {
return { date: format(date, DATE_FORMAT),
date: format(date, DATE_FORMAT), value: marketPrice
value: marketPrice };
}; });
}
);
this.marketDataDetails = marketData; this.marketDataItems = marketData;
this.sectors = {}; this.sectors = {};
if (this.assetProfile?.countries?.length > 0) { if (this.assetProfile?.countries?.length > 0) {

2
apps/client/src/app/components/admin-market-data/asset-profile-dialog/asset-profile-dialog.html

@ -84,7 +84,7 @@
[dataSource]="data.dataSource" [dataSource]="data.dataSource"
[dateOfFirstActivity]="assetProfile?.dateOfFirstActivity" [dateOfFirstActivity]="assetProfile?.dateOfFirstActivity"
[locale]="data.locale" [locale]="data.locale"
[marketData]="marketDataDetails" [marketData]="marketDataItems"
[symbol]="data.symbol" [symbol]="data.symbol"
[user]="user" [user]="user"
(marketDataChanged)="onMarketDataChanged($event)" (marketDataChanged)="onMarketDataChanged($event)"

15
libs/ui/src/lib/historical-market-data-editor/market-data-detail-dialog/market-data-detail-dialog.component.ts → libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.component.ts

@ -22,7 +22,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input'; import { MatInputModule } from '@angular/material/input';
import { Subject, takeUntil } from 'rxjs'; import { Subject, takeUntil } from 'rxjs';
import { MarketDataDetailDialogParams } from './interfaces/interfaces'; import { HistoricalMarketDataEditorDialogParams } from './interfaces/interfaces';
@Component({ @Component({
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -37,21 +37,22 @@ import { MarketDataDetailDialogParams } from './interfaces/interfaces';
MatInputModule, MatInputModule,
ReactiveFormsModule ReactiveFormsModule
], ],
selector: 'gf-market-data-detail-dialog', selector: 'gf-historical-market-data-editor-dialog',
schemas: [CUSTOM_ELEMENTS_SCHEMA], schemas: [CUSTOM_ELEMENTS_SCHEMA],
standalone: true, standalone: true,
styleUrls: ['./market-data-detail-dialog.scss'], styleUrls: ['./historical-market-data-editor-dialog.scss'],
templateUrl: 'market-data-detail-dialog.html' templateUrl: 'historical-market-data-editor-dialog.html'
}) })
export class MarketDataDetailDialogComponent implements OnDestroy { export class GfHistoricalMarketDataEditorDialogComponent implements OnDestroy {
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
public constructor( public constructor(
private adminService: AdminService, private adminService: AdminService,
private changeDetectorRef: ChangeDetectorRef, private changeDetectorRef: ChangeDetectorRef,
@Inject(MAT_DIALOG_DATA) public data: MarketDataDetailDialogParams, @Inject(MAT_DIALOG_DATA)
public data: HistoricalMarketDataEditorDialogParams,
private dateAdapter: DateAdapter<any>, private dateAdapter: DateAdapter<any>,
public dialogRef: MatDialogRef<MarketDataDetailDialogComponent>, public dialogRef: MatDialogRef<GfHistoricalMarketDataEditorDialogComponent>,
@Inject(MAT_DATE_LOCALE) private locale: string @Inject(MAT_DATE_LOCALE) private locale: string
) {} ) {}

0
libs/ui/src/lib/historical-market-data-editor/market-data-detail-dialog/market-data-detail-dialog.html → libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.html

0
libs/ui/src/lib/historical-market-data-editor/market-data-detail-dialog/market-data-detail-dialog.scss → libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/historical-market-data-editor-dialog.scss

2
libs/ui/src/lib/historical-market-data-editor/market-data-detail-dialog/interfaces/interfaces.ts → libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor-dialog/interfaces/interfaces.ts

@ -2,7 +2,7 @@ import { User } from '@ghostfolio/common/interfaces';
import { DataSource } from '@prisma/client'; import { DataSource } from '@prisma/client';
export interface MarketDataDetailDialogParams { export interface HistoricalMarketDataEditorDialogParams {
currency: string; currency: string;
dataSource: DataSource; dataSource: DataSource;
dateString: string; dateString: string;

31
libs/ui/src/lib/historical-market-data-editor/historical-market-data-editor.component.ts

@ -43,8 +43,8 @@ import { parse as csvToJson } from 'papaparse';
import { EMPTY, Subject, takeUntil } from 'rxjs'; import { EMPTY, Subject, takeUntil } from 'rxjs';
import { catchError } from 'rxjs/operators'; import { catchError } from 'rxjs/operators';
import { MarketDataDetailDialogParams } from './market-data-detail-dialog/interfaces/interfaces'; import { GfHistoricalMarketDataEditorDialogComponent } from './historical-market-data-editor-dialog/historical-market-data-editor-dialog.component';
import { MarketDataDetailDialogComponent } from './market-data-detail-dialog/market-data-detail-dialog.component'; import { HistoricalMarketDataEditorDialogParams } from './historical-market-data-editor-dialog/interfaces/interfaces';
@Component({ @Component({
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
@ -200,18 +200,21 @@ export class GfHistoricalMarketDataEditorComponent
}) { }) {
const marketPrice = this.marketDataByMonth[yearMonth]?.[day]?.marketPrice; const marketPrice = this.marketDataByMonth[yearMonth]?.[day]?.marketPrice;
const dialogRef = this.dialog.open(MarketDataDetailDialogComponent, { const dialogRef = this.dialog.open(
data: { GfHistoricalMarketDataEditorDialogComponent,
marketPrice, {
currency: this.currency, data: {
dataSource: this.dataSource, marketPrice,
dateString: `${yearMonth}-${day}`, currency: this.currency,
symbol: this.symbol, dataSource: this.dataSource,
user: this.user dateString: `${yearMonth}-${day}`,
} as MarketDataDetailDialogParams, symbol: this.symbol,
height: this.deviceType === 'mobile' ? '98vh' : '80vh', user: this.user
width: this.deviceType === 'mobile' ? '100vw' : '50rem' } as HistoricalMarketDataEditorDialogParams,
}); height: this.deviceType === 'mobile' ? '98vh' : '80vh',
width: this.deviceType === 'mobile' ? '100vw' : '50rem'
}
);
dialogRef dialogRef
.afterClosed() .afterClosed()

Loading…
Cancel
Save