]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/shared/actor-avatar-info.component.ts
Use height instead of width to represent the video resolution
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / shared / actor-avatar-info.component.ts
CommitLineData
52d9f792
C
1import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core'
2import { AuthService } from '../../core'
3import { ServerService } from '../../core/server'
4import { UserService } from '../../shared/users'
5import { NotificationsService } from 'angular2-notifications'
6import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
7import { 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})
14export 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}