From 52d9f792b3fee5acce80f948295b59e3ad2073eb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Jun 2018 14:34:04 +0200 Subject: Client: Add ability to update video channel avatar --- .../shared/actor-avatar-info.component.html | 19 ++++++++ .../shared/actor-avatar-info.component.scss | 51 ++++++++++++++++++++++ .../shared/actor-avatar-info.component.ts | 48 ++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 client/src/app/+my-account/shared/actor-avatar-info.component.html create mode 100644 client/src/app/+my-account/shared/actor-avatar-info.component.scss create mode 100644 client/src/app/+my-account/shared/actor-avatar-info.component.ts (limited to 'client/src/app/+my-account/shared') diff --git a/client/src/app/+my-account/shared/actor-avatar-info.component.html b/client/src/app/+my-account/shared/actor-avatar-info.component.html new file mode 100644 index 000000000..8bdff2f5a --- /dev/null +++ b/client/src/app/+my-account/shared/actor-avatar-info.component.html @@ -0,0 +1,19 @@ + +
+ Avatar + +
+
+
{{ actor.displayName }}
+
{{ actor.name }}
+
+
{{ actor.followersCount }} subscribers
+
+
+ +
+ Change the avatar + +
+
(extensions: {{ avatarExtensions }}, max size: {{ maxAvatarSize | bytes }})
+
\ No newline at end of file diff --git a/client/src/app/+my-account/shared/actor-avatar-info.component.scss b/client/src/app/+my-account/shared/actor-avatar-info.component.scss new file mode 100644 index 000000000..36a792f82 --- /dev/null +++ b/client/src/app/+my-account/shared/actor-avatar-info.component.scss @@ -0,0 +1,51 @@ +@import '_variables'; +@import '_mixins'; + +.actor { + display: flex; + + img { + @include avatar(50px); + + margin-right: 15px; + } + + .actor-info { + .actor-info-names { + display: flex; + align-items: center; + + .actor-info-display-name { + font-size: 20px; + font-weight: $font-bold; + } + + .actor-info-username { + margin-left: 7px; + position: relative; + top: 2px; + font-size: 14px; + color: #777272; + } + } + + .actor-info-followers { + font-size: 15px; + } + } +} + +.button-file { + @include peertube-button-file(160px); + + margin-top: 10px; + margin-bottom: 5px; +} + +.file-max-size { + display: inline-block; + font-size: 13px; + + position: relative; + top: -10px; +} \ No newline at end of file diff --git a/client/src/app/+my-account/shared/actor-avatar-info.component.ts b/client/src/app/+my-account/shared/actor-avatar-info.component.ts new file mode 100644 index 000000000..e0b25ad33 --- /dev/null +++ b/client/src/app/+my-account/shared/actor-avatar-info.component.ts @@ -0,0 +1,48 @@ +import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core' +import { AuthService } from '../../core' +import { ServerService } from '../../core/server' +import { UserService } from '../../shared/users' +import { NotificationsService } from 'angular2-notifications' +import { VideoChannel } from '@app/shared/video-channel/video-channel.model' +import { Account } from '@app/shared/account/account.model' + +@Component({ + selector: 'my-actor-avatar-info', + templateUrl: './actor-avatar-info.component.html', + styleUrls: [ './actor-avatar-info.component.scss' ] +}) +export class ActorAvatarInfoComponent { + @ViewChild('avatarfileInput') avatarfileInput + + @Input() actor: VideoChannel | Account + + @Output() avatarChange = new EventEmitter() + + constructor ( + private userService: UserService, + private authService: AuthService, + private serverService: ServerService, + private notificationsService: NotificationsService + ) {} + + onAvatarChange () { + const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ] + if (avatarfile.size > this.maxAvatarSize) { + this.notificationsService.error('Error', 'This image is too large.') + return + } + + const formData = new FormData() + formData.append('avatarfile', avatarfile) + + this.avatarChange.emit(formData) + } + + get maxAvatarSize () { + return this.serverService.getConfig().avatar.file.size.max + } + + get avatarExtensions () { + return this.serverService.getConfig().avatar.file.extensions.join(',') + } +} -- cgit v1.2.3