1 import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core'
2 import { ServerService } from '../../core/server'
3 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
4 import { Account } from '@app/shared/account/account.model'
5 import { Notifier } from '@app/core'
8 selector: 'my-actor-avatar-info',
9 templateUrl: './actor-avatar-info.component.html',
10 styleUrls: [ './actor-avatar-info.component.scss' ]
12 export class ActorAvatarInfoComponent {
13 @ViewChild('avatarfileInput') avatarfileInput: ElementRef<HTMLInputElement>
15 @Input() actor: VideoChannel | Account
17 @Output() avatarChange = new EventEmitter<FormData>()
20 private serverService: ServerService,
21 private notifier: Notifier
25 const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ]
26 if (avatarfile.size > this.maxAvatarSize) {
27 this.notifier.error('Error', 'This image is too large.')
31 const formData = new FormData()
32 formData.append('avatarfile', avatarfile)
34 this.avatarChange.emit(formData)
37 get maxAvatarSize () {
38 return this.serverService.getConfig().avatar.file.size.max
41 get avatarExtensions () {
42 return this.serverService.getConfig().avatar.file.extensions.join(',')