Remove angular pipes module

pull/3066/head
Chocobozzz 2020-08-11 16:50:00 +02:00
parent f309a156a6
commit 94676e631c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
13 changed files with 51 additions and 29 deletions

View File

@ -96,7 +96,6 @@
"linkifyjs": "^2.1.5",
"lodash-es": "^4.17.4",
"markdown-it": "^11.0.0",
"ngx-pipes": "^2.6.0",
"node-sass": "^4.9.3",
"npm-font-source-sans-pro": "^1.0.2",
"p2p-media-loader-hlsjs": "^0.6.2",

View File

@ -1,10 +1,9 @@
import { BytesPipe } from 'ngx-pipes'
import { SortMeta } from 'primeng/api'
import { Component, OnInit } from '@angular/core'
import { ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
import { RedundancyService } from '@app/shared/shared-main'
import { BytesPipe, RedundancyService } from '@app/shared/shared-main'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
import { VideoRedundanciesTarget, VideoRedundancy } from '@shared/models'
import { VideosRedundancyStats } from '@shared/models/server'

View File

@ -1,4 +1,3 @@
import { BytesPipe } from 'ngx-pipes'
import { Subscription } from 'rxjs'
import { HttpEventType, HttpResponse } from '@angular/common/http'
import { Component, ElementRef, EventEmitter, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
@ -6,7 +5,7 @@ import { Router } from '@angular/router'
import { AuthService, CanComponentDeactivate, Notifier, ServerService, UserService } from '@app/core'
import { scrollToTop } from '@app/helpers'
import { FormValidatorService } from '@app/shared/shared-forms'
import { VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { BytesPipe, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main'
import { LoadingBarService } from '@ngx-loading-bar/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { VideoPrivacy } from '@shared/models'

View File

@ -1,10 +1,10 @@
import { BytesPipe } from 'ngx-pipes'
import { SortMeta } from 'primeng/api'
import { from, Observable, of } from 'rxjs'
import { catchError, concatMap, filter, first, map, shareReplay, throttleTime, toArray } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { AuthService } from '@app/core/auth'
import { BytesPipe } from '@app/shared/shared-main'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { UserLocalStorageKeys } from '@root-helpers/users'
import {

View File

@ -2,9 +2,9 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
import { ServerService } from '@app/core'
import { ServerConfig } from '@shared/models'
import { BytesPipe } from 'ngx-pipes'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { ServerConfig } from '@shared/models'
import { BytesPipe } from '../shared-main'
@Component({
selector: 'my-preview-upload',

View File

@ -1,7 +1,6 @@
import { BytesPipe } from 'ngx-pipes'
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
import { Notifier, ServerService } from '@app/core'
import { Account, VideoChannel } from '@app/shared/shared-main'
import { Account, BytesPipe, VideoChannel } from '@app/shared/shared-main'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { ServerConfig } from '@shared/models'

View File

@ -0,0 +1,34 @@
import { Pipe, PipeTransform } from '@angular/core'
// Thanks: https://github.com/danrevah/ngx-pipes/blob/master/src/ng-pipes/pipes/math/bytes.ts
@Pipe({ name: 'bytes' })
export class BytesPipe implements PipeTransform {
private dictionary: Array<{ max: number; type: string }> = [
{ max: 1024, type: 'B' },
{ max: 1048576, type: 'KB' },
{ max: 1073741824, type: 'MB' },
{ max: 1.0995116e12, type: 'GB' }
]
transform (value: number, precision?: number | undefined): string | number {
const format = this.dictionary.find(d => value < d.max) || this.dictionary[this.dictionary.length - 1]
const calc = value / (format.max / 1024)
const num = precision === undefined
? calc
: applyPrecision(calc, precision)
return `${num} ${format.type}`
}
}
function applyPrecision (num: number, precision: number) {
if (precision <= 0) {
return Math.round(num)
}
const tho = 10 ** precision
return Math.round(num * tho) / tho
}

View File

@ -1,3 +1,4 @@
export * from './bytes.pipe'
export * from './from-now.pipe'
export * from './infinite-scroller.directive'
export * from './number-formatter.pipe'

View File

@ -1,6 +1,6 @@
import { Pipe, PipeTransform } from '@angular/core'
// Thanks: https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts
// Thanks: https://github.com/danrevah/ngx-pipes/blob/master/src/ng-pipes/pipes/math/bytes.ts
@Pipe({ name: 'myNumberFormatter' })
export class NumberFormatterPipe implements PipeTransform {

View File

@ -1,4 +1,3 @@
import { BytesPipe, KeysPipe, NgPipesModule } from 'ngx-pipes'
import { SharedModule as PrimeSharedModule } from 'primeng/api'
import { ClipboardModule } from '@angular/cdk/clipboard'
import { CommonModule, DatePipe } from '@angular/common'
@ -17,7 +16,7 @@ import {
import { I18n } from '@ngx-translate/i18n-polyfill'
import { SharedGlobalIconModule } from '../shared-icons'
import { AccountService, ActorAvatarInfoComponent, AvatarComponent } from './account'
import { FromNowPipe, InfiniteScrollerDirective, NumberFormatterPipe, PeerTubeTemplateDirective } from './angular'
import { FromNowPipe, InfiniteScrollerDirective, NumberFormatterPipe, PeerTubeTemplateDirective, BytesPipe } from './angular'
import { AUTH_INTERCEPTOR_PROVIDER } from './auth'
import { ActionDropdownComponent, ButtonComponent, DeleteButtonComponent, EditButtonComponent } from './buttons'
import { DateToggleComponent } from './date'
@ -47,7 +46,6 @@ import { VideoChannelService } from './video-channel'
ClipboardModule,
PrimeSharedModule,
NgPipesModule,
SharedGlobalIconModule
],
@ -57,8 +55,9 @@ import { VideoChannelService } from './video-channel'
ActorAvatarInfoComponent,
FromNowPipe,
InfiniteScrollerDirective,
NumberFormatterPipe,
BytesPipe,
InfiniteScrollerDirective,
PeerTubeTemplateDirective,
ActionDropdownComponent,
@ -98,15 +97,15 @@ import { VideoChannelService } from './video-channel'
ClipboardModule,
PrimeSharedModule,
BytesPipe,
KeysPipe,
AvatarComponent,
ActorAvatarInfoComponent,
FromNowPipe,
InfiniteScrollerDirective,
BytesPipe,
NumberFormatterPipe,
InfiniteScrollerDirective,
PeerTubeTemplateDirective,
ActionDropdownComponent,

View File

@ -1,8 +1,8 @@
import { Subject } from 'rxjs'
import { BytesPipe } from 'ngx-pipes'
import { Component, Input, OnInit } from '@angular/core'
import { User, UserService } from '@app/core'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { BytesPipe } from '../angular'
@Component({
selector: 'my-user-quota',

View File

@ -1,11 +1,10 @@
import { mapValues, pick } from 'lodash-es'
import { BytesPipe } from 'ngx-pipes'
import { Component, ElementRef, ViewChild } from '@angular/core'
import { AuthService, Notifier } from '@app/core'
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models'
import { NumberFormatterPipe, VideoDetails, VideoService } from '../shared-main'
import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoService } from '../shared-main'
type DownloadType = 'video' | 'subtitles'
type FileMetadata = { [key: string]: { label: string, value: string }}

View File

@ -7873,13 +7873,6 @@ next-tick@~1.0.0:
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=
ngx-pipes@^2.6.0:
version "2.7.5"
resolved "https://registry.yarnpkg.com/ngx-pipes/-/ngx-pipes-2.7.5.tgz#22e2e4b7015ae9103210dfa2dacd6f4ae4411639"
integrity sha512-hlxHzu+snGJ038Z+HdkgEZRlZeE7suDTLWJD1yUP11eAM+xLPJAur1QtvvtZTHRHutOc7Wij1keBtuWIS9D0JQ==
dependencies:
tslib "^2.0.0"
nice-try@^1.0.4:
version "1.0.5"
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"