aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--client/package.json1
-rw-r--r--client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts5
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts3
-rw-r--r--client/src/app/core/users/user.service.ts2
-rw-r--r--client/src/app/shared/shared-forms/preview-upload.component.ts4
-rw-r--r--client/src/app/shared/shared-main/account/actor-avatar-info.component.ts3
-rw-r--r--client/src/app/shared/shared-main/angular/bytes.pipe.ts34
-rw-r--r--client/src/app/shared/shared-main/angular/index.ts1
-rw-r--r--client/src/app/shared/shared-main/angular/number-formatter.pipe.ts2
-rw-r--r--client/src/app/shared/shared-main/shared-main.module.ts13
-rw-r--r--client/src/app/shared/shared-main/users/user-quota.component.ts2
-rw-r--r--client/src/app/shared/shared-video-miniature/video-download.component.ts3
-rw-r--r--client/yarn.lock7
13 files changed, 51 insertions, 29 deletions
diff --git a/client/package.json b/client/package.json
index 50b33d7c3..3c4b9ead4 100644
--- a/client/package.json
+++ b/client/package.json
@@ -96,7 +96,6 @@
96 "linkifyjs": "^2.1.5", 96 "linkifyjs": "^2.1.5",
97 "lodash-es": "^4.17.4", 97 "lodash-es": "^4.17.4",
98 "markdown-it": "^11.0.0", 98 "markdown-it": "^11.0.0",
99 "ngx-pipes": "^2.6.0",
100 "node-sass": "^4.9.3", 99 "node-sass": "^4.9.3",
101 "npm-font-source-sans-pro": "^1.0.2", 100 "npm-font-source-sans-pro": "^1.0.2",
102 "p2p-media-loader-hlsjs": "^0.6.2", 101 "p2p-media-loader-hlsjs": "^0.6.2",
diff --git a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts
index c29f69475..07e2e0ff3 100644
--- a/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts
+++ b/client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts
@@ -1,10 +1,9 @@
1import { BytesPipe } from 'ngx-pipes'
2import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
3import { Component, OnInit } from '@angular/core' 2import { Component, OnInit } from '@angular/core'
4import { ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' 3import { ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
5import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 4import { BytesPipe, RedundancyService } from '@app/shared/shared-main'
6import { RedundancyService } from '@app/shared/shared-main'
7import { I18n } from '@ngx-translate/i18n-polyfill' 5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
8import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models' 7import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models'
9import { VideosRedundancyStats } from '@shared/models/server' 8import { VideosRedundancyStats } from '@shared/models/server'
10 9
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
index 5a18cd78a..e18e3c9a7 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts
@@ -1,4 +1,3 @@
1import { BytesPipe } from 'ngx-pipes'
2import { Subscription } from 'rxjs' 1import { Subscription } from 'rxjs'
3import { HttpEventType, HttpResponse } from '@angular/common/http' 2import { HttpEventType, HttpResponse } from '@angular/common/http'
4import { Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' 3import { Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
@@ -6,7 +5,7 @@ import { Router } from '@angular/router'
6import { AuthService, CanComponentDeactivate, Notifier, ServerService, UserService } from '@app/core' 5import { AuthService, CanComponentDeactivate, Notifier, ServerService, UserService } from '@app/core'
7import { scrollToTop } from '@app/helpers' 6import { scrollToTop } from '@app/helpers'
8import { FormValidatorService } from '@app/shared/shared-forms' 7import { FormValidatorService } from '@app/shared/shared-forms'
9import { VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' 8import { BytesPipe, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
10import { LoadingBarService } from '@ngx-loading-bar/core' 9import { LoadingBarService } from '@ngx-loading-bar/core'
11import { I18n } from '@ngx-translate/i18n-polyfill' 10import { I18n } from '@ngx-translate/i18n-polyfill'
12import { VideoPrivacy } from '@shared/models' 11import { VideoPrivacy } from '@shared/models'
diff --git a/client/src/app/core/users/user.service.ts b/client/src/app/core/users/user.service.ts
index aac2a0206..6e7a48519 100644
--- a/client/src/app/core/users/user.service.ts
+++ b/client/src/app/core/users/user.service.ts
@@ -1,10 +1,10 @@
1import { BytesPipe } from 'ngx-pipes'
2import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
3import { from, Observable, of } from 'rxjs' 2import { from, Observable, of } from 'rxjs'
4import { catchError, concatMap, filter, first, map, shareReplay, throttleTime, toArray } from 'rxjs/operators' 3import { catchError, concatMap, filter, first, map, shareReplay, throttleTime, toArray } from 'rxjs/operators'
5import { HttpClient, HttpParams } from '@angular/common/http' 4import { HttpClient, HttpParams } from '@angular/common/http'
6import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
7import { AuthService } from '@app/core/auth' 6import { AuthService } from '@app/core/auth'
7import { BytesPipe } from '@app/shared/shared-main'
8import { I18n } from '@ngx-translate/i18n-polyfill' 8import { I18n } from '@ngx-translate/i18n-polyfill'
9import { UserLocalStorageKeys } from '@root-helpers/users' 9import { UserLocalStorageKeys } from '@root-helpers/users'
10import { 10import {
diff --git a/client/src/app/shared/shared-forms/preview-upload.component.ts b/client/src/app/shared/shared-forms/preview-upload.component.ts
index 7519734ba..7afff0b31 100644
--- a/client/src/app/shared/shared-forms/preview-upload.component.ts
+++ b/client/src/app/shared/shared-forms/preview-upload.component.ts
@@ -2,9 +2,9 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core'
2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' 2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' 3import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
4import { ServerService } from '@app/core' 4import { ServerService } from '@app/core'
5import { ServerConfig } from '@shared/models'
6import { BytesPipe } from 'ngx-pipes'
7import { I18n } from '@ngx-translate/i18n-polyfill' 5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { ServerConfig } from '@shared/models'
7import { BytesPipe } from '../shared-main'
8 8
9@Component({ 9@Component({
10 selector: 'my-preview-upload', 10 selector: 'my-preview-upload',
diff --git a/client/src/app/shared/shared-main/account/actor-avatar-info.component.ts b/client/src/app/shared/shared-main/account/actor-avatar-info.component.ts
index 0c04ae4a6..1389218cc 100644
--- a/client/src/app/shared/shared-main/account/actor-avatar-info.component.ts
+++ b/client/src/app/shared/shared-main/account/actor-avatar-info.component.ts
@@ -1,7 +1,6 @@
1import { BytesPipe } from 'ngx-pipes'
2import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' 1import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
3import { Notifier, ServerService } from '@app/core' 2import { Notifier, ServerService } from '@app/core'
4import { Account, VideoChannel } from '@app/shared/shared-main' 3import { Account, BytesPipe, VideoChannel } from '@app/shared/shared-main'
5import { I18n } from '@ngx-translate/i18n-polyfill' 4import { I18n } from '@ngx-translate/i18n-polyfill'
6import { ServerConfig } from '@shared/models' 5import { ServerConfig } from '@shared/models'
7 6
diff --git a/client/src/app/shared/shared-main/angular/bytes.pipe.ts b/client/src/app/shared/shared-main/angular/bytes.pipe.ts
new file mode 100644
index 000000000..f4f473568
--- /dev/null
+++ b/client/src/app/shared/shared-main/angular/bytes.pipe.ts
@@ -0,0 +1,34 @@
1import { Pipe, PipeTransform } from '@angular/core'
2
3// Thanks: https://github.com/danrevah/ngx-pipes/blob/master/src/ng-pipes/pipes/math/bytes.ts
4
5@Pipe({ name: 'bytes' })
6export class BytesPipe implements PipeTransform {
7 private dictionary: Array<{ max: number; type: string }> = [
8 { max: 1024, type: 'B' },
9 { max: 1048576, type: 'KB' },
10 { max: 1073741824, type: 'MB' },
11 { max: 1.0995116e12, type: 'GB' }
12 ]
13
14 transform (value: number, precision?: number | undefined): string | number {
15 const format = this.dictionary.find(d => value < d.max) || this.dictionary[this.dictionary.length - 1]
16 const calc = value / (format.max / 1024)
17
18 const num = precision === undefined
19 ? calc
20 : applyPrecision(calc, precision)
21
22 return `${num} ${format.type}`
23 }
24}
25
26function applyPrecision (num: number, precision: number) {
27 if (precision <= 0) {
28 return Math.round(num)
29 }
30
31 const tho = 10 ** precision
32
33 return Math.round(num * tho) / tho
34}
diff --git a/client/src/app/shared/shared-main/angular/index.ts b/client/src/app/shared/shared-main/angular/index.ts
index 3b072fb84..9ba815136 100644
--- a/client/src/app/shared/shared-main/angular/index.ts
+++ b/client/src/app/shared/shared-main/angular/index.ts
@@ -1,3 +1,4 @@
1export * from './bytes.pipe'
1export * from './from-now.pipe' 2export * from './from-now.pipe'
2export * from './infinite-scroller.directive' 3export * from './infinite-scroller.directive'
3export * from './number-formatter.pipe' 4export * from './number-formatter.pipe'
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 8a0756a36..e2eba3a60 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,6 +1,6 @@
1import { Pipe, PipeTransform } from '@angular/core' 1import { Pipe, PipeTransform } from '@angular/core'
2 2
3// Thanks: https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts 3// Thanks: https://github.com/danrevah/ngx-pipes/blob/master/src/ng-pipes/pipes/math/bytes.ts
4 4
5@Pipe({ name: 'myNumberFormatter' }) 5@Pipe({ name: 'myNumberFormatter' })
6export class NumberFormatterPipe implements PipeTransform { 6export class NumberFormatterPipe implements PipeTransform {
diff --git a/client/src/app/shared/shared-main/shared-main.module.ts b/client/src/app/shared/shared-main/shared-main.module.ts
index c6192f6f8..6186db4d6 100644
--- a/client/src/app/shared/shared-main/shared-main.module.ts
+++ b/client/src/app/shared/shared-main/shared-main.module.ts
@@ -1,4 +1,3 @@
1import { BytesPipe, KeysPipe, NgPipesModule } from 'ngx-pipes'
2import { SharedModule as PrimeSharedModule } from 'primeng/api' 1import { SharedModule as PrimeSharedModule } from 'primeng/api'
3import { ClipboardModule } from '@angular/cdk/clipboard' 2import { ClipboardModule } from '@angular/cdk/clipboard'
4import { CommonModule, DatePipe } from '@angular/common' 3import { CommonModule, DatePipe } from '@angular/common'
@@ -17,7 +16,7 @@ import {
17import { I18n } from '@ngx-translate/i18n-polyfill' 16import { I18n } from '@ngx-translate/i18n-polyfill'
18import { SharedGlobalIconModule } from '../shared-icons' 17import { SharedGlobalIconModule } from '../shared-icons'
19import { AccountService, ActorAvatarInfoComponent, AvatarComponent } from './account' 18import { AccountService, ActorAvatarInfoComponent, AvatarComponent } from './account'
20import { FromNowPipe, InfiniteScrollerDirective, NumberFormatterPipe, PeerTubeTemplateDirective } from './angular' 19import { FromNowPipe, InfiniteScrollerDirective, NumberFormatterPipe, PeerTubeTemplateDirective, BytesPipe } from './angular'
21import { AUTH_INTERCEPTOR_PROVIDER } from './auth' 20import { AUTH_INTERCEPTOR_PROVIDER } from './auth'
22import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons' 21import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons'
23import { DateToggleComponent } from './date' 22import { DateToggleComponent } from './date'
@@ -47,7 +46,6 @@ import { VideoChannelService } from './video-channel'
47 ClipboardModule, 46 ClipboardModule,
48 47
49 PrimeSharedModule, 48 PrimeSharedModule,
50 NgPipesModule,
51 49
52 SharedGlobalIconModule 50 SharedGlobalIconModule
53 ], 51 ],
@@ -57,8 +55,9 @@ import { VideoChannelService } from './video-channel'
57 ActorAvatarInfoComponent, 55 ActorAvatarInfoComponent,
58 56
59 FromNowPipe, 57 FromNowPipe,
60 InfiniteScrollerDirective,
61 NumberFormatterPipe, 58 NumberFormatterPipe,
59 BytesPipe,
60 InfiniteScrollerDirective,
62 PeerTubeTemplateDirective, 61 PeerTubeTemplateDirective,
63 62
64 ActionDropdownComponent, 63 ActionDropdownComponent,
@@ -98,15 +97,15 @@ import { VideoChannelService } from './video-channel'
98 ClipboardModule, 97 ClipboardModule,
99 98
100 PrimeSharedModule, 99 PrimeSharedModule,
101 BytesPipe,
102 KeysPipe,
103 100
104 AvatarComponent, 101 AvatarComponent,
105 ActorAvatarInfoComponent, 102 ActorAvatarInfoComponent,
106 103
107 FromNowPipe, 104 FromNowPipe,
108 InfiniteScrollerDirective, 105 BytesPipe,
109 NumberFormatterPipe, 106 NumberFormatterPipe,
107
108 InfiniteScrollerDirective,
110 PeerTubeTemplateDirective, 109 PeerTubeTemplateDirective,
111 110
112 ActionDropdownComponent, 111 ActionDropdownComponent,
diff --git a/client/src/app/shared/shared-main/users/user-quota.component.ts b/client/src/app/shared/shared-main/users/user-quota.component.ts
index a8f56e4d6..6830ad8fe 100644
--- a/client/src/app/shared/shared-main/users/user-quota.component.ts
+++ b/client/src/app/shared/shared-main/users/user-quota.component.ts
@@ -1,8 +1,8 @@
1import { Subject } from 'rxjs' 1import { Subject } from 'rxjs'
2import { BytesPipe } from 'ngx-pipes'
3import { Component, Input, OnInit } from '@angular/core' 2import { Component, Input, OnInit } from '@angular/core'
4import { User, UserService } from '@app/core' 3import { User, UserService } from '@app/core'
5import { I18n } from '@ngx-translate/i18n-polyfill' 4import { I18n } from '@ngx-translate/i18n-polyfill'
5import { BytesPipe } from '../angular'
6 6
7@Component({ 7@Component({
8 selector: 'my-user-quota', 8 selector: 'my-user-quota',
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 4fd06eacf..e3d6a1969 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,11 +1,10 @@
1import { mapValues, pick } from 'lodash-es' 1import { mapValues, pick } from 'lodash-es'
2import { BytesPipe } from 'ngx-pipes'
3import { Component, ElementRef, ViewChild } from '@angular/core' 2import { Component, ElementRef, ViewChild } from '@angular/core'
4import { AuthService, Notifier } from '@app/core' 3import { AuthService, Notifier } from '@app/core'
5import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap' 4import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'
6import { I18n } from '@ngx-translate/i18n-polyfill' 5import { I18n } from '@ngx-translate/i18n-polyfill'
7import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models' 6import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models'
8import { NumberFormatterPipe, VideoDetails, VideoService } from '../shared-main' 7import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoService } from '../shared-main'
9 8
10type DownloadType = 'video' | 'subtitles' 9type DownloadType = 'video' | 'subtitles'
11type FileMetadata = { [key: string]: { label: string, value: string }} 10type FileMetadata = { [key: string]: { label: string, value: string }}
diff --git a/client/yarn.lock b/client/yarn.lock
index 38aea725e..4fe21c1a5 100644
--- a/client/yarn.lock
+++ b/client/yarn.lock
@@ -7873,13 +7873,6 @@ next-tick@~1.0.0:
7873 resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c" 7873 resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
7874 integrity sha1-yobR/ogoFpsBICCOPchCS524NCw= 7874 integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=
7875 7875
7876ngx-pipes@^2.6.0:
7877 version "2.7.5"
7878 resolved "https://registry.yarnpkg.com/ngx-pipes/-/ngx-pipes-2.7.5.tgz#22e2e4b7015ae9103210dfa2dacd6f4ae4411639"
7879 integrity sha512-hlxHzu+snGJ038Z+HdkgEZRlZeE7suDTLWJD1yUP11eAM+xLPJAur1QtvvtZTHRHutOc7Wij1keBtuWIS9D0JQ==
7880 dependencies:
7881 tslib "^2.0.0"
7882
7883nice-try@^1.0.4: 7876nice-try@^1.0.4:
7884 version "1.0.5" 7877 version "1.0.5"
7885 resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" 7878 resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"