Feature/improve market data detail (#511)

* Improve historical data view (hide invalid and future dates)

* Update changelog
This commit is contained in:
Thomas Kaul 2021-12-03 21:24:05 +01:00 committed by GitHub
parent 49f46e1a1e
commit 961774ce9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 4 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased ## Unreleased
### Changed
- Improved the historical data view in the admin control panel (hide invalid and future dates)
### Fixed ### Fixed
- Improved the allocations by currency in combination with cash balances - Improved the allocations by currency in combination with cash balances

View File

@ -6,12 +6,15 @@
*ngFor="let dayItem of days; let i = index" *ngFor="let dayItem of days; let i = index"
class="day" class="day"
[title]=" [title]="
(marketDataByMonth[itemByMonth.key][i + 1]?.date (itemByMonth.key + '-' + (i + 1 < 10 ? '0' + (i + 1) : i + 1)
| date: defaultDateFormat) ?? '' | date: defaultDateFormat) ?? ''
" "
[ngClass]="{ [ngClass]="{
valid: isDateOfInterest(
itemByMonth.key + '-' + (i + 1 < 10 ? '0' + (i + 1) : i + 1)
),
'available cursor-pointer': 'available cursor-pointer':
marketDataByMonth[itemByMonth.key][i + 1]?.day == i + 1 marketDataByMonth[itemByMonth.key][i + 1]?.day === i + 1
}" }"
(click)=" (click)="
marketDataByMonth[itemByMonth.key][i + 1] && marketDataByMonth[itemByMonth.key][i + 1] &&

View File

@ -10,11 +10,14 @@
} }
.day { .day {
background-color: var(--danger);
height: 0.5rem; height: 0.5rem;
margin-right: 0.25rem; margin-right: 0.25rem;
width: 0.5rem; width: 0.5rem;
&.valid {
background-color: var(--danger);
}
&.available { &.available {
background-color: var(--success); background-color: var(--success);
} }

View File

@ -7,8 +7,9 @@ import {
} from '@angular/core'; } from '@angular/core';
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 { MarketData } from '@prisma/client'; import { MarketData } from '@prisma/client';
import { format } from 'date-fns'; import { format, isBefore, isValid, parse } from 'date-fns';
import { DeviceDetectorService } from 'ngx-device-detector'; import { DeviceDetectorService } from 'ngx-device-detector';
import { Subject, takeUntil } from 'rxjs'; import { Subject, takeUntil } from 'rxjs';
@ -59,6 +60,12 @@ export class AdminMarketDataDetailComponent implements OnChanges, OnInit {
} }
} }
public isDateOfInterest(aDateString: string) {
// Date is valid and in the past
const date = parse(aDateString, DATE_FORMAT, new Date());
return isValid(date) && isBefore(date, new Date());
}
public onOpenMarketDataDetail({ date, marketPrice, symbol }: MarketData) { public onOpenMarketDataDetail({ date, marketPrice, symbol }: MarketData) {
const dialogRef = this.dialog.open(MarketDataDetailDialog, { const dialogRef = this.dialog.open(MarketDataDetailDialog, {
data: { data: {