aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/app/shared/shared-main/angular/number-formatter.pipe.ts17
-rw-r--r--client/src/app/shared/shared-video-miniature/video-download.component.ts5
2 files changed, 13 insertions, 9 deletions
diff --git a/client/src/app/shared/shared-main/angular/number-formatter.pipe.ts b/client/src/app/shared/shared-main/angular/number-formatter.pipe.ts
index 5e6ccfa16..8badb1573 100644
--- a/client/src/app/shared/shared-main/angular/number-formatter.pipe.ts
+++ b/client/src/app/shared/shared-main/angular/number-formatter.pipe.ts
@@ -1,14 +1,10 @@
1import { Pipe, PipeTransform } from '@angular/core' 1import { formatNumber } from '@angular/common'
2import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core'
2 3
3// Thanks: https://github.com/danrevah/ngx-pipes/blob/master/src/ng-pipes/pipes/math/bytes.ts 4// Thanks: https://github.com/danrevah/ngx-pipes/blob/master/src/ng-pipes/pipes/math/bytes.ts
4 5
5@Pipe({ name: 'myNumberFormatter' }) 6@Pipe({ name: 'myNumberFormatter' })
6export class NumberFormatterPipe implements PipeTransform { 7export class NumberFormatterPipe implements PipeTransform {
7 private dictionary: Array<{max: number, type: string}> = [
8 { max: 1000, type: '' },
9 { max: 1000000, type: 'K' },
10 { max: 1000000000, type: 'M' }
11 ]
12 8
13 /** 9 /**
14 * @param x number 10 * @param x number
@@ -21,6 +17,13 @@ export class NumberFormatterPipe implements PipeTransform {
21 return +f 17 return +f
22 } 18 }
23 19
20 private dictionary: Array<{max: number, type: string}> = [
21 { max: 1000, type: '' },
22 { max: 1000000, type: 'K' },
23 { max: 1000000000, type: 'M' }
24 ]
25 constructor (@Inject(LOCALE_ID) private localeId: string) {}
26
24 transform (value: number) { 27 transform (value: number) {
25 const format = this.dictionary.find(d => value < d.max) || this.dictionary[this.dictionary.length - 1] 28 const format = this.dictionary.find(d => value < d.max) || this.dictionary[this.dictionary.length - 1]
26 const calc = value / (format.max / 1000) 29 const calc = value / (format.max / 1000)
@@ -28,7 +31,7 @@ export class NumberFormatterPipe implements PipeTransform {
28 const decimalPart = NumberFormatterPipe.getDecimalForNumber(calc) 31 const decimalPart = NumberFormatterPipe.getDecimalForNumber(calc)
29 32
30 return integralPart < 10 && decimalPart > 0 33 return integralPart < 10 && decimalPart > 0
31 ? `${integralPart}.${decimalPart}${format.type}` 34 ? formatNumber(parseFloat(`${integralPart}.${decimalPart}`), this.localeId) + format.type
32 : `${integralPart}${format.type}` 35 : `${integralPart}${format.type}`
33 } 36 }
34} 37}
diff --git a/client/src/app/shared/shared-video-miniature/video-download.component.ts b/client/src/app/shared/shared-video-miniature/video-download.component.ts
index 99838f712..70b27b105 100644
--- a/client/src/app/shared/shared-video-miniature/video-download.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-download.component.ts
@@ -1,5 +1,5 @@
1import { mapValues, pick } from 'lodash-es' 1import { mapValues, pick } from 'lodash-es'
2import { Component, ElementRef, ViewChild } from '@angular/core' 2import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core'
3import { AuthService, Notifier } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
4import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap' 4import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'
5import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models' 5import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models'
@@ -34,13 +34,14 @@ export class VideoDownloadComponent {
34 private numbersPipe: NumberFormatterPipe 34 private numbersPipe: NumberFormatterPipe
35 35
36 constructor ( 36 constructor (
37 @Inject(LOCALE_ID) private localeId: string,
37 private notifier: Notifier, 38 private notifier: Notifier,
38 private modalService: NgbModal, 39 private modalService: NgbModal,
39 private videoService: VideoService, 40 private videoService: VideoService,
40 private auth: AuthService 41 private auth: AuthService
41 ) { 42 ) {
42 this.bytesPipe = new BytesPipe() 43 this.bytesPipe = new BytesPipe()
43 this.numbersPipe = new NumberFormatterPipe() 44 this.numbersPipe = new NumberFormatterPipe(this.localeId)
44 } 45 }
45 46
46 get typeText () { 47 get typeText () {