aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-06-29 14:34:04 +0200
committerChocobozzz <me@florianbigard.com>2018-06-29 14:34:04 +0200
commit52d9f792b3fee5acce80f948295b59e3ad2073eb (patch)
tree661f577e9c7196d199b4b49e475ecd2d88e6d7b7 /client/src/app/+my-account/my-account-video-channels/my-account-video-channel-update.component.ts
parent4bbfc6c606c8d3794bae25c64c516120af41f4eb (diff)
downloadPeerTube-52d9f792b3fee5acce80f948295b59e3ad2073eb.tar.gz
PeerTube-52d9f792b3fee5acce80f948295b59e3ad2073eb.tar.zst
PeerTube-52d9f792b3fee5acce80f948295b59e3ad2073eb.zip
Client: Add ability to update video channel avatar
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.ts30
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 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit' 4import { MyAccountVideoChannelEdit } from './my-account-video-channel-edit'
@@ -6,7 +6,7 @@ import { VideoChannelUpdate } from '../../../../../shared/models/videos'
6import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' 6import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
7import { Subscription } from 'rxjs' 7import { Subscription } from 'rxjs'
8import { VideoChannel } from '@app/shared/video-channel/video-channel.model' 8import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
9import { AuthService } from '@app/core' 9import { AuthService, ServerService } from '@app/core'
10import { I18n } from '@ngx-translate/i18n-polyfill' 10import { I18n } from '@ngx-translate/i18n-polyfill'
11import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 11import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
12import { VideoChannelValidatorsService } from '@app/shared/forms/form-validators/video-channel-validators.service' 12import { 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})
19export class MyAccountVideoChannelUpdateComponent extends MyAccountVideoChannelEdit implements OnInit, OnDestroy { 19export 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 }