Add AccountAvatarComponent (#3965)
* refactor(client): create account-avatar component * continue implement account-avatar * fix review comments
This commit is contained in:
parent
266947e5ef
commit
fbdcd4ec9f
|
@ -2,7 +2,7 @@
|
|||
<div class="account-info">
|
||||
|
||||
<div class="account-avatar-row">
|
||||
<img class="account-avatar" [src]="account.avatarUrl" alt="Avatar" />
|
||||
<my-account-avatar [account]="account" size="120"></my-account-avatar>
|
||||
|
||||
<div>
|
||||
<div class="section-label" i18n>PEERTUBE ACCOUNT</div>
|
||||
|
|
|
@ -10,6 +10,7 @@ import { AccountVideoChannelsComponent } from './account-video-channels/account-
|
|||
import { AccountVideosComponent } from './account-videos/account-videos.component'
|
||||
import { AccountsRoutingModule } from './accounts-routing.module'
|
||||
import { AccountsComponent } from './accounts.component'
|
||||
import { SharedAccountAvatarModule } from '../shared/shared-account-avatar/shared-account-avatar.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -20,7 +21,8 @@ import { AccountsComponent } from './accounts.component'
|
|||
SharedUserSubscriptionModule,
|
||||
SharedModerationModule,
|
||||
SharedVideoMiniatureModule,
|
||||
SharedGlobalIconModule
|
||||
SharedGlobalIconModule,
|
||||
SharedAccountAvatarModule
|
||||
],
|
||||
|
||||
declarations: [
|
||||
|
|
|
@ -39,6 +39,7 @@ import { JobService, LogsComponent, LogsService, SystemComponent } from './syste
|
|||
import { DebugComponent, DebugService } from './system/debug'
|
||||
import { JobsComponent } from './system/jobs/jobs.component'
|
||||
import { UserCreateComponent, UserListComponent, UserPasswordComponent, UsersComponent, UserUpdateComponent } from './users'
|
||||
import { SharedAccountAvatarModule } from '../shared/shared-account-avatar/shared-account-avatar.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -50,6 +51,7 @@ import { UserCreateComponent, UserListComponent, UserPasswordComponent, UsersCom
|
|||
SharedGlobalIconModule,
|
||||
SharedAbuseListModule,
|
||||
SharedVideoCommentModule,
|
||||
SharedAccountAvatarModule,
|
||||
SharedActorImageModule,
|
||||
|
||||
TableModule,
|
||||
|
|
|
@ -34,12 +34,7 @@
|
|||
<td>
|
||||
<a [href]="accountBlock.blockedAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">
|
||||
<div class="chip two-lines">
|
||||
<img
|
||||
class="avatar"
|
||||
[src]="accountBlock.blockedAccount.avatar?.path"
|
||||
(error)="switchToDefaultAvatar($event)"
|
||||
alt="Avatar"
|
||||
>
|
||||
<my-account-avatar [account]="accountBlock.blockedAccount"></my-account-avatar>
|
||||
<div>
|
||||
{{ accountBlock.blockedAccount.displayName }}
|
||||
<span class="text-muted">{{ accountBlock.blockedAccount.nameWithHost }}</span>
|
||||
|
|
|
@ -86,12 +86,8 @@
|
|||
<td>
|
||||
<a [href]="videoComment.account.localUrl" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">
|
||||
<div class="chip two-lines">
|
||||
<img
|
||||
class="avatar"
|
||||
[src]="videoComment.accountAvatarUrl"
|
||||
alt=""
|
||||
>
|
||||
<div>
|
||||
<my-account-avatar [account]="videoComment.account"></my-account-avatar>
|
||||
<div>
|
||||
{{ videoComment.account.displayName }}
|
||||
<span>{{ videoComment.by }}</span>
|
||||
</div>
|
||||
|
|
|
@ -106,13 +106,8 @@
|
|||
<td *ngIf="isSelected('username')">
|
||||
<a i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer" [routerLink]="[ '/accounts/' + user.username ]">
|
||||
<div class="chip two-lines">
|
||||
<img
|
||||
class="avatar"
|
||||
[src]="user?.account?.avatar?.path"
|
||||
(error)="switchToDefaultAvatar($event)"
|
||||
alt="Avatar"
|
||||
>
|
||||
<div>
|
||||
<my-account-avatar [account]="user?.account"></my-account-avatar>
|
||||
<div>
|
||||
<span class="user-table-primary-text">{{ user.account.displayName }}</span>
|
||||
<span class="text-muted">{{ user.username }}</span>
|
||||
</div>
|
||||
|
|
|
@ -163,10 +163,6 @@ export class UserListComponent extends RestTable implements OnInit {
|
|||
this.loadData()
|
||||
}
|
||||
|
||||
switchToDefaultAvatar ($event: Event) {
|
||||
($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL()
|
||||
}
|
||||
|
||||
async unbanUsers (users: User[]) {
|
||||
const res = await this.confirmService.confirm($localize`Do you really want to unban ${users.length} users?`, $localize`Unban`)
|
||||
if (res === false) return
|
||||
|
|
|
@ -23,6 +23,7 @@ import { MyAccountNotificationPreferencesComponent } from './my-account-settings
|
|||
import { MyAccountProfileComponent } from './my-account-settings/my-account-profile/my-account-profile.component'
|
||||
import { MyAccountSettingsComponent } from './my-account-settings/my-account-settings.component'
|
||||
import { MyAccountComponent } from './my-account.component'
|
||||
import { SharedAccountAvatarModule } from '../shared/shared-account-avatar/shared-account-avatar.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -39,6 +40,7 @@ import { MyAccountComponent } from './my-account.component'
|
|||
SharedGlobalIconModule,
|
||||
SharedAbuseListModule,
|
||||
SharedShareModal,
|
||||
SharedAccountAvatarModule,
|
||||
SharedActorImageModule
|
||||
],
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import { MyVideoPlaylistUpdateComponent } from './my-video-playlists/my-video-pl
|
|||
import { MyVideoPlaylistsComponent } from './my-video-playlists/my-video-playlists.component'
|
||||
import { VideoChangeOwnershipComponent } from './my-videos/modals/video-change-ownership.component'
|
||||
import { MyVideosComponent } from './my-videos/my-videos.component'
|
||||
import { SharedAccountAvatarModule } from '../shared/shared-account-avatar/shared-account-avatar.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -45,7 +46,8 @@ import { MyVideosComponent } from './my-videos/my-videos.component'
|
|||
SharedGlobalIconModule,
|
||||
SharedAbuseListModule,
|
||||
SharedShareModal,
|
||||
SharedVideoLiveModule
|
||||
SharedVideoLiveModule,
|
||||
SharedAccountAvatarModule
|
||||
],
|
||||
|
||||
declarations: [
|
||||
|
|
|
@ -37,12 +37,7 @@
|
|||
<td>
|
||||
<a [href]="videoChangeOwnership.initiatorAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">
|
||||
<div class="chip two-lines">
|
||||
<img
|
||||
class="avatar"
|
||||
[src]="videoChangeOwnership.initiatorAccount.avatar?.path"
|
||||
(error)="switchToDefaultAvatar($event)"
|
||||
alt="Avatar"
|
||||
>
|
||||
<my-account-avatar [account]="videoChangeOwnership.initiatorAccount"></my-account-avatar>
|
||||
<div>
|
||||
{{ videoChangeOwnership.initiatorAccount.displayName }}
|
||||
<span class="text-muted">{{ videoChangeOwnership.initiatorAccount.nameWithHost }}</span>
|
||||
|
|
|
@ -43,10 +43,6 @@ export class MyOwnershipComponent extends RestTable implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
switchToDefaultAvatar ($event: Event) {
|
||||
($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL()
|
||||
}
|
||||
|
||||
openAcceptModal (videoChangeOwnership: VideoChangeOwnership) {
|
||||
this.myAccountAcceptOwnershipComponent.show(videoChangeOwnership)
|
||||
}
|
||||
|
|
|
@ -23,10 +23,8 @@
|
|||
<div class="section-label" i18n>OWNER ACCOUNT</div>
|
||||
|
||||
<div class="avatar-row">
|
||||
<a [routerLink]="getAccountUrl()" title="View account" i18n-title>
|
||||
<img class="account-avatar" [src]="videoChannel.ownerAvatarUrl" alt="Owner account avatar" />
|
||||
</a>
|
||||
|
||||
<my-account-avatar [account]="videoChannel.ownerAccount" size="120"></my-account-avatar>
|
||||
|
||||
<div class="actor-info">
|
||||
<h4>
|
||||
<a [routerLink]="getAccountUrl()" title="View account" i18n-title>{{ videoChannel.ownerAccount.displayName }}</a>
|
||||
|
|
|
@ -10,6 +10,7 @@ import { VideoChannelPlaylistsComponent } from './video-channel-playlists/video-
|
|||
import { VideoChannelVideosComponent } from './video-channel-videos/video-channel-videos.component'
|
||||
import { VideoChannelsRoutingModule } from './video-channels-routing.module'
|
||||
import { VideoChannelsComponent } from './video-channels.component'
|
||||
import { SharedAccountAvatarModule } from '../shared/shared-account-avatar/shared-account-avatar.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -21,7 +22,8 @@ import { VideoChannelsComponent } from './video-channels.component'
|
|||
SharedVideoMiniatureModule,
|
||||
SharedUserSubscriptionModule,
|
||||
SharedGlobalIconModule,
|
||||
SharedSupportModal
|
||||
SharedSupportModal,
|
||||
SharedAccountAvatarModule
|
||||
],
|
||||
|
||||
declarations: [
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<form novalidate [formGroup]="form" (ngSubmit)="formValidated()">
|
||||
<div class="avatar-and-textarea">
|
||||
<img [src]="getAvatarUrl()" alt="Avatar" />
|
||||
<my-account-avatar [account]="user?.account" size="25"></my-account-avatar>
|
||||
|
||||
<div class="form-group">
|
||||
<textarea i18n-placeholder placeholder="Add comment..." myAutoResize
|
||||
|
|
|
@ -9,9 +9,7 @@ form {
|
|||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
|
||||
img {
|
||||
@include avatar(25px);
|
||||
|
||||
my-account-avatar {
|
||||
vertical-align: top;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
|
|
@ -143,11 +143,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
|
|||
return window.location.href
|
||||
}
|
||||
|
||||
getAvatarUrl () {
|
||||
if (this.user) return this.user.accountAvatarUrl
|
||||
return Account.GET_DEFAULT_AVATAR_URL()
|
||||
}
|
||||
|
||||
gotoLogin () {
|
||||
this.hideModals()
|
||||
this.router.navigate([ '/login' ])
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
<div *ngIf="isCommentDisplayed()" class="root-comment">
|
||||
<div class="left">
|
||||
<a *ngIf="!comment.isDeleted" [href]="comment.account.url" target="_blank" rel="noopener noreferrer">
|
||||
<img
|
||||
class="comment-avatar"
|
||||
[src]="comment.accountAvatarUrl"
|
||||
(error)="switchToDefaultAvatar($event)"
|
||||
alt="Avatar"
|
||||
/>
|
||||
</a>
|
||||
|
||||
<my-account-avatar *ngIf="!comment.isDeleted" [account]="comment.account"></my-account-avatar>
|
||||
<div class="vertical-border"></div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -23,10 +23,6 @@
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.comment-avatar {
|
||||
@include avatar(36px);
|
||||
}
|
||||
|
||||
.comment {
|
||||
flex-grow: 1;
|
||||
// Fix word-wrap with flex
|
||||
|
|
|
@ -131,10 +131,6 @@ export class VideoCommentComponent implements OnInit, OnChanges {
|
|||
)
|
||||
}
|
||||
|
||||
switchToDefaultAvatar ($event: Event) {
|
||||
($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL()
|
||||
}
|
||||
|
||||
isCommentDisplayed () {
|
||||
// Not deleted
|
||||
return !this.comment.isDeleted ||
|
||||
|
|
|
@ -4,15 +4,11 @@
|
|||
<img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" class="channel-avatar" />
|
||||
</a>
|
||||
|
||||
<a [routerLink]="[ '/accounts', video.byAccount ]" [title]="accountLinkTitle">
|
||||
<img [src]="video.accountAvatarUrl" i18n-alt alt="Account avatar" />
|
||||
</a>
|
||||
</ng-container>
|
||||
<my-account-avatar [account]="video.account"></my-account-avatar>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="!isChannelAvatarNull() && genericChannel">
|
||||
<a [routerLink]="[ '/accounts', video.byAccount ]" [title]="accountLinkTitle">
|
||||
<img [src]="video.accountAvatarUrl" i18n-alt alt="Account avatar" />
|
||||
</a>
|
||||
<my-account-avatar [account]="video.account"></my-account-avatar>
|
||||
|
||||
<a [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
|
||||
<img [src]="video.videoChannelAvatarUrl" i18n-alt alt="Channel avatar" class="channel-avatar" />
|
||||
|
@ -20,8 +16,6 @@
|
|||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="isChannelAvatarNull()">
|
||||
<a [routerLink]="[ '/accounts', video.byAccount ]" [title]="accountLinkTitle">
|
||||
<img [src]="video.accountAvatarUrl" i18n-alt alt="Account avatar" />
|
||||
</a>
|
||||
<my-account-avatar [account]="video.account"></my-account-avatar>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
|
|
@ -17,10 +17,11 @@ import { VideoCommentsComponent } from './comment/video-comments.component'
|
|||
import { PlayerStylesComponent } from './player-styles.component'
|
||||
import { RecommendationsModule } from './recommendations/recommendations.module'
|
||||
import { TimestampRouteTransformerDirective } from './timestamp-route-transformer.directive'
|
||||
import { VideoAvatarChannelComponent } from './video-avatar-channel.component'
|
||||
import { VideoWatchPlaylistComponent } from './video-watch-playlist.component'
|
||||
import { VideoWatchRoutingModule } from './video-watch-routing.module'
|
||||
import { VideoWatchComponent } from './video-watch.component'
|
||||
import { SharedAccountAvatarModule } from '../../shared/shared-account-avatar/shared-account-avatar.module'
|
||||
import { VideoAvatarChannelComponent } from './video-avatar-channel.component'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -37,7 +38,8 @@ import { VideoWatchComponent } from './video-watch.component'
|
|||
SharedVideoCommentModule,
|
||||
SharedShareModal,
|
||||
SharedVideoModule,
|
||||
SharedSupportModal
|
||||
SharedSupportModal,
|
||||
SharedAccountAvatarModule
|
||||
],
|
||||
|
||||
declarations: [
|
||||
|
@ -47,6 +49,7 @@ import { VideoWatchComponent } from './video-watch.component'
|
|||
VideoCommentsComponent,
|
||||
VideoCommentAddComponent,
|
||||
VideoCommentComponent,
|
||||
VideoAvatarChannelComponent,
|
||||
|
||||
VideoAvatarChannelComponent,
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import { SharedGlobalIconModule } from './shared/shared-icons'
|
|||
import { SharedInstanceModule } from './shared/shared-instance'
|
||||
import { SharedMainModule } from './shared/shared-main'
|
||||
import { SharedUserInterfaceSettingsModule } from './shared/shared-user-settings'
|
||||
import { SharedAccountAvatarModule } from './shared/shared-account-avatar/shared-account-avatar.module'
|
||||
|
||||
registerLocaleData(localeOc, 'oc')
|
||||
|
||||
|
@ -59,6 +60,7 @@ registerLocaleData(localeOc, 'oc')
|
|||
SharedUserInterfaceSettingsModule,
|
||||
SharedGlobalIconModule,
|
||||
SharedInstanceModule,
|
||||
SharedAccountAvatarModule,
|
||||
|
||||
MetaModule.forRoot({
|
||||
provide: MetaLoader,
|
||||
|
|
|
@ -111,12 +111,6 @@ export class User implements UserServerModel {
|
|||
}
|
||||
}
|
||||
|
||||
get accountAvatarUrl () {
|
||||
if (!this.account) return ''
|
||||
|
||||
return this.account.avatarUrl
|
||||
}
|
||||
|
||||
hasRight (right: UserRight) {
|
||||
return hasUserRight(this.role, right)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<div>
|
||||
<div class="logged-in-more" ngbDropdown #dropdown="ngbDropdown" placement="bottom-left" [container]="dropdownContainer" (openChange)="onDropdownOpenChange($event)" autoClose="outside">
|
||||
<div ngbDropdownToggle>
|
||||
<img [src]="user.accountAvatarUrl" alt="Avatar" />
|
||||
<my-account-avatar [account]="user.account" size="34"></my-account-avatar>
|
||||
<div class="logged-in-info">
|
||||
<div class="logged-in-display-name">{{ user.account?.displayName }}</div>
|
||||
|
||||
|
|
|
@ -176,9 +176,7 @@ menu {
|
|||
border-radius: $main-radius;
|
||||
}
|
||||
|
||||
img {
|
||||
@include avatar(34px);
|
||||
|
||||
my-account-avatar {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,7 @@
|
|||
<a [routerLink]="[ baseRoute ]" [queryParams]="{ 'search': 'reporter:"' + abuse.reporterAccount.displayName + '"' }"
|
||||
class="chip"
|
||||
>
|
||||
<img
|
||||
class="avatar"
|
||||
[src]="abuse.reporterAccount.avatar?.path"
|
||||
(error)="switchToDefaultAvatar($event)"
|
||||
alt="Avatar"
|
||||
>
|
||||
<my-account-avatar [account]="abuse.reporterAccount"></my-account-avatar>
|
||||
<div>
|
||||
<span class="text-muted">{{ abuse.reporterAccount.nameWithHost }}</span>
|
||||
</div>
|
||||
|
@ -35,12 +30,7 @@
|
|||
<a [routerLink]="[ baseRoute ]" [queryParams]="{ 'search': 'reportee:"' +abuse.flaggedAccount.displayName + '"' }"
|
||||
class="chip"
|
||||
>
|
||||
<img
|
||||
class="avatar"
|
||||
[src]="abuse.flaggedAccount?.avatar?.path"
|
||||
(error)="switchToDefaultAvatar($event)"
|
||||
alt="Avatar"
|
||||
>
|
||||
<my-account-avatar [account]="abuse.flaggedAccount"></my-account-avatar>
|
||||
<div>
|
||||
<span class="text-muted">{{ abuse.flaggedAccount ? abuse.flaggedAccount.nameWithHost : '' }}</span>
|
||||
</div>
|
||||
|
|
|
@ -45,8 +45,4 @@ export class AbuseDetailsComponent {
|
|||
label: this.predefinedReasonsTranslations[r]
|
||||
}))
|
||||
}
|
||||
|
||||
switchToDefaultAvatar ($event: Event) {
|
||||
($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,12 +65,7 @@
|
|||
<td *ngIf="isAdminView()">
|
||||
<a *ngIf="abuse.reporterAccount" [href]="abuse.reporterAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">
|
||||
<div class="chip two-lines">
|
||||
<img
|
||||
class="avatar"
|
||||
[src]="abuse.reporterAccount.avatar?.path"
|
||||
(error)="switchToDefaultAvatar($event)"
|
||||
alt="Avatar"
|
||||
>
|
||||
<my-account-avatar [account]="abuse.reporterAccount"></my-account-avatar>
|
||||
<div>
|
||||
{{ abuse.reporterAccount.displayName }}
|
||||
<span>{{ abuse.reporterAccount.nameWithHost }}</span>
|
||||
|
|
|
@ -122,10 +122,6 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
|
|||
)
|
||||
}
|
||||
|
||||
switchToDefaultAvatar ($event: Event) {
|
||||
($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL()
|
||||
}
|
||||
|
||||
async removeAbuse (abuse: AdminAbuse) {
|
||||
const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`)
|
||||
if (res === false) return
|
||||
|
|
|
@ -10,6 +10,7 @@ import { AbuseDetailsComponent } from './abuse-details.component'
|
|||
import { AbuseListTableComponent } from './abuse-list-table.component'
|
||||
import { AbuseMessageModalComponent } from './abuse-message-modal.component'
|
||||
import { ModerationCommentModalComponent } from './moderation-comment-modal.component'
|
||||
import { SharedAccountAvatarModule } from '../shared-account-avatar/shared-account-avatar.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -19,7 +20,8 @@ import { ModerationCommentModalComponent } from './moderation-comment-modal.comp
|
|||
SharedFormModule,
|
||||
SharedModerationModule,
|
||||
SharedGlobalIconModule,
|
||||
SharedVideoCommentModule
|
||||
SharedVideoCommentModule,
|
||||
SharedAccountAvatarModule
|
||||
],
|
||||
|
||||
declarations: [
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<a *ngIf="account" [href]="href" target="_blank" rel="noopener noreferrer" [title]="title">
|
||||
<img
|
||||
[class]="class"
|
||||
[src]="avatarUrl"
|
||||
i18n-alt
|
||||
alt="Account avatar"
|
||||
/>
|
||||
</a>
|
|
@ -0,0 +1,22 @@
|
|||
@import '_variables';
|
||||
@import '_mixins';
|
||||
|
||||
.avatar-25 {
|
||||
@include avatar(25px);
|
||||
}
|
||||
|
||||
.avatar-34 {
|
||||
@include avatar(34px);
|
||||
}
|
||||
|
||||
.avatar-36 {
|
||||
@include avatar(36px);
|
||||
}
|
||||
|
||||
.avatar-40 {
|
||||
@include avatar(40px);
|
||||
}
|
||||
|
||||
.avatar-120 {
|
||||
@include avatar(120px);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
import { Component, Input } from '@angular/core'
|
||||
import { Account as AccountInterface } from '@shared/models'
|
||||
import { Account } from '../shared-main/account/account.model'
|
||||
|
||||
@Component({
|
||||
selector: 'my-account-avatar',
|
||||
styleUrls: [ './account-avatar.component.scss' ],
|
||||
templateUrl: './account-avatar.component.html'
|
||||
})
|
||||
export class AccountAvatarComponent {
|
||||
_href: string
|
||||
_title: string
|
||||
|
||||
@Input() account: { name: string, avatar?: { url?: string }, url: string }
|
||||
@Input() size = '36'
|
||||
@Input() set href (value) {
|
||||
this._href = value
|
||||
}
|
||||
@Input() set title (value) {
|
||||
this._title = value
|
||||
}
|
||||
|
||||
get href () {
|
||||
return this._href || this.account?.url
|
||||
}
|
||||
|
||||
get title () {
|
||||
return this._title || $localize`${this.account.name} (account page)`
|
||||
}
|
||||
|
||||
get class () {
|
||||
return `avatar avatar-${this.size}`
|
||||
}
|
||||
|
||||
get avatarUrl () {
|
||||
return this.account?.avatar ? this.account.avatar.url : Account.GET_DEFAULT_AVATAR_URL()
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
export * from './account-avatar.component'
|
||||
export * from './shared-account-avatar.module'
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
import { NgModule } from '@angular/core'
|
||||
import { SharedGlobalIconModule } from '../shared-icons'
|
||||
import { SharedMainModule } from '../shared-main/shared-main.module'
|
||||
import { AccountAvatarComponent } from './account-avatar.component'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
SharedMainModule,
|
||||
SharedGlobalIconModule
|
||||
],
|
||||
|
||||
declarations: [
|
||||
AccountAvatarComponent
|
||||
],
|
||||
|
||||
exports: [
|
||||
AccountAvatarComponent
|
||||
],
|
||||
|
||||
providers: [ ]
|
||||
})
|
||||
export class SharedAccountAvatarModule { }
|
|
@ -20,7 +20,6 @@ export class Video implements VideoServerModel {
|
|||
byVideoChannel: string
|
||||
byAccount: string
|
||||
|
||||
accountAvatarUrl: string
|
||||
videoChannelAvatarUrl: string
|
||||
|
||||
createdAt: Date
|
||||
|
@ -144,7 +143,6 @@ export class Video implements VideoServerModel {
|
|||
|
||||
this.byAccount = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host)
|
||||
this.byVideoChannel = Actor.CREATE_BY_STRING(hash.channel.name, hash.channel.host)
|
||||
this.accountAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.account)
|
||||
this.videoChannelAvatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this.channel)
|
||||
|
||||
this.category.label = peertubeTranslate(this.category.label, translations)
|
||||
|
|
|
@ -38,12 +38,7 @@
|
|||
<td>
|
||||
<a [href]="accountBlock.blockedAccount.url" i18n-title title="Open account in a new tab" target="_blank" rel="noopener noreferrer">
|
||||
<div class="chip two-lines">
|
||||
<img
|
||||
class="avatar"
|
||||
[src]="accountBlock.blockedAccount.avatar?.path"
|
||||
(error)="switchToDefaultAvatar($event)"
|
||||
alt="Avatar"
|
||||
>
|
||||
<my-account-avatar [account]="accountBlock.blockedAccount"></my-account-avatar>
|
||||
<div>
|
||||
{{ accountBlock.blockedAccount.displayName }}
|
||||
<span class="text-muted">{{ accountBlock.blockedAccount.nameWithHost }}</span>
|
||||
|
|
|
@ -30,10 +30,6 @@ export class GenericAccountBlocklistComponent extends RestTable implements OnIni
|
|||
this.initialize()
|
||||
}
|
||||
|
||||
switchToDefaultAvatar ($event: Event) {
|
||||
($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL()
|
||||
}
|
||||
|
||||
unblockAccount (accountBlock: AccountBlock) {
|
||||
const blockedAccount = accountBlock.blockedAccount
|
||||
const operation = this.mode === BlocklistComponentType.Account
|
||||
|
|
|
@ -13,13 +13,15 @@ import { UserBanModalComponent } from './user-ban-modal.component'
|
|||
import { UserModerationDropdownComponent } from './user-moderation-dropdown.component'
|
||||
import { VideoBlockComponent } from './video-block.component'
|
||||
import { VideoBlockService } from './video-block.service'
|
||||
import { SharedAccountAvatarModule } from '../shared-account-avatar/shared-account-avatar.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
SharedMainModule,
|
||||
SharedFormModule,
|
||||
SharedGlobalIconModule,
|
||||
SharedVideoCommentModule
|
||||
SharedVideoCommentModule,
|
||||
SharedAccountAvatarModule
|
||||
],
|
||||
|
||||
declarations: [
|
||||
|
|
|
@ -17,7 +17,6 @@ export class VideoComment implements VideoCommentServerModel {
|
|||
totalRepliesFromVideoAuthor: number
|
||||
totalReplies: number
|
||||
by: string
|
||||
accountAvatarUrl: string
|
||||
|
||||
isLocal: boolean
|
||||
|
||||
|
@ -38,7 +37,6 @@ export class VideoComment implements VideoCommentServerModel {
|
|||
|
||||
if (this.account) {
|
||||
this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
|
||||
this.accountAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.account)
|
||||
|
||||
const absoluteAPIUrl = getAbsoluteAPIUrl()
|
||||
const thisHost = new URL(absoluteAPIUrl).host
|
||||
|
@ -70,7 +68,6 @@ export class VideoCommentAdmin implements VideoCommentAdminServerModel {
|
|||
}
|
||||
|
||||
by: string
|
||||
accountAvatarUrl: string
|
||||
|
||||
constructor (hash: VideoCommentAdminServerModel, textHtml: string) {
|
||||
this.id = hash.id
|
||||
|
@ -97,7 +94,6 @@ export class VideoCommentAdmin implements VideoCommentAdminServerModel {
|
|||
|
||||
if (this.account) {
|
||||
this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
|
||||
this.accountAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.account)
|
||||
|
||||
this.account.localUrl = '/accounts/' + this.by
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import { VideoDownloadComponent } from './video-download.component'
|
|||
import { VideoMiniatureComponent } from './video-miniature.component'
|
||||
import { VideosSelectionComponent } from './videos-selection.component'
|
||||
import { VideoListHeaderComponent } from './video-list-header.component'
|
||||
import { SharedAccountAvatarModule } from '../shared-account-avatar/shared-account-avatar.module'
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
@ -23,7 +24,8 @@ import { VideoListHeaderComponent } from './video-list-header.component'
|
|||
SharedThumbnailModule,
|
||||
SharedGlobalIconModule,
|
||||
SharedVideoLiveModule,
|
||||
SharedVideoModule
|
||||
SharedVideoModule,
|
||||
SharedAccountAvatarModule
|
||||
],
|
||||
|
||||
declarations: [
|
||||
|
|
|
@ -10,9 +10,10 @@
|
|||
<div class="video-bottom">
|
||||
<div class="video-miniature-information">
|
||||
<div class="d-flex video-miniature-meta">
|
||||
<a *ngIf="displayOptions.avatar" class="avatar" [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
|
||||
<img [src]="getAvatarUrl()" alt="" [ngClass]="{ channel: displayOwnerVideoChannel() }" />
|
||||
<a *ngIf="displayOptions.avatar && displayOwnerVideoChannel()" class="avatar" [routerLink]="[ '/video-channels', video.byVideoChannel ]" [title]="channelLinkTitle">
|
||||
<img [src]="getAvatarUrl()" alt="" class="channel" />
|
||||
</a>
|
||||
<my-account-avatar *ngIf="displayOptions.avatar && displayOwnerAccount()" [account]="video.account" size="40" [href]="'/video-channels/' + video.byVideoChannel" [title]="channelLinkTitle"></my-account-avatar>
|
||||
|
||||
<div class="w-100 d-flex flex-column">
|
||||
<a *ngIf="!videoHref" tabindex="-1" class="video-miniature-name"
|
||||
|
|
|
@ -12,13 +12,10 @@ $more-button-width: 40px;
|
|||
width: calc(100% - #{$more-button-width});
|
||||
}
|
||||
|
||||
my-account-avatar,
|
||||
.avatar {
|
||||
margin: 10px 10px 0 0;
|
||||
|
||||
img:not(.channel) {
|
||||
@include avatar(40px);
|
||||
}
|
||||
|
||||
img.channel {
|
||||
@include channel-avatar(40px);
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ export class VideoMiniatureComponent implements OnInit {
|
|||
|
||||
getAvatarUrl () {
|
||||
if (this.displayOwnerAccount()) {
|
||||
return this.video.accountAvatarUrl
|
||||
return this.video.account.avatar?.url
|
||||
}
|
||||
|
||||
return this.video.videoChannelAvatarUrl
|
||||
|
|
|
@ -29,10 +29,6 @@
|
|||
@include channel-avatar(120px);
|
||||
}
|
||||
|
||||
.account-avatar {
|
||||
@include avatar(120px);
|
||||
}
|
||||
|
||||
> div {
|
||||
margin-left: $img-margin;
|
||||
min-width: 1px;
|
||||
|
|
Loading…
Reference in New Issue