Browse Source
Merge pull request #42 from dandevaud/bugfix/several-bugfixes
Added further date ranges
pull/5027/head
dandevaud
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
28 additions and
2 deletions
-
apps/api/src/app/portfolio/portfolio.service.ts
-
apps/api/src/app/user/update-user-setting.dto.ts
-
apps/client/src/app/components/toggle/toggle.component.ts
-
libs/common/src/lib/types/date-range.type.ts
|
|
@ -72,6 +72,7 @@ import { |
|
|
|
set, |
|
|
|
setDayOfYear, |
|
|
|
subDays, |
|
|
|
subMonths, |
|
|
|
subYears |
|
|
|
} from 'date-fns'; |
|
|
|
import { isEmpty, sortBy, uniq, uniqBy } from 'lodash'; |
|
|
@ -1624,6 +1625,28 @@ export class PortfolioService { |
|
|
|
setDayOfYear(new Date().setHours(0, 0, 0, 0), 1) |
|
|
|
]); |
|
|
|
break; |
|
|
|
|
|
|
|
case '1w': |
|
|
|
portfolioStart = max([ |
|
|
|
portfolioStart, |
|
|
|
subDays(new Date().setHours(0, 0, 0, 0), 7) |
|
|
|
]); |
|
|
|
break; |
|
|
|
|
|
|
|
case '1m': |
|
|
|
portfolioStart = max([ |
|
|
|
portfolioStart, |
|
|
|
subMonths(new Date().setHours(0, 0, 0, 0), 1) |
|
|
|
]); |
|
|
|
break; |
|
|
|
|
|
|
|
case '3m': |
|
|
|
portfolioStart = max([ |
|
|
|
portfolioStart, |
|
|
|
subMonths(new Date().setHours(0, 0, 0, 0), 3) |
|
|
|
]); |
|
|
|
break; |
|
|
|
|
|
|
|
case '1y': |
|
|
|
portfolioStart = max([ |
|
|
|
portfolioStart, |
|
|
|
|
|
@ -29,7 +29,7 @@ export class UpdateUserSettingDto { |
|
|
|
@IsOptional() |
|
|
|
colorScheme?: ColorScheme; |
|
|
|
|
|
|
|
@IsIn(<DateRange[]>['1d', '1y', '5y', 'max', 'ytd']) |
|
|
|
@IsIn(<DateRange[]>['1d', '1w', '1m', '3m', '1y', '5y', 'max', 'ytd']) |
|
|
|
@IsOptional() |
|
|
|
dateRange?: DateRange; |
|
|
|
|
|
|
|
|
|
@ -19,6 +19,9 @@ import { ToggleOption } from '@ghostfolio/common/types'; |
|
|
|
export class ToggleComponent implements OnChanges, OnInit { |
|
|
|
public static DEFAULT_DATE_RANGE_OPTIONS: ToggleOption[] = [ |
|
|
|
{ label: $localize`Today`, value: '1d' }, |
|
|
|
{ label: $localize`1W`, value: '1w' }, |
|
|
|
{ label: $localize`1M`, value: '1m' }, |
|
|
|
{ label: $localize`3M`, value: '3m' }, |
|
|
|
{ label: $localize`YTD`, value: 'ytd' }, |
|
|
|
{ label: $localize`1Y`, value: '1y' }, |
|
|
|
{ label: $localize`5Y`, value: '5y' }, |
|
|
|
|
|
@ -1 +1 @@ |
|
|
|
export type DateRange = '1d' | '1y' | '5y' | 'max' | 'ytd'; |
|
|
|
export type DateRange = '1d' | '1w' | '1m' | '3m' | '1y' | '5y' | 'max' | 'ytd'; |
|
|
|