aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/images
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-23 14:10:17 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-06-23 16:00:49 +0200
commit67ed6552b831df66713bac9e672738796128d33f (patch)
tree59c97d41e0b49d75a90aa3de987968ab9b1ff447 /client/src/app/shared/images
parent0c4bacbff53bc732f5a2677d62a6ead7752e2405 (diff)
downloadPeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.gz
PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.zst
PeerTube-67ed6552b831df66713bac9e672738796128d33f.zip
Reorganize client shared modules
Diffstat (limited to 'client/src/app/shared/images')
-rw-r--r--client/src/app/shared/images/global-icon.component.scss6
-rw-r--r--client/src/app/shared/images/global-icon.component.ts93
-rw-r--r--client/src/app/shared/images/preview-upload.component.html11
-rw-r--r--client/src/app/shared/images/preview-upload.component.scss29
-rw-r--r--client/src/app/shared/images/preview-upload.component.ts92
5 files changed, 0 insertions, 231 deletions
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 @@
1::ng-deep {
2 svg {
3 width: inherit;
4 height: inherit;
5 }
6}
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 @@
1import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core'
2import { HooksService } from '@app/core/plugins/hooks.service'
3
4const icons = {
5 'add': require('!!raw-loader?!../../../assets/images/global/add.svg').default,
6 'user': require('!!raw-loader?!../../../assets/images/global/user.svg').default,
7 'sign-out': require('!!raw-loader?!../../../assets/images/global/sign-out.svg').default,
8 'syndication': require('!!raw-loader?!../../../assets/images/global/syndication.svg').default,
9 'help': require('!!raw-loader?!../../../assets/images/global/help.svg').default,
10 'sparkle': require('!!raw-loader?!../../../assets/images/global/sparkle.svg').default,
11 'alert': require('!!raw-loader?!../../../assets/images/global/alert.svg').default,
12 'cloud-error': require('!!raw-loader?!../../../assets/images/global/cloud-error.svg').default,
13 'clock': require('!!raw-loader?!../../../assets/images/global/clock.svg').default,
14 'user-add': require('!!raw-loader?!../../../assets/images/global/user-add.svg').default,
15 'no': require('!!raw-loader?!../../../assets/images/global/no.svg').default,
16 'cloud-download': require('!!raw-loader?!../../../assets/images/global/cloud-download.svg').default,
17 'undo': require('!!raw-loader?!../../../assets/images/global/undo.svg').default,
18 'history': require('!!raw-loader?!../../../assets/images/global/history.svg').default,
19 'circle-tick': require('!!raw-loader?!../../../assets/images/global/circle-tick.svg').default,
20 'cog': require('!!raw-loader?!../../../assets/images/global/cog.svg').default,
21 'download': require('!!raw-loader?!../../../assets/images/global/download.svg').default,
22 'go': require('!!raw-loader?!../../../assets/images/menu/go.svg').default,
23 'edit': require('!!raw-loader?!../../../assets/images/global/edit.svg').default,
24 'im-with-her': require('!!raw-loader?!../../../assets/images/global/im-with-her.svg').default,
25 'delete': require('!!raw-loader?!../../../assets/images/global/delete.svg').default,
26 'server': require('!!raw-loader?!../../../assets/images/global/server.svg').default,
27 'cross': require('!!raw-loader?!../../../assets/images/global/cross.svg').default,
28 'validate': require('!!raw-loader?!../../../assets/images/global/validate.svg').default,
29 'tick': require('!!raw-loader?!../../../assets/images/global/tick.svg').default,
30 'repeat': require('!!raw-loader?!../../../assets/images/global/repeat.svg').default,
31 'inbox-full': require('!!raw-loader?!../../../assets/images/global/inbox-full.svg').default,
32 'dislike': require('!!raw-loader?!../../../assets/images/video/dislike.svg').default,
33 'support': require('!!raw-loader?!../../../assets/images/video/support.svg').default,
34 'like': require('!!raw-loader?!../../../assets/images/video/like.svg').default,
35 'more-horizontal': require('!!raw-loader?!../../../assets/images/global/more-horizontal.svg').default,
36 'more-vertical': require('!!raw-loader?!../../../assets/images/global/more-vertical.svg').default,
37 'share': require('!!raw-loader?!../../../assets/images/video/share.svg').default,
38 'upload': require('!!raw-loader?!../../../assets/images/video/upload.svg').default,
39 'playlist-add': require('!!raw-loader?!../../../assets/images/video/playlist-add.svg').default,
40 'play': require('!!raw-loader?!../../../assets/images/global/play.svg').default,
41 'playlists': require('!!raw-loader?!../../../assets/images/global/playlists.svg').default,
42 'globe': require('!!raw-loader?!../../../assets/images/menu/globe.svg').default,
43 'home': require('!!raw-loader?!../../../assets/images/menu/home.svg').default,
44 'recently-added': require('!!raw-loader?!../../../assets/images/menu/recently-added.svg').default,
45 'trending': require('!!raw-loader?!../../../assets/images/menu/trending.svg').default,
46 'video-lang': require('!!raw-loader?!../../../assets/images/global/video-lang.svg').default,
47 'videos': require('!!raw-loader?!../../../assets/images/global/videos.svg').default,
48 'folder': require('!!raw-loader?!../../../assets/images/global/folder.svg').default,
49 'subscriptions': require('!!raw-loader?!../../../assets/images/menu/subscriptions.svg').default,
50 'language': require('!!raw-loader?!../../../assets/images/menu/language.svg').default,
51 'unsensitive': require('!!raw-loader?!../../../assets/images/menu/eye.svg').default,
52 'sensitive': require('!!raw-loader?!../../../assets/images/menu/eye-closed.svg').default,
53 'p2p': require('!!raw-loader?!../../../assets/images/menu/p2p.svg').default,
54 'users': require('!!raw-loader?!../../../assets/images/global/users.svg').default,
55 'search': require('!!raw-loader?!../../../assets/images/global/search.svg').default,
56 'refresh': require('!!raw-loader?!../../../assets/images/global/refresh.svg').default,
57 'npm': require('!!raw-loader?!../../../assets/images/global/npm.svg').default,
58 'fullscreen': require('!!raw-loader?!../../../assets/images/global/fullscreen.svg').default,
59 'exit-fullscreen': require('!!raw-loader?!../../../assets/images/global/exit-fullscreen.svg').default,
60 'robot': require('!!raw-loader?!../../../assets/images/global/robot.svg').default
61}
62
63export type GlobalIconName = keyof typeof icons
64
65@Component({
66 selector: 'my-global-icon',
67 template: '',
68 styleUrls: [ './global-icon.component.scss' ],
69 changeDetection: ChangeDetectionStrategy.OnPush
70})
71export class GlobalIconComponent implements OnInit {
72 @Input() iconName: GlobalIconName
73
74 constructor (
75 private el: ElementRef,
76 private hooks: HooksService
77 ) { }
78
79 async ngOnInit () {
80 const nativeElement = this.el.nativeElement as HTMLElement
81 nativeElement.innerHTML = await this.hooks.wrapFun(
82 this.getSVGContent.bind(this),
83 { name: this.iconName },
84 'common',
85 'filter:internal.common.svg-icons.get-content.params',
86 'filter:internal.common.svg-icons.get-content.result'
87 )
88 }
89
90 private getSVGContent (options: { name: string }) {
91 return icons[options.name]
92 }
93}
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 @@
1<div class="root">
2 <div class="preview-container">
3 <my-reactive-file
4 [inputName]="inputName" [inputLabel]="inputLabel" [extensions]="videoImageExtensions" [maxFileSize]="maxVideoImageSize" placement="right"
5 icon="edit" (fileChanged)="onFileChanged($event)" [ngbTooltip]="'(extensions: '+ videoImageExtensions +', '+ maxSizeText +': '+ maxVideoImageSizeInBytes +')'"
6 ></my-reactive-file>
7
8 <img *ngIf="imageSrc" [ngStyle]="{ width: previewWidth, height: previewHeight }" [src]="imageSrc" class="preview" />
9 <div *ngIf="!imageSrc" [ngStyle]="{ width: previewWidth, height: previewHeight }" class="preview no-image"></div>
10 </div>
11</div>
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 @@
1@import '_variables';
2@import '_mixins';
3
4.root {
5 height: auto;
6 display: flex;
7 flex-direction: column;
8
9 .preview-container {
10 position: relative;
11
12 my-reactive-file {
13 position: absolute;
14 bottom: 10px;
15 left: 10px;
16 }
17
18 .preview {
19 object-fit: cover;
20 border-radius: 4px;
21 max-width: 100%;
22
23 &.no-image {
24 border: 2px solid grey;
25 background-color: pvar(--mainBackgroundColor);
26 }
27 }
28 }
29}
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 @@
1import { Component, forwardRef, Input, OnInit } from '@angular/core'
2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
4import { ServerService } from '@app/core'
5import { ServerConfig } from '@shared/models'
6import { BytesPipe } from 'ngx-pipes'
7import { I18n } from '@ngx-translate/i18n-polyfill'
8
9@Component({
10 selector: 'my-preview-upload',
11 styleUrls: [ './preview-upload.component.scss' ],
12 templateUrl: './preview-upload.component.html',
13 providers: [
14 {
15 provide: NG_VALUE_ACCESSOR,
16 useExisting: forwardRef(() => PreviewUploadComponent),
17 multi: true
18 }
19 ]
20})
21export class PreviewUploadComponent implements OnInit, ControlValueAccessor {
22 @Input() inputLabel: string
23 @Input() inputName: string
24 @Input() previewWidth: string
25 @Input() previewHeight: string
26
27 imageSrc: SafeResourceUrl
28 allowedExtensionsMessage = ''
29 maxSizeText: string
30
31 private serverConfig: ServerConfig
32 private bytesPipe: BytesPipe
33 private file: Blob
34
35 constructor (
36 private sanitizer: DomSanitizer,
37 private serverService: ServerService,
38 private i18n: I18n
39 ) {
40 this.bytesPipe = new BytesPipe()
41 this.maxSizeText = this.i18n('max size')
42 }
43
44 get videoImageExtensions () {
45 return this.serverConfig.video.image.extensions
46 }
47
48 get maxVideoImageSize () {
49 return this.serverConfig.video.image.size.max
50 }
51
52 get maxVideoImageSizeInBytes () {
53 return this.bytesPipe.transform(this.maxVideoImageSize)
54 }
55
56 ngOnInit () {
57 this.serverConfig = this.serverService.getTmpConfig()
58 this.serverService.getConfig()
59 .subscribe(config => this.serverConfig = config)
60
61 this.allowedExtensionsMessage = this.videoImageExtensions.join(', ')
62 }
63
64 onFileChanged (file: Blob) {
65 this.file = file
66
67 this.propagateChange(this.file)
68 this.updatePreview()
69 }
70
71 propagateChange = (_: any) => { /* empty */ }
72
73 writeValue (file: any) {
74 this.file = file
75 this.updatePreview()
76 }
77
78 registerOnChange (fn: (_: any) => void) {
79 this.propagateChange = fn
80 }
81
82 registerOnTouched () {
83 // Unused
84 }
85
86 private updatePreview () {
87 if (this.file) {
88 const url = URL.createObjectURL(this.file)
89 this.imageSrc = this.sanitizer.bypassSecurityTrustResourceUrl(url)
90 }
91 }
92}