diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-29 14:34:04 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-29 14:34:04 +0200 |
commit | 52d9f792b3fee5acce80f948295b59e3ad2073eb (patch) | |
tree | 661f577e9c7196d199b4b49e475ecd2d88e6d7b7 /client/src/app/+my-account/my-account-video-channels | |
parent | 4bbfc6c606c8d3794bae25c64c516120af41f4eb (diff) | |
download | PeerTube-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')
3 files changed, 37 insertions, 4 deletions
diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.html b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.html index 1c08cfdca..f7ca2ec43 100644 --- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.html +++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.html | |||
@@ -1,5 +1,9 @@ | |||
1 | <my-actor-avatar-info | ||
2 | *ngIf="isCreation() === false && videoChannelToUpdate" | ||
3 | [actor]="videoChannelToUpdate" (avatarChange)="onAvatarChange($event)" | ||
4 | ></my-actor-avatar-info> | ||
5 | |||
1 | <div i18n class="form-sub-title" *ngIf="isCreation() === true">Create a video channel</div> | 6 | <div i18n class="form-sub-title" *ngIf="isCreation() === true">Create a video channel</div> |
2 | <div i18n class="form-sub-title" *ngIf="isCreation() === false">Update {{ videoChannel?.displayName }}</div> | ||
3 | 7 | ||
4 | <div *ngIf="error" class="alert alert-danger">{{ error }}</div> | 8 | <div *ngIf="error" class="alert alert-danger">{{ error }}</div> |
5 | 9 | ||
diff --git a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.scss b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.scss index 6fbb8ae8b..86c2598b7 100644 --- a/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.scss +++ b/client/src/app/+my-account/my-account-video-channels/my-account-video-channel-edit.component.scss | |||
@@ -5,6 +5,11 @@ | |||
5 | margin-bottom: 20px; | 5 | margin-bottom: 20px; |
6 | } | 6 | } |
7 | 7 | ||
8 | my-actor-avatar-info { | ||
9 | display: block; | ||
10 | margin-bottom: 20px; | ||
11 | } | ||
12 | |||
8 | input[type=text] { | 13 | input[type=text] { |
9 | @include peertube-input-text(340px); | 14 | @include peertube-input-text(340px); |
10 | 15 | ||
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 | } |