diff options
Diffstat (limited to 'client/src/app/videos/+video-edit/shared/video-image.component.ts')
-rw-r--r-- | client/src/app/videos/+video-edit/shared/video-image.component.ts | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/client/src/app/videos/+video-edit/shared/video-image.component.ts b/client/src/app/videos/+video-edit/shared/video-image.component.ts deleted file mode 100644 index a604cde90..000000000 --- a/client/src/app/videos/+video-edit/shared/video-image.component.ts +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | import { Component, forwardRef, Input } from '@angular/core' | ||
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | ||
3 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' | ||
4 | import { ServerService } from '@app/core' | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-video-image', | ||
8 | styleUrls: [ './video-image.component.scss' ], | ||
9 | templateUrl: './video-image.component.html', | ||
10 | providers: [ | ||
11 | { | ||
12 | provide: NG_VALUE_ACCESSOR, | ||
13 | useExisting: forwardRef(() => VideoImageComponent), | ||
14 | multi: true | ||
15 | } | ||
16 | ] | ||
17 | }) | ||
18 | export class VideoImageComponent implements ControlValueAccessor { | ||
19 | @Input() inputLabel: string | ||
20 | @Input() inputName: string | ||
21 | @Input() previewWidth: string | ||
22 | @Input() previewHeight: string | ||
23 | |||
24 | imageSrc: SafeResourceUrl | ||
25 | |||
26 | private file: File | ||
27 | |||
28 | constructor ( | ||
29 | private sanitizer: DomSanitizer, | ||
30 | private serverService: ServerService | ||
31 | ) {} | ||
32 | |||
33 | get videoImageExtensions () { | ||
34 | return this.serverService.getConfig().video.image.extensions | ||
35 | } | ||
36 | |||
37 | get maxVideoImageSize () { | ||
38 | return this.serverService.getConfig().video.image.size.max | ||
39 | } | ||
40 | |||
41 | onFileChanged (file: File) { | ||
42 | this.file = file | ||
43 | |||
44 | this.propagateChange(this.file) | ||
45 | this.updatePreview() | ||
46 | } | ||
47 | |||
48 | propagateChange = (_: any) => { /* empty */ } | ||
49 | |||
50 | writeValue (file: any) { | ||
51 | this.file = file | ||
52 | this.updatePreview() | ||
53 | } | ||
54 | |||
55 | registerOnChange (fn: (_: any) => void) { | ||
56 | this.propagateChange = fn | ||
57 | } | ||
58 | |||
59 | registerOnTouched () { | ||
60 | // Unused | ||
61 | } | ||
62 | |||
63 | private updatePreview () { | ||
64 | if (this.file) { | ||
65 | const url = URL.createObjectURL(this.file) | ||
66 | this.imageSrc = this.sanitizer.bypassSecurityTrustResourceUrl(url) | ||
67 | } | ||
68 | } | ||
69 | } | ||