X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bmy-account%2Fmy-account-settings%2Fmy-account-settings.component.ts;h=62053d97b2003220cf0f7da19c3bfc3858c66001;hb=6937f26a5e8b17c7a27f267bce2682ab01611f2f;hp=06d1138e72979fb81915cbf335397c2b1ebabbd3;hpb=62e62f118d5da57acd3494fece2e8ed357564ffe;p=github%2FChocobozzz%2FPeerTube.git 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 06d1138e7..62053d97b 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 @@ -2,9 +2,9 @@ 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' @Component({ selector: 'my-account-settings', @@ -12,8 +12,6 @@ import { UserService } from '../../shared/users' styleUrls: [ './my-account-settings.component.scss' ] }) export class MyAccountSettingsComponent implements OnInit { - @ViewChild('avatarfileInput') avatarfileInput - user: User = null userVideoQuota = '0' userVideoQuotaUsed = 0 @@ -21,10 +19,14 @@ export class MyAccountSettingsComponent implements OnInit { constructor ( private userService: UserService, private authService: AuthService, - private serverService: ServerService, - private notificationsService: NotificationsService + private notificationsService: NotificationsService, + private i18n: I18n ) {} + get userInformationLoaded () { + return this.authService.userInformationLoaded + } + ngOnInit () { this.user = this.authService.getUser() @@ -33,7 +35,7 @@ export class MyAccountSettingsComponent implements OnInit { if (this.user.videoQuota !== -1) { this.userVideoQuota = new BytesPipe().transform(this.user.videoQuota, 0).toString() } else { - this.userVideoQuota = 'Unlimited' + this.userVideoQuota = this.i18n('Unlimited') } } ) @@ -42,29 +44,16 @@ export class MyAccountSettingsComponent implements OnInit { .subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed) } - changeAvatar () { - const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ] - - const formData = new FormData() - formData.append('avatarfile', avatarfile) - + onAvatarChange (formData: FormData) { this.userService.changeAvatar(formData) .subscribe( data => { - this.notificationsService.success('Success', 'Avatar changed.') + this.notificationsService.success(this.i18n('Success'), this.i18n('Avatar changed.')) - this.user.account.avatar = data.avatar + this.user.updateAccountAvatar(data.avatar) }, - err => this.notificationsService.error('Error', err.message) + 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(',') - } }