|
@ -8,6 +8,7 @@ import { |
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
import { MatDialog } from '@angular/material/dialog'; |
|
|
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config'; |
|
|
import { DEFAULT_DATE_FORMAT } from '@ghostfolio/common/config'; |
|
|
import { DATE_FORMAT } from '@ghostfolio/common/helper'; |
|
|
import { DATE_FORMAT } from '@ghostfolio/common/helper'; |
|
|
|
|
|
import { LineChartItem } from '@ghostfolio/ui/line-chart/interfaces/line-chart.interface'; |
|
|
import { DataSource, MarketData } from '@prisma/client'; |
|
|
import { DataSource, MarketData } from '@prisma/client'; |
|
|
import { format, isBefore, isValid, parse } from 'date-fns'; |
|
|
import { format, isBefore, isValid, parse } from 'date-fns'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
|
import { DeviceDetectorService } from 'ngx-device-detector'; |
|
@ -29,6 +30,7 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit { |
|
|
public days = Array(31); |
|
|
public days = Array(31); |
|
|
public defaultDateFormat = DEFAULT_DATE_FORMAT; |
|
|
public defaultDateFormat = DEFAULT_DATE_FORMAT; |
|
|
public deviceType: string; |
|
|
public deviceType: string; |
|
|
|
|
|
public historicalDataItems: LineChartItem[]; |
|
|
public marketDataByMonth: { |
|
|
public marketDataByMonth: { |
|
|
[yearMonth: string]: { [day: string]: MarketData & { day: number } }; |
|
|
[yearMonth: string]: { [day: string]: MarketData & { day: number } }; |
|
|
} = {}; |
|
|
} = {}; |
|
@ -45,6 +47,12 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit { |
|
|
public ngOnInit() {} |
|
|
public ngOnInit() {} |
|
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
public ngOnChanges() { |
|
|
|
|
|
this.historicalDataItems = this.marketData.map((marketDataItem) => { |
|
|
|
|
|
return { |
|
|
|
|
|
date: format(marketDataItem.date, DATE_FORMAT), |
|
|
|
|
|
value: marketDataItem.marketPrice |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
this.marketDataByMonth = {}; |
|
|
this.marketDataByMonth = {}; |
|
|
|
|
|
|
|
|
for (const marketDataItem of this.marketData) { |
|
|
for (const marketDataItem of this.marketData) { |
|
|