]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
Merge pull request #1105 from BO41/unused-imports
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-settings / my-account-settings.component.ts
index 14293f14c40e51749cbc5c15db00b197b20c644a..62053d97b2003220cf0f7da19c3bfc3858c66001 100644 (file)
@@ -2,7 +2,6 @@ import { Component, OnInit, ViewChild } from '@angular/core'
 import { NotificationsService } from 'angular2-notifications'
 import { BytesPipe } from 'ngx-pipes'
 import { AuthService } from '../../core'
-import { ServerService } from '../../core/server'
 import { User } from '../../shared'
 import { UserService } from '../../shared/users'
 import { I18n } from '@ngx-translate/i18n-polyfill'
@@ -13,8 +12,6 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
   styleUrls: [ './my-account-settings.component.scss' ]
 })
 export class MyAccountSettingsComponent implements OnInit {
-  @ViewChild('avatarfileInput') avatarfileInput
-
   user: User = null
   userVideoQuota = '0'
   userVideoQuotaUsed = 0
@@ -22,7 +19,6 @@ export class MyAccountSettingsComponent implements OnInit {
   constructor (
     private userService: UserService,
     private authService: AuthService,
-    private serverService: ServerService,
     private notificationsService: NotificationsService,
     private i18n: I18n
   ) {}
@@ -48,16 +44,7 @@ export class MyAccountSettingsComponent implements OnInit {
       .subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed)
   }
 
-  changeAvatar () {
-    const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ]
-    if (avatarfile.size > this.maxAvatarSize) {
-      this.notificationsService.error('Error', 'This image is too large.')
-      return
-    }
-
-    const formData = new FormData()
-    formData.append('avatarfile', avatarfile)
-
+  onAvatarChange (formData: FormData) {
     this.userService.changeAvatar(formData)
       .subscribe(
         data => {
@@ -69,12 +56,4 @@ export class MyAccountSettingsComponent implements OnInit {
         err => this.notificationsService.error(this.i18n('Error'), err.message)
       )
   }
-
-  get maxAvatarSize () {
-    return this.serverService.getConfig().avatar.file.size.max
-  }
-
-  get avatarExtensions () {
-    return this.serverService.getConfig().avatar.file.extensions.join(',')
-  }
 }