diff options
Diffstat (limited to 'client/src/app/+my-account/shared')
3 files changed, 118 insertions, 0 deletions
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 @@ | |||
1 | <ng-container *ngIf="actor"> | ||
2 | <div class="actor"> | ||
3 | <img [src]="actor.avatarUrl" alt="Avatar" /> | ||
4 | |||
5 | <div class="actor-info"> | ||
6 | <div class="actor-info-names"> | ||
7 | <div class="actor-info-display-name">{{ actor.displayName }}</div> | ||
8 | <div class="actor-info-username">{{ actor.name }}</div> | ||
9 | </div> | ||
10 | <div i18n class="actor-info-followers">{{ actor.followersCount }} subscribers</div> | ||
11 | </div> | ||
12 | </div> | ||
13 | |||
14 | <div class="button-file"> | ||
15 | <span i18n>Change the avatar</span> | ||
16 | <input #avatarfileInput type="file" name="avatarfile" id="avatarfile" [accept]="avatarExtensions" (change)="onAvatarChange()" /> | ||
17 | </div> | ||
18 | <div i18n class="file-max-size">(extensions: {{ avatarExtensions }}, max size: {{ maxAvatarSize | bytes }})</div> | ||
19 | </ng-container> \ 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 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .actor { | ||
5 | display: flex; | ||
6 | |||
7 | img { | ||
8 | @include avatar(50px); | ||
9 | |||
10 | margin-right: 15px; | ||
11 | } | ||
12 | |||
13 | .actor-info { | ||
14 | .actor-info-names { | ||
15 | display: flex; | ||
16 | align-items: center; | ||
17 | |||
18 | .actor-info-display-name { | ||
19 | font-size: 20px; | ||
20 | font-weight: $font-bold; | ||
21 | } | ||
22 | |||
23 | .actor-info-username { | ||
24 | margin-left: 7px; | ||
25 | position: relative; | ||
26 | top: 2px; | ||
27 | font-size: 14px; | ||
28 | color: #777272; | ||
29 | } | ||
30 | } | ||
31 | |||
32 | .actor-info-followers { | ||
33 | font-size: 15px; | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | |||
38 | .button-file { | ||
39 | @include peertube-button-file(160px); | ||
40 | |||
41 | margin-top: 10px; | ||
42 | margin-bottom: 5px; | ||
43 | } | ||
44 | |||
45 | .file-max-size { | ||
46 | display: inline-block; | ||
47 | font-size: 13px; | ||
48 | |||
49 | position: relative; | ||
50 | top: -10px; | ||
51 | } \ 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 @@ | |||
1 | import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core' | ||
2 | import { AuthService } from '../../core' | ||
3 | import { ServerService } from '../../core/server' | ||
4 | import { UserService } from '../../shared/users' | ||
5 | import { NotificationsService } from 'angular2-notifications' | ||
6 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | ||
7 | import { Account } from '@app/shared/account/account.model' | ||
8 | |||
9 | @Component({ | ||
10 | selector: 'my-actor-avatar-info', | ||
11 | templateUrl: './actor-avatar-info.component.html', | ||
12 | styleUrls: [ './actor-avatar-info.component.scss' ] | ||
13 | }) | ||
14 | export class ActorAvatarInfoComponent { | ||
15 | @ViewChild('avatarfileInput') avatarfileInput | ||
16 | |||
17 | @Input() actor: VideoChannel | Account | ||
18 | |||
19 | @Output() avatarChange = new EventEmitter<FormData>() | ||
20 | |||
21 | constructor ( | ||
22 | private userService: UserService, | ||
23 | private authService: AuthService, | ||
24 | private serverService: ServerService, | ||
25 | private notificationsService: NotificationsService | ||
26 | ) {} | ||
27 | |||
28 | onAvatarChange () { | ||
29 | const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ] | ||
30 | if (avatarfile.size > this.maxAvatarSize) { | ||
31 | this.notificationsService.error('Error', 'This image is too large.') | ||
32 | return | ||
33 | } | ||
34 | |||
35 | const formData = new FormData() | ||
36 | formData.append('avatarfile', avatarfile) | ||
37 | |||
38 | this.avatarChange.emit(formData) | ||
39 | } | ||
40 | |||
41 | get maxAvatarSize () { | ||
42 | return this.serverService.getConfig().avatar.file.size.max | ||
43 | } | ||
44 | |||
45 | get avatarExtensions () { | ||
46 | return this.serverService.getConfig().avatar.file.extensions.join(',') | ||
47 | } | ||
48 | } | ||