From 67ed6552b831df66713bac9e672738796128d33f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 23 Jun 2020 14:10:17 +0200 Subject: Reorganize client shared modules --- .../app/shared/images/global-icon.component.scss | 6 -- .../src/app/shared/images/global-icon.component.ts | 93 ---------------------- .../shared/images/preview-upload.component.html | 11 --- .../shared/images/preview-upload.component.scss | 29 ------- .../app/shared/images/preview-upload.component.ts | 92 --------------------- 5 files changed, 231 deletions(-) delete mode 100644 client/src/app/shared/images/global-icon.component.scss delete mode 100644 client/src/app/shared/images/global-icon.component.ts delete mode 100644 client/src/app/shared/images/preview-upload.component.html delete mode 100644 client/src/app/shared/images/preview-upload.component.scss delete mode 100644 client/src/app/shared/images/preview-upload.component.ts (limited to 'client/src/app/shared/images') diff --git a/client/src/app/shared/images/global-icon.component.scss b/client/src/app/shared/images/global-icon.component.scss deleted file mode 100644 index 6795d6628..000000000 --- a/client/src/app/shared/images/global-icon.component.scss +++ /dev/null @@ -1,6 +0,0 @@ -::ng-deep { - svg { - width: inherit; - height: inherit; - } -} diff --git a/client/src/app/shared/images/global-icon.component.ts b/client/src/app/shared/images/global-icon.component.ts deleted file mode 100644 index 169882685..000000000 --- a/client/src/app/shared/images/global-icon.component.ts +++ /dev/null @@ -1,93 +0,0 @@ -import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core' -import { HooksService } from '@app/core/plugins/hooks.service' - -const icons = { - 'add': require('!!raw-loader?!../../../assets/images/global/add.svg').default, - 'user': require('!!raw-loader?!../../../assets/images/global/user.svg').default, - 'sign-out': require('!!raw-loader?!../../../assets/images/global/sign-out.svg').default, - 'syndication': require('!!raw-loader?!../../../assets/images/global/syndication.svg').default, - 'help': require('!!raw-loader?!../../../assets/images/global/help.svg').default, - 'sparkle': require('!!raw-loader?!../../../assets/images/global/sparkle.svg').default, - 'alert': require('!!raw-loader?!../../../assets/images/global/alert.svg').default, - 'cloud-error': require('!!raw-loader?!../../../assets/images/global/cloud-error.svg').default, - 'clock': require('!!raw-loader?!../../../assets/images/global/clock.svg').default, - 'user-add': require('!!raw-loader?!../../../assets/images/global/user-add.svg').default, - 'no': require('!!raw-loader?!../../../assets/images/global/no.svg').default, - 'cloud-download': require('!!raw-loader?!../../../assets/images/global/cloud-download.svg').default, - 'undo': require('!!raw-loader?!../../../assets/images/global/undo.svg').default, - 'history': require('!!raw-loader?!../../../assets/images/global/history.svg').default, - 'circle-tick': require('!!raw-loader?!../../../assets/images/global/circle-tick.svg').default, - 'cog': require('!!raw-loader?!../../../assets/images/global/cog.svg').default, - 'download': require('!!raw-loader?!../../../assets/images/global/download.svg').default, - 'go': require('!!raw-loader?!../../../assets/images/menu/go.svg').default, - 'edit': require('!!raw-loader?!../../../assets/images/global/edit.svg').default, - 'im-with-her': require('!!raw-loader?!../../../assets/images/global/im-with-her.svg').default, - 'delete': require('!!raw-loader?!../../../assets/images/global/delete.svg').default, - 'server': require('!!raw-loader?!../../../assets/images/global/server.svg').default, - 'cross': require('!!raw-loader?!../../../assets/images/global/cross.svg').default, - 'validate': require('!!raw-loader?!../../../assets/images/global/validate.svg').default, - 'tick': require('!!raw-loader?!../../../assets/images/global/tick.svg').default, - 'repeat': require('!!raw-loader?!../../../assets/images/global/repeat.svg').default, - 'inbox-full': require('!!raw-loader?!../../../assets/images/global/inbox-full.svg').default, - 'dislike': require('!!raw-loader?!../../../assets/images/video/dislike.svg').default, - 'support': require('!!raw-loader?!../../../assets/images/video/support.svg').default, - 'like': require('!!raw-loader?!../../../assets/images/video/like.svg').default, - 'more-horizontal': require('!!raw-loader?!../../../assets/images/global/more-horizontal.svg').default, - 'more-vertical': require('!!raw-loader?!../../../assets/images/global/more-vertical.svg').default, - 'share': require('!!raw-loader?!../../../assets/images/video/share.svg').default, - 'upload': require('!!raw-loader?!../../../assets/images/video/upload.svg').default, - 'playlist-add': require('!!raw-loader?!../../../assets/images/video/playlist-add.svg').default, - 'play': require('!!raw-loader?!../../../assets/images/global/play.svg').default, - 'playlists': require('!!raw-loader?!../../../assets/images/global/playlists.svg').default, - 'globe': require('!!raw-loader?!../../../assets/images/menu/globe.svg').default, - 'home': require('!!raw-loader?!../../../assets/images/menu/home.svg').default, - 'recently-added': require('!!raw-loader?!../../../assets/images/menu/recently-added.svg').default, - 'trending': require('!!raw-loader?!../../../assets/images/menu/trending.svg').default, - 'video-lang': require('!!raw-loader?!../../../assets/images/global/video-lang.svg').default, - 'videos': require('!!raw-loader?!../../../assets/images/global/videos.svg').default, - 'folder': require('!!raw-loader?!../../../assets/images/global/folder.svg').default, - 'subscriptions': require('!!raw-loader?!../../../assets/images/menu/subscriptions.svg').default, - 'language': require('!!raw-loader?!../../../assets/images/menu/language.svg').default, - 'unsensitive': require('!!raw-loader?!../../../assets/images/menu/eye.svg').default, - 'sensitive': require('!!raw-loader?!../../../assets/images/menu/eye-closed.svg').default, - 'p2p': require('!!raw-loader?!../../../assets/images/menu/p2p.svg').default, - 'users': require('!!raw-loader?!../../../assets/images/global/users.svg').default, - 'search': require('!!raw-loader?!../../../assets/images/global/search.svg').default, - 'refresh': require('!!raw-loader?!../../../assets/images/global/refresh.svg').default, - 'npm': require('!!raw-loader?!../../../assets/images/global/npm.svg').default, - 'fullscreen': require('!!raw-loader?!../../../assets/images/global/fullscreen.svg').default, - 'exit-fullscreen': require('!!raw-loader?!../../../assets/images/global/exit-fullscreen.svg').default, - 'robot': require('!!raw-loader?!../../../assets/images/global/robot.svg').default -} - -export type GlobalIconName = keyof typeof icons - -@Component({ - selector: 'my-global-icon', - template: '', - styleUrls: [ './global-icon.component.scss' ], - changeDetection: ChangeDetectionStrategy.OnPush -}) -export class GlobalIconComponent implements OnInit { - @Input() iconName: GlobalIconName - - constructor ( - private el: ElementRef, - private hooks: HooksService - ) { } - - async ngOnInit () { - const nativeElement = this.el.nativeElement as HTMLElement - nativeElement.innerHTML = await this.hooks.wrapFun( - this.getSVGContent.bind(this), - { name: this.iconName }, - 'common', - 'filter:internal.common.svg-icons.get-content.params', - 'filter:internal.common.svg-icons.get-content.result' - ) - } - - private getSVGContent (options: { name: string }) { - return icons[options.name] - } -} diff --git a/client/src/app/shared/images/preview-upload.component.html b/client/src/app/shared/images/preview-upload.component.html deleted file mode 100644 index 7c3a2b588..000000000 --- a/client/src/app/shared/images/preview-upload.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
-
- - - -
-
-
diff --git a/client/src/app/shared/images/preview-upload.component.scss b/client/src/app/shared/images/preview-upload.component.scss deleted file mode 100644 index 88eccd5f7..000000000 --- a/client/src/app/shared/images/preview-upload.component.scss +++ /dev/null @@ -1,29 +0,0 @@ -@import '_variables'; -@import '_mixins'; - -.root { - height: auto; - display: flex; - flex-direction: column; - - .preview-container { - position: relative; - - my-reactive-file { - position: absolute; - bottom: 10px; - left: 10px; - } - - .preview { - object-fit: cover; - border-radius: 4px; - max-width: 100%; - - &.no-image { - border: 2px solid grey; - background-color: pvar(--mainBackgroundColor); - } - } - } -} diff --git a/client/src/app/shared/images/preview-upload.component.ts b/client/src/app/shared/images/preview-upload.component.ts deleted file mode 100644 index 7519734ba..000000000 --- a/client/src/app/shared/images/preview-upload.component.ts +++ /dev/null @@ -1,92 +0,0 @@ -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' - -@Component({ - selector: 'my-preview-upload', - styleUrls: [ './preview-upload.component.scss' ], - templateUrl: './preview-upload.component.html', - providers: [ - { - provide: NG_VALUE_ACCESSOR, - useExisting: forwardRef(() => PreviewUploadComponent), - multi: true - } - ] -}) -export class PreviewUploadComponent implements OnInit, ControlValueAccessor { - @Input() inputLabel: string - @Input() inputName: string - @Input() previewWidth: string - @Input() previewHeight: string - - imageSrc: SafeResourceUrl - allowedExtensionsMessage = '' - maxSizeText: string - - private serverConfig: ServerConfig - private bytesPipe: BytesPipe - private file: Blob - - constructor ( - private sanitizer: DomSanitizer, - private serverService: ServerService, - private i18n: I18n - ) { - this.bytesPipe = new BytesPipe() - this.maxSizeText = this.i18n('max size') - } - - get videoImageExtensions () { - return this.serverConfig.video.image.extensions - } - - get maxVideoImageSize () { - return this.serverConfig.video.image.size.max - } - - get maxVideoImageSizeInBytes () { - return this.bytesPipe.transform(this.maxVideoImageSize) - } - - ngOnInit () { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => this.serverConfig = config) - - this.allowedExtensionsMessage = this.videoImageExtensions.join(', ') - } - - onFileChanged (file: Blob) { - this.file = file - - this.propagateChange(this.file) - this.updatePreview() - } - - propagateChange = (_: any) => { /* empty */ } - - writeValue (file: any) { - this.file = file - this.updatePreview() - } - - registerOnChange (fn: (_: any) => void) { - this.propagateChange = fn - } - - registerOnTouched () { - // Unused - } - - private updatePreview () { - if (this.file) { - const url = URL.createObjectURL(this.file) - this.imageSrc = this.sanitizer.bypassSecurityTrustResourceUrl(url) - } - } -} -- cgit v1.2.3