diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-29 14:34:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-29 14:34:04 +0200 |
commit | 52d9f792b3fee5acce80f948295b59e3ad2073eb (patch) | |
tree | 661f577e9c7196d199b4b49e475ecd2d88e6d7b7 /client/src/app/+my-account/shared/actor-avatar-info.component.ts | |
parent | 4bbfc6c606c8d3794bae25c64c516120af41f4eb (diff) | |
download | PeerTube-52d9f792b3fee5acce80f948295b59e3ad2073eb.tar.gz PeerTube-52d9f792b3fee5acce80f948295b59e3ad2073eb.tar.zst PeerTube-52d9f792b3fee5acce80f948295b59e3ad2073eb.zip |
Client: Add ability to update video channel avatar
Diffstat (limited to 'client/src/app/+my-account/shared/actor-avatar-info.component.ts')
-rw-r--r-- | client/src/app/+my-account/shared/actor-avatar-info.component.ts | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/client/src/app/+my-account/shared/actor-avatar-info.component.ts b/client/src/app/+my-account/shared/actor-avatar-info.component.ts new file mode 100644 index 000000000..e0b25ad33 --- /dev/null +++ b/client/src/app/+my-account/shared/actor-avatar-info.component.ts | |||
@@ -0,0 +1,48 @@ | |||
1 | import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core' | ||
2 | import { AuthService } from '../../core' | ||
3 | import { ServerService } from '../../core/server' | ||
4 | import { UserService } from '../../shared/users' | ||
5 | import { NotificationsService } from 'angular2-notifications' | ||
6 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | ||
7 | import { Account } from '@app/shared/account/account.model' | ||
8 | |||
9 | @Component({ | ||
10 | selector: 'my-actor-avatar-info', | ||
11 | templateUrl: './actor-avatar-info.component.html', | ||
12 | styleUrls: [ './actor-avatar-info.component.scss' ] | ||
13 | }) | ||
14 | export class ActorAvatarInfoComponent { | ||
15 | @ViewChild('avatarfileInput') avatarfileInput | ||
16 | |||
17 | @Input() actor: VideoChannel | Account | ||
18 | |||
19 | @Output() avatarChange = new EventEmitter<FormData>() | ||
20 | |||
21 | constructor ( | ||
22 | private userService: UserService, | ||
23 | private authService: AuthService, | ||
24 | private serverService: ServerService, | ||
25 | private notificationsService: NotificationsService | ||
26 | ) {} | ||
27 | |||
28 | onAvatarChange () { | ||
29 | const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ] | ||
30 | if (avatarfile.size > this.maxAvatarSize) { | ||
31 | this.notificationsService.error('Error', 'This image is too large.') | ||
32 | return | ||
33 | } | ||
34 | |||
35 | const formData = new FormData() | ||
36 | formData.append('avatarfile', avatarfile) | ||
37 | |||
38 | this.avatarChange.emit(formData) | ||
39 | } | ||
40 | |||
41 | get maxAvatarSize () { | ||
42 | return this.serverService.getConfig().avatar.file.size.max | ||
43 | } | ||
44 | |||
45 | get avatarExtensions () { | ||
46 | return this.serverService.getConfig().avatar.file.extensions.join(',') | ||
47 | } | ||
48 | } | ||