diff options
-rw-r--r-- | client/src/app/+accounts/accounts.component.html | 8 | ||||
-rw-r--r-- | client/src/app/+accounts/accounts.component.scss | 4 | ||||
-rw-r--r-- | client/src/app/+accounts/accounts.component.ts | 37 |
3 files changed, 27 insertions, 22 deletions
diff --git a/client/src/app/+accounts/accounts.component.html b/client/src/app/+accounts/accounts.component.html index 9596d34af..85f7dd30c 100644 --- a/client/src/app/+accounts/accounts.component.html +++ b/client/src/app/+accounts/accounts.component.html | |||
@@ -16,24 +16,24 @@ | |||
16 | </button> | 16 | </button> |
17 | 17 | ||
18 | </div> | 18 | </div> |
19 | <span *ngIf="user?.blocked" [ngbTooltip]="user.blockedReason" class="badge badge-danger" i18n>Banned</span> | 19 | <span *ngIf="accountUser?.blocked" [ngbTooltip]="accountUser.blockedReason" class="badge badge-danger" i18n>Banned</span> |
20 | <span *ngIf="account.mutedByUser" class="badge badge-danger" i18n>Muted</span> | 20 | <span *ngIf="account.mutedByUser" class="badge badge-danger" i18n>Muted</span> |
21 | <span *ngIf="account.mutedServerByUser" class="badge badge-danger" i18n>Instance muted</span> | 21 | <span *ngIf="account.mutedServerByUser" class="badge badge-danger" i18n>Instance muted</span> |
22 | <span *ngIf="account.mutedByInstance" class="badge badge-danger" i18n>Muted by your instance</span> | 22 | <span *ngIf="account.mutedByInstance" class="badge badge-danger" i18n>Muted by your instance</span> |
23 | <span *ngIf="account.mutedServerByInstance" class="badge badge-danger" i18n>Instance muted by your instance</span> | 23 | <span *ngIf="account.mutedServerByInstance" class="badge badge-danger" i18n>Instance muted by your instance</span> |
24 | 24 | ||
25 | <my-user-moderation-dropdown | 25 | <my-user-moderation-dropdown |
26 | buttonSize="small" [account]="account" [user]="user" placement="bottom-left auto" | 26 | buttonSize="small" [account]="account" [user]="accountUser" placement="bottom-left auto" |
27 | (userChanged)="onUserChanged()" (userDeleted)="onUserDeleted()" | 27 | (userChanged)="onUserChanged()" (userDeleted)="onUserDeleted()" |
28 | ></my-user-moderation-dropdown> | 28 | ></my-user-moderation-dropdown> |
29 | </div> | 29 | </div> |
30 | <div class="actor-followers" i18n-title [title]="subscribersDisplayFor(account.followersCount) + ' to the account actor'"> | 30 | <div class="actor-followers" [title]="accountFollowerTitle"> |
31 | {{ subscribersDisplayFor(naiveAggregatedSubscribers) }} | 31 | {{ subscribersDisplayFor(naiveAggregatedSubscribers) }} |
32 | </div> | 32 | </div> |
33 | </div> | 33 | </div> |
34 | 34 | ||
35 | <div class="right-buttons"> | 35 | <div class="right-buttons"> |
36 | <a *ngIf="isManageable" routerLink="/my-account" class="btn btn-outline-tertiary mr-2" i18n>Manage</a> | 36 | <a *ngIf="isAccountManageable" routerLink="/my-account" class="btn btn-outline-tertiary mr-2" i18n>Manage</a> |
37 | <my-subscribe-button *ngIf="videoChannels" [account]="account" [videoChannels]="videoChannels"></my-subscribe-button> | 37 | <my-subscribe-button *ngIf="videoChannels" [account]="account" [videoChannels]="videoChannels"></my-subscribe-button> |
38 | </div> | 38 | </div> |
39 | </div> | 39 | </div> |
diff --git a/client/src/app/+accounts/accounts.component.scss b/client/src/app/+accounts/accounts.component.scss index a06f04055..96484c9d3 100644 --- a/client/src/app/+accounts/accounts.component.scss +++ b/client/src/app/+accounts/accounts.component.scss | |||
@@ -17,12 +17,10 @@ | |||
17 | 17 | ||
18 | a { | 18 | a { |
19 | @include peertube-button-outline; | 19 | @include peertube-button-outline; |
20 | height: auto; | ||
21 | line-height: 32px; | ||
22 | } | 20 | } |
23 | 21 | ||
24 | my-subscribe-button { | 22 | my-subscribe-button { |
25 | height: min-content; | 23 | min-height: 30px; |
26 | } | 24 | } |
27 | } | 25 | } |
28 | 26 | ||
diff --git a/client/src/app/+accounts/accounts.component.ts b/client/src/app/+accounts/accounts.component.ts index 3d486f084..b06ecfe0e 100644 --- a/client/src/app/+accounts/accounts.component.ts +++ b/client/src/app/+accounts/accounts.component.ts | |||
@@ -3,8 +3,8 @@ import { ActivatedRoute } from '@angular/router' | |||
3 | import { AccountService } from '@app/shared/account/account.service' | 3 | import { AccountService } from '@app/shared/account/account.service' |
4 | import { Account } from '@app/shared/account/account.model' | 4 | import { Account } from '@app/shared/account/account.model' |
5 | import { RestExtractor, UserService } from '@app/shared' | 5 | import { RestExtractor, UserService } from '@app/shared' |
6 | import { catchError, distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators' | 6 | import { catchError, distinctUntilChanged, first, map, switchMap, tap } from 'rxjs/operators' |
7 | import { Subscription } from 'rxjs' | 7 | import { forkJoin, Subscription } from 'rxjs' |
8 | import { AuthService, Notifier, RedirectService } from '@app/core' | 8 | import { AuthService, Notifier, RedirectService } from '@app/core' |
9 | import { User, UserRight } from '../../../../shared' | 9 | import { User, UserRight } from '../../../../shared' |
10 | import { I18n } from '@ngx-translate/i18n-polyfill' | 10 | import { I18n } from '@ngx-translate/i18n-polyfill' |
@@ -17,9 +17,12 @@ import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | |||
17 | }) | 17 | }) |
18 | export class AccountsComponent implements OnInit, OnDestroy { | 18 | export class AccountsComponent implements OnInit, OnDestroy { |
19 | account: Account | 19 | account: Account |
20 | user: User | 20 | accountUser: User |
21 | videoChannels: VideoChannel[] = [] | 21 | videoChannels: VideoChannel[] = [] |
22 | 22 | ||
23 | isAccountManageable = false | ||
24 | accountFollowerTitle = '' | ||
25 | |||
23 | private routeSub: Subscription | 26 | private routeSub: Subscription |
24 | 27 | ||
25 | constructor ( | 28 | constructor ( |
@@ -42,6 +45,14 @@ export class AccountsComponent implements OnInit, OnDestroy { | |||
42 | switchMap(accountId => this.accountService.getAccount(accountId)), | 45 | switchMap(accountId => this.accountService.getAccount(accountId)), |
43 | tap(account => { | 46 | tap(account => { |
44 | this.account = account | 47 | this.account = account |
48 | |||
49 | this.isAccountManageable = this.account.userId && this.account.userId === this.authService.getUser().id | ||
50 | |||
51 | this.accountFollowerTitle = this.i18n( | ||
52 | '{{followers}} direct account followers', | ||
53 | { followers: this.subscribersDisplayFor(account.followersCount) } | ||
54 | ) | ||
55 | |||
45 | this.getUserIfNeeded(account) | 56 | this.getUserIfNeeded(account) |
46 | }), | 57 | }), |
47 | switchMap(account => this.videoChannelService.listAccountVideoChannels(account)), | 58 | switchMap(account => this.videoChannelService.listAccountVideoChannels(account)), |
@@ -65,11 +76,6 @@ export class AccountsComponent implements OnInit, OnDestroy { | |||
65 | ) | 76 | ) |
66 | } | 77 | } |
67 | 78 | ||
68 | get isManageable () { | ||
69 | if (!this.authService.isLoggedIn()) return false | ||
70 | return this.user.id === this.authService.getUser().id | ||
71 | } | ||
72 | |||
73 | onUserChanged () { | 79 | onUserChanged () { |
74 | this.getUserIfNeeded(this.account) | 80 | this.getUserIfNeeded(this.account) |
75 | } | 81 | } |
@@ -87,17 +93,18 @@ export class AccountsComponent implements OnInit, OnDestroy { | |||
87 | } | 93 | } |
88 | 94 | ||
89 | private getUserIfNeeded (account: Account) { | 95 | private getUserIfNeeded (account: Account) { |
90 | if (!account.userId) return | 96 | if (!account.userId || !this.authService.isLoggedIn()) return |
91 | if (!this.authService.isLoggedIn()) return | ||
92 | 97 | ||
93 | const user = this.authService.getUser() | 98 | const user = this.authService.getUser() |
94 | if (user.hasRight(UserRight.MANAGE_USERS)) { | 99 | if (user.hasRight(UserRight.MANAGE_USERS)) { |
95 | this.userService.getUser(account.userId) | 100 | forkJoin([ |
96 | .subscribe( | 101 | this.userService.getUser(account.userId), |
97 | user => this.user = user, | 102 | this.authService.userInformationLoaded.pipe(first()) |
103 | ]).subscribe( | ||
104 | ([ accountUser ]) => this.accountUser = accountUser, | ||
98 | 105 | ||
99 | err => this.notifier.error(err.message) | 106 | err => this.notifier.error(err.message) |
100 | ) | 107 | ) |
101 | } | 108 | } |
102 | } | 109 | } |
103 | } | 110 | } |