diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-01-13 09:12:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-13 09:12:55 +0100 |
commit | 1ea7da819e5bfae7b443ed722c18c4165d101439 (patch) | |
tree | 17cea3786dfb3a59a2ad5559de9ebf106a0440a2 /client/src/app/+my-library | |
parent | 75dd1b641f987e1e09dbaa3329e08c6e98a858f3 (diff) | |
download | PeerTube-1ea7da819e5bfae7b443ed722c18c4165d101439.tar.gz PeerTube-1ea7da819e5bfae7b443ed722c18c4165d101439.tar.zst PeerTube-1ea7da819e5bfae7b443ed722c18c4165d101439.zip |
add ability to remove one's avatar for account and channels (#3467)
* add ability to remove one's avatar for account and channels
* add ability to remove one's avatar for account and channels
* only display avatar edition options after input change
Diffstat (limited to 'client/src/app/+my-library')
3 files changed, 22 insertions, 2 deletions
diff --git a/client/src/app/+my-library/+my-video-channels/my-video-channel-edit.component.html b/client/src/app/+my-library/+my-video-channels/my-video-channel-edit.component.html index 5ea000400..735f9e3ba 100644 --- a/client/src/app/+my-library/+my-video-channels/my-video-channel-edit.component.html +++ b/client/src/app/+my-library/+my-video-channels/my-video-channel-edit.component.html | |||
@@ -46,7 +46,7 @@ | |||
46 | 46 | ||
47 | <my-actor-avatar-info | 47 | <my-actor-avatar-info |
48 | *ngIf="!isCreation() && videoChannelToUpdate" | 48 | *ngIf="!isCreation() && videoChannelToUpdate" |
49 | [actor]="videoChannelToUpdate" (avatarChange)="onAvatarChange($event)" | 49 | [actor]="videoChannelToUpdate" (avatarChange)="onAvatarChange($event)" (avatarDelete)="onAvatarDelete()" |
50 | ></my-actor-avatar-info> | 50 | ></my-actor-avatar-info> |
51 | 51 | ||
52 | <div class="form-group"> | 52 | <div class="form-group"> |
diff --git a/client/src/app/+my-library/+my-video-channels/my-video-channel-edit.ts b/client/src/app/+my-library/+my-video-channels/my-video-channel-edit.ts index 09db0df9d..3e20a27ee 100644 --- a/client/src/app/+my-library/+my-video-channels/my-video-channel-edit.ts +++ b/client/src/app/+my-library/+my-video-channels/my-video-channel-edit.ts | |||
@@ -14,6 +14,7 @@ export abstract class MyVideoChannelEdit extends FormReactive { | |||
14 | 14 | ||
15 | // We need this method so angular does not complain in child template that doesn't need this | 15 | // We need this method so angular does not complain in child template that doesn't need this |
16 | onAvatarChange (formData: FormData) { /* empty */ } | 16 | onAvatarChange (formData: FormData) { /* empty */ } |
17 | onAvatarDelete () { /* empty */ } | ||
17 | 18 | ||
18 | // Should be implemented by the child | 19 | // Should be implemented by the child |
19 | isBulkUpdateVideosDisplayed () { | 20 | isBulkUpdateVideosDisplayed () { |
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 c6cb5ade6..6cd1ff503 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 | |||
@@ -11,6 +11,8 @@ import { FormValidatorService } from '@app/shared/shared-forms' | |||
11 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' | 11 | import { VideoChannel, VideoChannelService } from '@app/shared/shared-main' |
12 | import { ServerConfig, VideoChannelUpdate } from '@shared/models' | 12 | import { ServerConfig, VideoChannelUpdate } from '@shared/models' |
13 | import { MyVideoChannelEdit } from './my-video-channel-edit' | 13 | import { MyVideoChannelEdit } from './my-video-channel-edit' |
14 | import { HttpErrorResponse } from '@angular/common/http' | ||
15 | import { uploadErrorHandler } from '@app/helpers' | ||
14 | 16 | ||
15 | @Component({ | 17 | @Component({ |
16 | selector: 'my-video-channel-update', | 18 | selector: 'my-video-channel-update', |
@@ -107,10 +109,27 @@ export class MyVideoChannelUpdateComponent extends MyVideoChannelEdit implements | |||
107 | this.videoChannelToUpdate.updateAvatar(data.avatar) | 109 | this.videoChannelToUpdate.updateAvatar(data.avatar) |
108 | }, | 110 | }, |
109 | 111 | ||
110 | err => this.notifier.error(err.message) | 112 | (err: HttpErrorResponse) => uploadErrorHandler({ |
113 | err, | ||
114 | name: $localize`avatar`, | ||
115 | notifier: this.notifier | ||
116 | }) | ||
111 | ) | 117 | ) |
112 | } | 118 | } |
113 | 119 | ||
120 | onAvatarDelete () { | ||
121 | this.videoChannelService.deleteVideoChannelAvatar(this.videoChannelToUpdate.name) | ||
122 | .subscribe( | ||
123 | data => { | ||
124 | this.notifier.success($localize`Avatar deleted.`) | ||
125 | |||
126 | this.videoChannelToUpdate.resetAvatar() | ||
127 | }, | ||
128 | |||
129 | err => this.notifier.error(err.message) | ||
130 | ) | ||
131 | } | ||
132 | |||
114 | get maxAvatarSize () { | 133 | get maxAvatarSize () { |
115 | return this.serverConfig.avatar.file.size.max | 134 | return this.serverConfig.avatar.file.size.max |
116 | } | 135 | } |