aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorkimsible <kimsible@users.noreply.github.com>2020-11-18 19:20:05 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-25 11:12:06 +0100
commitc418d483004dfbae9ea38d54aa1577db46d34a8a (patch)
treec4fd4ec790c6e5d6bc44e887090a8286e10fffd2 /client/src/app/shared
parent18490b07650d77d7fe376970b749af5a8c672fd6 (diff)
downloadPeerTube-c418d483004dfbae9ea38d54aa1577db46d34a8a.tar.gz
PeerTube-c418d483004dfbae9ea38d54aa1577db46d34a8a.tar.zst
PeerTube-c418d483004dfbae9ea38d54aa1577db46d34a8a.zip
Add new default different avatar for channel and account
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-abuse-list/abuse-details.component.ts4
-rw-r--r--client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts2
-rw-r--r--client/src/app/shared/shared-forms/select/select-channel.component.ts4
-rw-r--r--client/src/app/shared/shared-main/account/account.model.ts22
-rw-r--r--client/src/app/shared/shared-main/account/actor.model.ts18
-rw-r--r--client/src/app/shared/shared-main/users/user-notification.model.ts18
-rw-r--r--client/src/app/shared/shared-main/video-channel/video-channel.model.ts22
-rw-r--r--client/src/app/shared/shared-main/video/video.model.ts6
-rw-r--r--client/src/app/shared/shared-moderation/account-blocklist.component.ts4
-rw-r--r--client/src/app/shared/shared-video-comment/video-comment.model.ts6
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist.model.ts6
11 files changed, 69 insertions, 43 deletions
diff --git a/client/src/app/shared/shared-abuse-list/abuse-details.component.ts b/client/src/app/shared/shared-abuse-list/abuse-details.component.ts
index 282a6fe19..31cf3389d 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-details.component.ts
+++ b/client/src/app/shared/shared-abuse-list/abuse-details.component.ts
@@ -1,6 +1,6 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input } from '@angular/core'
2import { durationToString } from '@app/helpers' 2import { durationToString } from '@app/helpers'
3import { Actor } from '@app/shared/shared-main' 3import { Account } from '@app/shared/shared-main'
4import { AbusePredefinedReasonsString } from '@shared/models' 4import { AbusePredefinedReasonsString } from '@shared/models'
5import { ProcessedAbuse } from './processed-abuse.model' 5import { ProcessedAbuse } from './processed-abuse.model'
6 6
@@ -47,6 +47,6 @@ export class AbuseDetailsComponent {
47 } 47 }
48 48
49 switchToDefaultAvatar ($event: Event) { 49 switchToDefaultAvatar ($event: Event) {
50 ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL() 50 ($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL()
51 } 51 }
52} 52}
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
index 807665b9c..904f62b57 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
@@ -122,7 +122,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
122 } 122 }
123 123
124 switchToDefaultAvatar ($event: Event) { 124 switchToDefaultAvatar ($event: Event) {
125 ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL() 125 ($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL()
126 } 126 }
127 127
128 async removeAbuse (abuse: AdminAbuse) { 128 async removeAbuse (abuse: AdminAbuse) {
diff --git a/client/src/app/shared/shared-forms/select/select-channel.component.ts b/client/src/app/shared/shared-forms/select/select-channel.component.ts
index 1b0db9b6f..1d91d59bc 100644
--- a/client/src/app/shared/shared-forms/select/select-channel.component.ts
+++ b/client/src/app/shared/shared-forms/select/select-channel.component.ts
@@ -1,6 +1,6 @@
1import { Component, forwardRef, Input } from '@angular/core' 1import { Component, forwardRef, Input } from '@angular/core'
2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' 2import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
3import { Actor } from '@app/shared/shared-main/account/actor.model' 3import { VideoChannel } from '@app/shared/shared-main'
4 4
5export type SelectChannelItem = { 5export type SelectChannelItem = {
6 id: number 6 id: number
@@ -34,7 +34,7 @@ export class SelectChannelComponent implements ControlValueAccessor {
34 34
35 get channels () { 35 get channels () {
36 return this.items.map(c => Object.assign(c, { 36 return this.items.map(c => Object.assign(c, {
37 avatarPath: c.avatarPath ? c.avatarPath : Actor.GET_DEFAULT_AVATAR_URL() 37 avatarPath: c.avatarPath ? c.avatarPath : VideoChannel.GET_DEFAULT_AVATAR_URL()
38 })) 38 }))
39 } 39 }
40 40
diff --git a/client/src/app/shared/shared-main/account/account.model.ts b/client/src/app/shared/shared-main/account/account.model.ts
index 6df2e9d10..b3dc6cfe5 100644
--- a/client/src/app/shared/shared-main/account/account.model.ts
+++ b/client/src/app/shared/shared-main/account/account.model.ts
@@ -1,4 +1,4 @@
1import { Account as ServerAccount } from '@shared/models/actors/account.model' 1import { Account as ServerAccount, Avatar } from '@shared/models'
2import { Actor } from './actor.model' 2import { Actor } from './actor.model'
3 3
4export class Account extends Actor implements ServerAccount { 4export class Account extends Actor implements ServerAccount {
@@ -13,9 +13,19 @@ export class Account extends Actor implements ServerAccount {
13 13
14 userId?: number 14 userId?: number
15 15
16 static GET_ACTOR_AVATAR_URL (actor: object) {
17 return Actor.GET_ACTOR_AVATAR_URL(actor) || this.GET_DEFAULT_AVATAR_URL()
18 }
19
20 static GET_DEFAULT_AVATAR_URL () {
21 return `${window.location.origin}/client/assets/images/default-avatar-account.png`
22 }
23
16 constructor (hash: ServerAccount) { 24 constructor (hash: ServerAccount) {
17 super(hash) 25 super(hash)
18 26
27 this.updateComputedAttributes()
28
19 this.displayName = hash.displayName 29 this.displayName = hash.displayName
20 this.description = hash.description 30 this.description = hash.description
21 this.userId = hash.userId 31 this.userId = hash.userId
@@ -27,4 +37,14 @@ export class Account extends Actor implements ServerAccount {
27 this.mutedServerByUser = false 37 this.mutedServerByUser = false
28 this.mutedServerByInstance = false 38 this.mutedServerByInstance = false
29 } 39 }
40
41 updateAvatar (newAvatar: Avatar) {
42 this.avatar = newAvatar
43
44 this.updateComputedAttributes()
45 }
46
47 private updateComputedAttributes () {
48 this.avatarUrl = Account.GET_ACTOR_AVATAR_URL(this)
49 }
30} 50}
diff --git a/client/src/app/shared/shared-main/account/actor.model.ts b/client/src/app/shared/shared-main/account/actor.model.ts
index 950e256ff..8222c9769 100644
--- a/client/src/app/shared/shared-main/account/actor.model.ts
+++ b/client/src/app/shared/shared-main/account/actor.model.ts
@@ -24,12 +24,6 @@ export abstract class Actor implements ActorServer {
24 24
25 return absoluteAPIUrl + actor.avatar.path 25 return absoluteAPIUrl + actor.avatar.path
26 } 26 }
27
28 return this.GET_DEFAULT_AVATAR_URL()
29 }
30
31 static GET_DEFAULT_AVATAR_URL () {
32 return window.location.origin + '/client/assets/images/default-avatar.png'
33 } 27 }
34 28
35 static CREATE_BY_STRING (accountName: string, host: string, forceHostname = false) { 29 static CREATE_BY_STRING (accountName: string, host: string, forceHostname = false) {
@@ -61,17 +55,5 @@ export abstract class Actor implements ActorServer {
61 55
62 this.avatar = hash.avatar 56 this.avatar = hash.avatar
63 this.isLocal = Actor.IS_LOCAL(this.host) 57 this.isLocal = Actor.IS_LOCAL(this.host)
64
65 this.updateComputedAttributes()
66 }
67
68 updateAvatar (newAvatar: Avatar) {
69 this.avatar = newAvatar
70
71 this.updateComputedAttributes()
72 }
73
74 private updateComputedAttributes () {
75 this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this)
76 } 58 }
77} 59}
diff --git a/client/src/app/shared/shared-main/users/user-notification.model.ts b/client/src/app/shared/shared-main/users/user-notification.model.ts
index 648bb7fe0..b1df4a584 100644
--- a/client/src/app/shared/shared-main/users/user-notification.model.ts
+++ b/client/src/app/shared/shared-main/users/user-notification.model.ts
@@ -7,7 +7,7 @@ import {
7 VideoInfo, 7 VideoInfo,
8 UserRight 8 UserRight
9} from '@shared/models' 9} from '@shared/models'
10import { Actor } from '../account/actor.model' 10import { Account, Actor, VideoChannel } from '@app/shared/shared-main'
11import { AuthUser } from '@app/core' 11import { AuthUser } from '@app/core'
12 12
13export class UserNotification implements UserNotificationServer { 13export class UserNotification implements UserNotificationServer {
@@ -95,22 +95,22 @@ export class UserNotification implements UserNotificationServer {
95 // To prevent a notification popup crash in case of bug, wrap it inside a try/catch 95 // To prevent a notification popup crash in case of bug, wrap it inside a try/catch
96 try { 96 try {
97 this.video = hash.video 97 this.video = hash.video
98 if (this.video) this.setAvatarUrl(this.video.channel) 98 if (this.video) this.setVideoChannelAvatarUrl(this.video.channel)
99 99
100 this.videoImport = hash.videoImport 100 this.videoImport = hash.videoImport
101 101
102 this.comment = hash.comment 102 this.comment = hash.comment
103 if (this.comment) this.setAvatarUrl(this.comment.account) 103 if (this.comment) this.setAccountAvatarUrl(this.comment.account)
104 104
105 this.abuse = hash.abuse 105 this.abuse = hash.abuse
106 106
107 this.videoBlacklist = hash.videoBlacklist 107 this.videoBlacklist = hash.videoBlacklist
108 108
109 this.account = hash.account 109 this.account = hash.account
110 if (this.account) this.setAvatarUrl(this.account) 110 if (this.account) this.setAccountAvatarUrl(this.account)
111 111
112 this.actorFollow = hash.actorFollow 112 this.actorFollow = hash.actorFollow
113 if (this.actorFollow) this.setAvatarUrl(this.actorFollow.follower) 113 if (this.actorFollow) this.setAccountAvatarUrl(this.actorFollow.follower)
114 114
115 this.createdAt = hash.createdAt 115 this.createdAt = hash.createdAt
116 this.updatedAt = hash.updatedAt 116 this.updatedAt = hash.updatedAt
@@ -222,7 +222,11 @@ export class UserNotification implements UserNotificationServer {
222 return [ this.buildVideoUrl(comment.video), { threadId: comment.threadId } ] 222 return [ this.buildVideoUrl(comment.video), { threadId: comment.threadId } ]
223 } 223 }
224 224
225 private setAvatarUrl (actor: { avatarUrl?: string, avatar?: { url?: string, path: string } }) { 225 private setAccountAvatarUrl (actor: { avatarUrl?: string, avatar?: { url?: string, path: string } }) {
226 actor.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(actor) 226 actor.avatarUrl = Account.GET_ACTOR_AVATAR_URL(actor)
227 }
228
229 private setVideoChannelAvatarUrl (actor: { avatarUrl?: string, avatar?: { url?: string, path: string } }) {
230 actor.avatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(actor)
227 } 231 }
228} 232}
diff --git a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts
index 123389afb..4f1f5b65d 100644
--- a/client/src/app/shared/shared-main/video-channel/video-channel.model.ts
+++ b/client/src/app/shared/shared-main/video-channel/video-channel.model.ts
@@ -1,4 +1,4 @@
1import { VideoChannel as ServerVideoChannel, ViewsPerDate, Account } from '@shared/models' 1import { VideoChannel as ServerVideoChannel, ViewsPerDate, Account, Avatar } from '@shared/models'
2import { Actor } from '../account/actor.model' 2import { Actor } from '../account/actor.model'
3 3
4export class VideoChannel extends Actor implements ServerVideoChannel { 4export class VideoChannel extends Actor implements ServerVideoChannel {
@@ -17,9 +17,19 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
17 17
18 viewsPerDay?: ViewsPerDate[] 18 viewsPerDay?: ViewsPerDate[]
19 19
20 static GET_ACTOR_AVATAR_URL (actor: object) {
21 return Actor.GET_ACTOR_AVATAR_URL(actor) || this.GET_DEFAULT_AVATAR_URL()
22 }
23
24 static GET_DEFAULT_AVATAR_URL () {
25 return `${window.location.origin}/client/assets/images/default-avatar-videochannel.png`
26 }
27
20 constructor (hash: ServerVideoChannel) { 28 constructor (hash: ServerVideoChannel) {
21 super(hash) 29 super(hash)
22 30
31 this.updateComputedAttributes()
32
23 this.displayName = hash.displayName 33 this.displayName = hash.displayName
24 this.description = hash.description 34 this.description = hash.description
25 this.support = hash.support 35 this.support = hash.support
@@ -39,4 +49,14 @@ export class VideoChannel extends Actor implements ServerVideoChannel {
39 this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount) 49 this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount)
40 } 50 }
41 } 51 }
52
53 updateAvatar (newAvatar: Avatar) {
54 this.avatar = newAvatar
55
56 this.updateComputedAttributes()
57 }
58
59 private updateComputedAttributes () {
60 this.avatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this)
61 }
42} 62}
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 92f5bc0c0..8e0e68020 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -12,7 +12,7 @@ import {
12 VideoScheduleUpdate, 12 VideoScheduleUpdate,
13 VideoState 13 VideoState
14} from '@shared/models' 14} from '@shared/models'
15import { Actor } from '../account/actor.model' 15import { Account, Actor, VideoChannel } from '@app/shared/shared-main'
16 16
17export class Video implements VideoServerModel { 17export class Video implements VideoServerModel {
18 byVideoChannel: string 18 byVideoChannel: string
@@ -142,8 +142,8 @@ export class Video implements VideoServerModel {
142 142
143 this.byAccount = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host) 143 this.byAccount = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host)
144 this.byVideoChannel = Actor.CREATE_BY_STRING(hash.channel.name, hash.channel.host) 144 this.byVideoChannel = Actor.CREATE_BY_STRING(hash.channel.name, hash.channel.host)
145 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account) 145 this.accountAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.account)
146 this.videoChannelAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.channel) 146 this.videoChannelAvatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this.channel)
147 147
148 this.category.label = peertubeTranslate(this.category.label, translations) 148 this.category.label = peertubeTranslate(this.category.label, translations)
149 this.licence.label = peertubeTranslate(this.licence.label, translations) 149 this.licence.label = peertubeTranslate(this.licence.label, translations)
diff --git a/client/src/app/shared/shared-moderation/account-blocklist.component.ts b/client/src/app/shared/shared-moderation/account-blocklist.component.ts
index 68928a2c2..3de9587b8 100644
--- a/client/src/app/shared/shared-moderation/account-blocklist.component.ts
+++ b/client/src/app/shared/shared-moderation/account-blocklist.component.ts
@@ -1,7 +1,7 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { Directive, OnInit } from '@angular/core' 2import { Directive, OnInit } from '@angular/core'
3import { Notifier, RestPagination, RestTable } from '@app/core' 3import { Notifier, RestPagination, RestTable } from '@app/core'
4import { Actor } from '@app/shared/shared-main' 4import { Account } from '@app/shared/shared-main'
5import { AccountBlock } from './account-block.model' 5import { AccountBlock } from './account-block.model'
6import { BlocklistComponentType, BlocklistService } from './blocklist.service' 6import { BlocklistComponentType, BlocklistService } from './blocklist.service'
7 7
@@ -31,7 +31,7 @@ export class GenericAccountBlocklistComponent extends RestTable implements OnIni
31 } 31 }
32 32
33 switchToDefaultAvatar ($event: Event) { 33 switchToDefaultAvatar ($event: Event) {
34 ($event.target as HTMLImageElement).src = Actor.GET_DEFAULT_AVATAR_URL() 34 ($event.target as HTMLImageElement).src = Account.GET_DEFAULT_AVATAR_URL()
35 } 35 }
36 36
37 unblockAccount (accountBlock: AccountBlock) { 37 unblockAccount (accountBlock: AccountBlock) {
diff --git a/client/src/app/shared/shared-video-comment/video-comment.model.ts b/client/src/app/shared/shared-video-comment/video-comment.model.ts
index eeee397af..bf718ae08 100644
--- a/client/src/app/shared/shared-video-comment/video-comment.model.ts
+++ b/client/src/app/shared/shared-video-comment/video-comment.model.ts
@@ -1,5 +1,5 @@
1import { getAbsoluteAPIUrl } from '@app/helpers' 1import { getAbsoluteAPIUrl } from '@app/helpers'
2import { Actor } from '@app/shared/shared-main' 2import { Account, Actor } from '@app/shared/shared-main'
3import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel } from '@shared/models' 3import { Account as AccountInterface, VideoComment as VideoCommentServerModel, VideoCommentAdmin as VideoCommentAdminServerModel } from '@shared/models'
4 4
5export class VideoComment implements VideoCommentServerModel { 5export class VideoComment implements VideoCommentServerModel {
@@ -38,7 +38,7 @@ export class VideoComment implements VideoCommentServerModel {
38 38
39 if (this.account) { 39 if (this.account) {
40 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host) 40 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
41 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account) 41 this.accountAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.account)
42 42
43 const absoluteAPIUrl = getAbsoluteAPIUrl() 43 const absoluteAPIUrl = getAbsoluteAPIUrl()
44 const thisHost = new URL(absoluteAPIUrl).host 44 const thisHost = new URL(absoluteAPIUrl).host
@@ -97,7 +97,7 @@ export class VideoCommentAdmin implements VideoCommentAdminServerModel {
97 97
98 if (this.account) { 98 if (this.account) {
99 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host) 99 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
100 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account) 100 this.accountAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.account)
101 101
102 this.account.localUrl = '/accounts/' + this.by 102 this.account.localUrl = '/accounts/' + this.by
103 } 103 }
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
index 3db3b7a2e..9bec16d77 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist.model.ts
@@ -1,5 +1,5 @@
1import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers' 1import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
2import { Actor } from '@app/shared/shared-main' 2import { Account, Actor, VideoChannel } from '@app/shared/shared-main'
3import { peertubeTranslate } from '@shared/core-utils/i18n' 3import { peertubeTranslate } from '@shared/core-utils/i18n'
4import { 4import {
5 AccountSummary, 5 AccountSummary,
@@ -78,12 +78,12 @@ export class VideoPlaylist implements ServerVideoPlaylist {
78 78
79 this.ownerAccount = hash.ownerAccount 79 this.ownerAccount = hash.ownerAccount
80 this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host) 80 this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
81 this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount) 81 this.ownerAvatarUrl = Account.GET_ACTOR_AVATAR_URL(this.ownerAccount)
82 82
83 if (hash.videoChannel) { 83 if (hash.videoChannel) {
84 this.videoChannel = hash.videoChannel 84 this.videoChannel = hash.videoChannel
85 this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host) 85 this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host)
86 this.videoChannelAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.videoChannel) 86 this.videoChannelAvatarUrl = VideoChannel.GET_ACTOR_AVATAR_URL(this.videoChannel)
87 } 87 }
88 88
89 this.privacy.label = peertubeTranslate(this.privacy.label, translations) 89 this.privacy.label = peertubeTranslate(this.privacy.label, translations)