aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-22 15:42:55 +0200
committerChocobozzz <me@florianbigard.com>2018-06-22 15:42:55 +0200
commit0c237b19fdf9c614293c1442f0ab95a81ce05735 (patch)
tree81f7ae4262630da5e8041bd70e2cb856e48253a3 /client/src
parentc4082b8b4e3684baae0172e97297c936d7419f2c (diff)
downloadPeerTube-0c237b19fdf9c614293c1442f0ab95a81ce05735.tar.gz
PeerTube-0c237b19fdf9c614293c1442f0ab95a81ce05735.tar.zst
PeerTube-0c237b19fdf9c614293c1442f0ab95a81ce05735.zip
Fix images size limit
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-settings.component.ts6
-rw-r--r--client/src/app/shared/users/user.model.ts7
-rw-r--r--client/src/app/videos/+video-edit/shared/video-image.component.ts11
3 files changed, 22 insertions, 2 deletions
diff --git a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
index 15f977e58..14293f14c 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
+++ b/client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
@@ -50,6 +50,10 @@ export class MyAccountSettingsComponent implements OnInit {
50 50
51 changeAvatar () { 51 changeAvatar () {
52 const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ] 52 const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ]
53 if (avatarfile.size > this.maxAvatarSize) {
54 this.notificationsService.error('Error', 'This image is too large.')
55 return
56 }
53 57
54 const formData = new FormData() 58 const formData = new FormData()
55 formData.append('avatarfile', avatarfile) 59 formData.append('avatarfile', avatarfile)
@@ -59,7 +63,7 @@ export class MyAccountSettingsComponent implements OnInit {
59 data => { 63 data => {
60 this.notificationsService.success(this.i18n('Success'), this.i18n('Avatar changed.')) 64 this.notificationsService.success(this.i18n('Success'), this.i18n('Avatar changed.'))
61 65
62 this.user.account.avatar = data.avatar 66 this.user.updateAccountAvatar(data.avatar)
63 }, 67 },
64 68
65 err => this.notificationsService.error(this.i18n('Error'), err.message) 69 err => this.notificationsService.error(this.i18n('Error'), err.message)
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts
index b4be2270f..60a0f26df 100644
--- a/client/src/app/shared/users/user.model.ts
+++ b/client/src/app/shared/users/user.model.ts
@@ -9,6 +9,7 @@ import {
9import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' 9import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
10import { Actor } from '@app/shared/actor/actor.model' 10import { Actor } from '@app/shared/actor/actor.model'
11import { Account } from '@app/shared/account/account.model' 11import { Account } from '@app/shared/account/account.model'
12import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
12 13
13export type UserConstructorHash = { 14export type UserConstructorHash = {
14 id: number, 15 id: number,
@@ -84,6 +85,12 @@ export class User implements UserServerModel {
84 this.updateComputedAttributes() 85 this.updateComputedAttributes()
85 } 86 }
86 87
88 updateAccountAvatar (newAccountAvatar: Avatar) {
89 this.account.avatar = newAccountAvatar
90
91 this.updateComputedAttributes()
92 }
93
87 private updateComputedAttributes () { 94 private updateComputedAttributes () {
88 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account) 95 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
89 } 96 }
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 df6565857..25955baaa 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,6 +2,8 @@ import { Component, forwardRef, Input } from '@angular/core'
2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' 2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser' 3import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'
4import { ServerService } from '@app/core' 4import { ServerService } from '@app/core'
5import { NotificationsService } from 'angular2-notifications'
6import { I18n } from '@ngx-translate/i18n-polyfill'
5 7
6@Component({ 8@Component({
7 selector: 'my-video-image', 9 selector: 'my-video-image',
@@ -27,7 +29,9 @@ export class VideoImageComponent implements ControlValueAccessor {
27 29
28 constructor ( 30 constructor (
29 private sanitizer: DomSanitizer, 31 private sanitizer: DomSanitizer,
30 private serverService: ServerService 32 private serverService: ServerService,
33 private notificationsService: NotificationsService,
34 private i18n: I18n
31 ) {} 35 ) {}
32 36
33 get videoImageExtensions () { 37 get videoImageExtensions () {
@@ -42,6 +46,11 @@ export class VideoImageComponent implements ControlValueAccessor {
42 if (event.target.files && event.target.files.length) { 46 if (event.target.files && event.target.files.length) {
43 const [ file ] = event.target.files 47 const [ file ] = event.target.files
44 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
45 this.file = file 54 this.file = file
46 this.propagateChange(this.file) 55 this.propagateChange(this.file)
47 this.updatePreview() 56 this.updatePreview()