diff options
Diffstat (limited to 'client/src')
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 { | |||
9 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' | 9 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' |
10 | import { Actor } from '@app/shared/actor/actor.model' | 10 | import { Actor } from '@app/shared/actor/actor.model' |
11 | import { Account } from '@app/shared/account/account.model' | 11 | import { Account } from '@app/shared/account/account.model' |
12 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' | ||
12 | 13 | ||
13 | export type UserConstructorHash = { | 14 | export 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' | |||
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' | ||
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() |