mirror of https://github.com/ghostfolio/ghostfolio
Thomas Kaul
3 years ago
committed by
GitHub
12 changed files with 110 additions and 81 deletions
@ -1,19 +0,0 @@ |
|||||
import { Injectable } from '@nestjs/common'; |
|
||||
import { PortfolioService } from './portfolio.service'; |
|
||||
import { PortfolioServiceNew } from './portfolio.service-new'; |
|
||||
|
|
||||
@Injectable() |
|
||||
export class PortfolioServiceFactory { |
|
||||
public constructor( |
|
||||
private readonly portfolioService: PortfolioService, |
|
||||
private readonly portfolioServiceNew: PortfolioServiceNew |
|
||||
) {} |
|
||||
|
|
||||
public get() { |
|
||||
if (false) { |
|
||||
return this.portfolioServiceNew; |
|
||||
} |
|
||||
|
|
||||
return this.portfolioService; |
|
||||
} |
|
||||
} |
|
@ -0,0 +1,25 @@ |
|||||
|
import type { RequestWithUser } from '@ghostfolio/common/types'; |
||||
|
import { Inject, Injectable } from '@nestjs/common'; |
||||
|
import { REQUEST } from '@nestjs/core'; |
||||
|
|
||||
|
import { PortfolioService } from './portfolio.service'; |
||||
|
import { PortfolioServiceNew } from './portfolio.service-new'; |
||||
|
|
||||
|
@Injectable() |
||||
|
export class PortfolioServiceStrategy { |
||||
|
public constructor( |
||||
|
private readonly portfolioService: PortfolioService, |
||||
|
private readonly portfolioServiceNew: PortfolioServiceNew, |
||||
|
@Inject(REQUEST) private readonly request: RequestWithUser |
||||
|
) {} |
||||
|
|
||||
|
public get() { |
||||
|
if ( |
||||
|
this.request.user?.Settings?.settings?.['isNewCalculationEngine'] === true |
||||
|
) { |
||||
|
return this.portfolioServiceNew; |
||||
|
} |
||||
|
|
||||
|
return this.portfolioService; |
||||
|
} |
||||
|
} |
@ -1,6 +1,11 @@ |
|||||
import { IsBoolean } from 'class-validator'; |
import { IsBoolean, IsOptional } from 'class-validator'; |
||||
|
|
||||
export class UpdateUserSettingDto { |
export class UpdateUserSettingDto { |
||||
@IsBoolean() |
@IsBoolean() |
||||
|
@IsOptional() |
||||
|
isNewCalculationEngine?: boolean; |
||||
|
|
||||
|
@IsBoolean() |
||||
|
@IsOptional() |
||||
isRestrictedView?: boolean; |
isRestrictedView?: boolean; |
||||
} |
} |
||||
|
Loading…
Reference in new issue