diff options
Diffstat (limited to 'client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts')
-rw-r--r-- | client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts index 1510c5015..6db8ea8d6 100644 --- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts +++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' | 4 | import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' |
@@ -6,7 +6,7 @@ import { VideoChannelUpdate } from '../../../../../shared/models/videos' | |||
6 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | 6 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' |
7 | import { Subscription } from 'rxjs' | 7 | import { Subscription } from 'rxjs' |
8 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | 8 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' |
9 | import { AuthService } from '@app/core' | 9 | import { AuthService, ServerService } from '@app/core' |
10 | import { I18n } from '@ngx-translate/i18n-polyfill' | 10 | import { I18n } from '@ngx-translate/i18n-polyfill' |
11 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 11 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
12 | import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators/video-channel-validators.service' | 12 | import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators/video-channel-validators.service' |
@@ -17,6 +17,8 @@ import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators | |||
17 | styleUrls: [ './my-account-video-channel-edit.component.scss' ] | 17 | styleUrls: [ './my-account-video-channel-edit.component.scss' ] |
18 | }) | 18 | }) |
19 | export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelEdit implements OnInit, OnDestroy { | 19 | export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelEdit implements OnInit, OnDestroy { |
20 | @ViewChild('avatarfileInput') avatarfileInput | ||
21 | |||
20 | error: string | 22 | error: string |
21 | 23 | ||
22 | private videoChannelToUpdate: VideoChannel | 24 | private videoChannelToUpdate: VideoChannel |
@@ -30,7 +32,8 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE | |||
30 | private router: Router, | 32 | private router: Router, |
31 | private route: ActivatedRoute, | 33 | private route: ActivatedRoute, |
32 | private videoChannelService: VideoChannelService, | 34 | private videoChannelService: VideoChannelService, |
33 | private i18n: I18n | 35 | private i18n: I18n, |
36 | private serverService: ServerService | ||
34 | ) { | 37 | ) { |
35 | super() | 38 | super() |
36 | } | 39 | } |
@@ -89,6 +92,27 @@ export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelE | |||
89 | ) | 92 | ) |
90 | } | 93 | } |
91 | 94 | ||
95 | onAvatarChange (formData: FormData) { | ||
96 | this.videoChannelService.changeVideoChannelAvatar(this.videoChannelToUpdate.uuid, formData) | ||
97 | .subscribe( | ||
98 | data => { | ||
99 | this.notificationsService.success(this.i18n('Success'), this.i18n('Avatar changed.')) | ||
100 | |||
101 | this.videoChannelToUpdate.updateAvatar(data.avatar) | ||
102 | }, | ||
103 | |||
104 | err => this.notificationsService.error(this.i18n('Error'), err.message) | ||
105 | ) | ||
106 | } | ||
107 | |||
108 | get maxAvatarSize () { | ||
109 | return this.serverService.getConfig().avatar.file.size.max | ||
110 | } | ||
111 | |||
112 | get avatarExtensions () { | ||
113 | return this.serverService.getConfig().avatar.file.extensions.join(',') | ||
114 | } | ||
115 | |||
92 | isCreation () { | 116 | isCreation () { |
93 | return false | 117 | return false |
94 | } | 118 | } |