|
|
@ -1,4 +1,3 @@ |
|
|
|
import { NUMERICAL_PRECISION_THRESHOLD } from '@ghostfolio/common/config'; |
|
|
|
import { |
|
|
|
getLocale, |
|
|
|
getNumberFormatDecimal, |
|
|
@ -15,7 +14,6 @@ import { |
|
|
|
ElementRef, |
|
|
|
Input, |
|
|
|
OnChanges, |
|
|
|
OnInit, |
|
|
|
ViewChild |
|
|
|
} from '@angular/core'; |
|
|
|
import { CountUp } from 'countup.js'; |
|
|
@ -27,7 +25,7 @@ import { isNumber } from 'lodash'; |
|
|
|
templateUrl: './portfolio-performance.component.html', |
|
|
|
styleUrls: ['./portfolio-performance.component.scss'] |
|
|
|
}) |
|
|
|
export class PortfolioPerformanceComponent implements OnChanges, OnInit { |
|
|
|
export class PortfolioPerformanceComponent implements OnChanges { |
|
|
|
@Input() deviceType: string; |
|
|
|
@Input() errors: ResponseError['errors']; |
|
|
|
@Input() isAllTimeHigh: boolean; |
|
|
@ -35,6 +33,7 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit { |
|
|
|
@Input() isLoading: boolean; |
|
|
|
@Input() locale = getLocale(); |
|
|
|
@Input() performance: PortfolioPerformance; |
|
|
|
@Input() precision: number; |
|
|
|
@Input() showDetails: boolean; |
|
|
|
@Input() unit: string; |
|
|
|
|
|
|
@ -42,9 +41,9 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit { |
|
|
|
|
|
|
|
public constructor() {} |
|
|
|
|
|
|
|
public ngOnInit() {} |
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
|
this.precision = this.precision >= 0 ? this.precision : 2; |
|
|
|
|
|
|
|
if (this.isLoading) { |
|
|
|
if (this.value?.nativeElement) { |
|
|
|
this.value.nativeElement.innerHTML = ''; |
|
|
@ -53,12 +52,7 @@ export class PortfolioPerformanceComponent implements OnChanges, OnInit { |
|
|
|
if (isNumber(this.performance?.currentValueInBaseCurrency)) { |
|
|
|
new CountUp('value', this.performance?.currentValueInBaseCurrency, { |
|
|
|
decimal: getNumberFormatDecimal(this.locale), |
|
|
|
decimalPlaces: |
|
|
|
this.deviceType === 'mobile' && |
|
|
|
this.performance?.currentValueInBaseCurrency >= |
|
|
|
NUMERICAL_PRECISION_THRESHOLD |
|
|
|
? 0 |
|
|
|
: 2, |
|
|
|
decimalPlaces: this.precision, |
|
|
|
duration: 1, |
|
|
|
separator: getNumberFormatGroup(this.locale) |
|
|
|
}).start(); |
|
|
|