diff options
Diffstat (limited to 'client/src/app/+my-library/+my-video-channels/my-video-channel-update.component.ts')
-rw-r--r-- | client/src/app/+my-library/+my-video-channels/my-video-channel-update.component.ts | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/client/src/app/+my-library/+my-video-channels/my-video-channel-update.component.ts b/client/src/app/+my-library/+my-video-channels/my-video-channel-update.component.ts index 6cd1ff503..22935a87a 100644 --- a/client/src/app/+my-library/+my-video-channels/my-video-channel-update.component.ts +++ b/client/src/app/+my-library/+my-video-channels/my-video-channel-update.component.ts | |||
@@ -1,7 +1,9 @@ | |||
1 | import { Subscription } from 'rxjs' | 1 | import { Subscription } from 'rxjs' |
2 | import { HttpErrorResponse } from '@angular/common/http' | ||
2 | import { Component, OnDestroy, OnInit } from '@angular/core' | 3 | import { Component, OnDestroy, OnInit } from '@angular/core' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { AuthService, Notifier, ServerService } from '@app/core' | 5 | import { AuthService, Notifier, ServerService } from '@app/core' |
6 | import { uploadErrorHandler } from '@app/helpers' | ||
5 | import { | 7 | import { |
6 | VIDEO_CHANNEL_DESCRIPTION_VALIDATOR, | 8 | VIDEO_CHANNEL_DESCRIPTION_VALIDATOR, |
7 | VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, | 9 | VIDEO_CHANNEL_DISPLAY_NAME_VALIDATOR, |
@@ -11,8 +13,6 @@ import { FormValidatorService } from '@app/shared/shared-forms' | |||
11 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' | 13 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' |
12 | import { ServerConfig, VideoChannelUpdate } from '@shared/models' | 14 | import { ServerConfig, VideoChannelUpdate } from '@shared/models' |
13 | import { MyVideoChannelEdit } from './my-video-channel-edit' | 15 | import { MyVideoChannelEdit } from './my-video-channel-edit' |
14 | import { HttpErrorResponse } from '@angular/common/http' | ||
15 | import { uploadErrorHandler } from '@app/helpers' | ||
16 | 16 | ||
17 | @Component({ | 17 | @Component({ |
18 | selector: 'my-video-channel-update', | 18 | selector: 'my-video-channel-update', |
@@ -101,7 +101,7 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements | |||
101 | } | 101 | } |
102 | 102 | ||
103 | onAvatarChange (formData: FormData) { | 103 | onAvatarChange (formData: FormData) { |
104 | this.videoChannelService.changeVideoChannelAvatar(this.videoChannelToUpdate.name, formData) | 104 | this.videoChannelService.changeVideoChannelImage(this.videoChannelToUpdate.name, formData, 'avatar') |
105 | .subscribe( | 105 | .subscribe( |
106 | data => { | 106 | data => { |
107 | this.notifier.success($localize`Avatar changed.`) | 107 | this.notifier.success($localize`Avatar changed.`) |
@@ -118,7 +118,7 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements | |||
118 | } | 118 | } |
119 | 119 | ||
120 | onAvatarDelete () { | 120 | onAvatarDelete () { |
121 | this.videoChannelService.deleteVideoChannelAvatar(this.videoChannelToUpdate.name) | 121 | this.videoChannelService.deleteVideoChannelImage(this.videoChannelToUpdate.name, 'avatar') |
122 | .subscribe( | 122 | .subscribe( |
123 | data => { | 123 | data => { |
124 | this.notifier.success($localize`Avatar deleted.`) | 124 | this.notifier.success($localize`Avatar deleted.`) |
@@ -130,6 +130,36 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements | |||
130 | ) | 130 | ) |
131 | } | 131 | } |
132 | 132 | ||
133 | onBannerChange (formData: FormData) { | ||
134 | this.videoChannelService.changeVideoChannelImage(this.videoChannelToUpdate.name, formData, 'banner') | ||
135 | .subscribe( | ||
136 | data => { | ||
137 | this.notifier.success($localize`Banner changed.`) | ||
138 | |||
139 | this.videoChannelToUpdate.updateBanner(data.banner) | ||
140 | }, | ||
141 | |||
142 | (err: HttpErrorResponse) => uploadErrorHandler({ | ||
143 | err, | ||
144 | name: $localize`banner`, | ||
145 | notifier: this.notifier | ||
146 | }) | ||
147 | ) | ||
148 | } | ||
149 | |||
150 | onBannerDelete () { | ||
151 | this.videoChannelService.deleteVideoChannelImage(this.videoChannelToUpdate.name, 'banner') | ||
152 | .subscribe( | ||
153 | data => { | ||
154 | this.notifier.success($localize`Banner deleted.`) | ||
155 | |||
156 | this.videoChannelToUpdate.resetBanner() | ||
157 | }, | ||
158 | |||
159 | err => this.notifier.error(err.message) | ||
160 | ) | ||
161 | } | ||
162 | |||
133 | get maxAvatarSize () { | 163 | get maxAvatarSize () { |
134 | return this.serverConfig.avatar.file.size.max | 164 | return this.serverConfig.avatar.file.size.max |
135 | } | 165 | } |