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 | 26 |
1 files changed, 7 insertions, 19 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 index 25955baaa..a604cde90 100644 --- a/client/src/app/videos/+video-edit/shared/video-image.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-image.component.ts | |||
@@ -2,8 +2,6 @@ import { Component, forwardRef, Input } from '@angular/core' | |||
2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' | 2 | import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' |
3 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' | 3 | import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' |
4 | import { ServerService } from '@app/core' | 4 | import { ServerService } from '@app/core' |
5 | import { NotificationsService } from 'angular2-notifications' | ||
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
7 | 5 | ||
8 | @Component({ | 6 | @Component({ |
9 | selector: 'my-video-image', | 7 | selector: 'my-video-image', |
@@ -25,36 +23,26 @@ export class VideoImageComponent implements ControlValueAccessor { | |||
25 | 23 | ||
26 | imageSrc: SafeResourceUrl | 24 | imageSrc: SafeResourceUrl |
27 | 25 | ||
28 | private file: Blob | 26 | private file: File |
29 | 27 | ||
30 | constructor ( | 28 | constructor ( |
31 | private sanitizer: DomSanitizer, | 29 | private sanitizer: DomSanitizer, |
32 | private serverService: ServerService, | 30 | private serverService: ServerService |
33 | private notificationsService: NotificationsService, | ||
34 | private i18n: I18n | ||
35 | ) {} | 31 | ) {} |
36 | 32 | ||
37 | get videoImageExtensions () { | 33 | get videoImageExtensions () { |
38 | return this.serverService.getConfig().video.image.extensions.join(',') | 34 | return this.serverService.getConfig().video.image.extensions |
39 | } | 35 | } |
40 | 36 | ||
41 | get maxVideoImageSize () { | 37 | get maxVideoImageSize () { |
42 | return this.serverService.getConfig().video.image.size.max | 38 | return this.serverService.getConfig().video.image.size.max |
43 | } | 39 | } |
44 | 40 | ||
45 | fileChange (event: any) { | 41 | onFileChanged (file: File) { |
46 | if (event.target.files && event.target.files.length) { | 42 | this.file = file |
47 | const [ file ] = event.target.files | ||
48 | |||
49 | if (file.size > this.maxVideoImageSize) { | ||
50 | this.notificationsService.error(this.i18n('Error'), this.i18n('This image is too large.')) | ||
51 | return | ||
52 | } | ||
53 | 43 | ||
54 | this.file = file | 44 | this.propagateChange(this.file) |
55 | this.propagateChange(this.file) | 45 | this.updatePreview() |
56 | this.updatePreview() | ||
57 | } | ||
58 | } | 46 | } |
59 | 47 | ||
60 | propagateChange = (_: any) => { /* empty */ } | 48 | propagateChange = (_: any) => { /* empty */ } |