aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+account/account-routing.module.ts12
-rw-r--r--client/src/app/+account/account-video-channels/account-video-channels.component.html11
-rw-r--r--client/src/app/+account/account-video-channels/account-video-channels.component.scss30
-rw-r--r--client/src/app/+account/account-video-channels/account-video-channels.component.ts33
-rw-r--r--client/src/app/+account/account.component.html4
-rw-r--r--client/src/app/+account/account.component.ts4
-rw-r--r--client/src/app/+account/account.module.ts2
-rw-r--r--client/src/app/menu/menu.component.html2
-rw-r--r--client/src/app/menu/menu.component.ts4
-rw-r--r--client/src/app/my-account/my-account-settings/my-account-settings.component.html2
-rw-r--r--client/src/app/my-account/my-account-settings/my-account-settings.component.ts4
-rw-r--r--client/src/app/shared/account/account.model.ts44
-rw-r--r--client/src/app/shared/actor/actor.model.ts50
-rw-r--r--client/src/app/shared/shared.module.ts4
-rw-r--r--client/src/app/shared/users/user.model.ts17
-rw-r--r--client/src/app/shared/video-channel/video-channel.model.ts23
-rw-r--r--client/src/app/shared/video-channel/video-channel.service.ts36
-rw-r--r--client/src/app/shared/video/video.model.ts6
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.html2
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment-add.component.ts4
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.html2
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.ts6
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.model.ts6
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.html2
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts4
25 files changed, 230 insertions, 84 deletions
diff --git a/client/src/app/+account/account-routing.module.ts b/client/src/app/+account/account-routing.module.ts
index 534102121..f72d8373f 100644
--- a/client/src/app/+account/account-routing.module.ts
+++ b/client/src/app/+account/account-routing.module.ts
@@ -3,7 +3,8 @@ import { RouterModule, Routes } from '@angular/router'
3import { MetaGuard } from '@ngx-meta/core' 3import { MetaGuard } from '@ngx-meta/core'
4import { AccountComponent } from './account.component' 4import { AccountComponent } from './account.component'
5import { AccountVideosComponent } from './account-videos/account-videos.component' 5import { AccountVideosComponent } from './account-videos/account-videos.component'
6import { AccountAboutComponent } from '@app/+account/account-about/account-about.component' 6import { AccountAboutComponent } from './account-about/account-about.component'
7import { AccountVideoChannelsComponent } from './account-video-channels/account-video-channels.component'
7 8
8const accountRoutes: Routes = [ 9const accountRoutes: Routes = [
9 { 10 {
@@ -26,6 +27,15 @@ const accountRoutes: Routes = [
26 } 27 }
27 }, 28 },
28 { 29 {
30 path: 'video-channels',
31 component: AccountVideoChannelsComponent,
32 data: {
33 meta: {
34 title: 'Account video channels'
35 }
36 }
37 },
38 {
29 path: 'about', 39 path: 'about',
30 component: AccountAboutComponent, 40 component: AccountAboutComponent,
31 data: { 41 data: {
diff --git a/client/src/app/+account/account-video-channels/account-video-channels.component.html b/client/src/app/+account/account-video-channels/account-video-channels.component.html
new file mode 100644
index 000000000..d20b40c60
--- /dev/null
+++ b/client/src/app/+account/account-video-channels/account-video-channels.component.html
@@ -0,0 +1,11 @@
1<div *ngIf="account" class="row">
2 <a
3 *ngFor="let videoChannel of videoChannels" [routerLink]="[ '/video-channels', videoChannel.uuid ]"
4 class="video-channel" title="See this video channel"
5 >
6 <img [src]="videoChannel.avatarUrl" alt="Avatar" />
7
8 <div class="video-channel-display-name">{{ videoChannel.displayName }}</div>
9 <div class="video-channel-followers">{{ videoChannel.followersCount }} subscribers</div>
10 </a>
11</div> \ No newline at end of file
diff --git a/client/src/app/+account/account-video-channels/account-video-channels.component.scss b/client/src/app/+account/account-video-channels/account-video-channels.component.scss
new file mode 100644
index 000000000..c9c7fa8eb
--- /dev/null
+++ b/client/src/app/+account/account-video-channels/account-video-channels.component.scss
@@ -0,0 +1,30 @@
1@import '_variables';
2@import '_mixins';
3
4.row {
5 text-align: center;
6}
7
8a.video-channel {
9 @include disable-default-a-behaviour;
10
11 display: inline-block;
12 text-align: center;
13 color: #000;
14 margin: 10px 30px;
15
16 img {
17 @include avatar(80px);
18
19 margin-bottom: 10px;
20 }
21
22 .video-channel-display-name {
23 font-size: 20px;
24 font-weight: $font-bold;
25 }
26
27 .video-channel-followers {
28 font-size: 15px;
29 }
30} \ No newline at end of file
diff --git a/client/src/app/+account/account-video-channels/account-video-channels.component.ts b/client/src/app/+account/account-video-channels/account-video-channels.component.ts
new file mode 100644
index 000000000..8915eb622
--- /dev/null
+++ b/client/src/app/+account/account-video-channels/account-video-channels.component.ts
@@ -0,0 +1,33 @@
1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute } from '@angular/router'
3import 'rxjs/add/observable/from'
4import 'rxjs/add/operator/concatAll'
5import { Account } from '@app/shared/account/account.model'
6import { AccountService } from '@app/shared/account/account.service'
7import { VideoChannel } from '../../../../../shared/models/videos'
8import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
9
10@Component({
11 selector: 'my-account-video-channels',
12 templateUrl: './account-video-channels.component.html',
13 styleUrls: [ './account-video-channels.component.scss' ]
14})
15export class AccountVideoChannelsComponent implements OnInit {
16 account: Account
17 videoChannels: VideoChannel[] = []
18
19 constructor (
20 protected route: ActivatedRoute,
21 private accountService: AccountService,
22 private videoChannelService: VideoChannelService
23 ) { }
24
25 ngOnInit () {
26 // Parent get the account for us
27 this.accountService.accountLoaded
28 .do(account => this.account = account)
29 .flatMap(account => this.videoChannelService.getVideoChannels(account.id))
30 .map(res => res.data)
31 .subscribe(videoChannels => this.videoChannels = videoChannels)
32 }
33}
diff --git a/client/src/app/+account/account.component.html b/client/src/app/+account/account.component.html
index f875b37a4..d0e99edda 100644
--- a/client/src/app/+account/account.component.html
+++ b/client/src/app/+account/account.component.html
@@ -2,7 +2,7 @@
2 <div class="sub-menu"> 2 <div class="sub-menu">
3 3
4 <div class="account"> 4 <div class="account">
5 <img [src]="getAvatarUrl()" alt="Avatar" /> 5 <img [src]="account.avatarUrl" alt="Avatar" />
6 6
7 <div class="account-info"> 7 <div class="account-info">
8 <div class="account-display-name">{{ account.displayName }}</div> 8 <div class="account-display-name">{{ account.displayName }}</div>
@@ -13,6 +13,8 @@
13 <div class="links"> 13 <div class="links">
14 <a routerLink="videos" routerLinkActive="active" class="title-page">Videos</a> 14 <a routerLink="videos" routerLinkActive="active" class="title-page">Videos</a>
15 15
16 <a routerLink="video-channels" routerLinkActive="active" class="title-page">Video channels</a>
17
16 <a routerLink="about" routerLinkActive="active" class="title-page">About</a> 18 <a routerLink="about" routerLinkActive="active" class="title-page">About</a>
17 </div> 19 </div>
18 </div> 20 </div>
diff --git a/client/src/app/+account/account.component.ts b/client/src/app/+account/account.component.ts
index ae5354ed9..d936ce2fe 100644
--- a/client/src/app/+account/account.component.ts
+++ b/client/src/app/+account/account.component.ts
@@ -22,8 +22,4 @@ export class AccountComponent implements OnInit {
22 this.accountService.getAccount(accountId) 22 this.accountService.getAccount(accountId)
23 .subscribe(account => this.account = account) 23 .subscribe(account => this.account = account)
24 } 24 }
25
26 getAvatarUrl () {
27 return Account.GET_ACCOUNT_AVATAR_URL(this.account)
28 }
29} 25}
diff --git a/client/src/app/+account/account.module.ts b/client/src/app/+account/account.module.ts
index 2fe67f3c5..82ef06e76 100644
--- a/client/src/app/+account/account.module.ts
+++ b/client/src/app/+account/account.module.ts
@@ -4,6 +4,7 @@ import { AccountRoutingModule } from './account-routing.module'
4import { AccountComponent } from './account.component' 4import { AccountComponent } from './account.component'
5import { AccountVideosComponent } from './account-videos/account-videos.component' 5import { AccountVideosComponent } from './account-videos/account-videos.component'
6import { AccountAboutComponent } from './account-about/account-about.component' 6import { AccountAboutComponent } from './account-about/account-about.component'
7import { AccountVideoChannelsComponent } from './account-video-channels/account-video-channels.component'
7 8
8@NgModule({ 9@NgModule({
9 imports: [ 10 imports: [
@@ -14,6 +15,7 @@ import { AccountAboutComponent } from './account-about/account-about.component'
14 declarations: [ 15 declarations: [
15 AccountComponent, 16 AccountComponent,
16 AccountVideosComponent, 17 AccountVideosComponent,
18 AccountVideoChannelsComponent,
17 AccountAboutComponent 19 AccountAboutComponent
18 ], 20 ],
19 21
diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html
index 832cd9e78..e4cd40628 100644
--- a/client/src/app/menu/menu.component.html
+++ b/client/src/app/menu/menu.component.html
@@ -1,7 +1,7 @@
1<menu> 1<menu>
2 <div *ngIf="isLoggedIn" class="logged-in-block"> 2 <div *ngIf="isLoggedIn" class="logged-in-block">
3 <a routerLink="/account/settings"> 3 <a routerLink="/account/settings">
4 <img [src]="getUserAvatarUrl()" alt="Avatar" /> 4 <img [src]="user.accountAvatarUrl" alt="Avatar" />
5 </a> 5 </a>
6 6
7 <div class="logged-in-info"> 7 <div class="logged-in-info">
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index 1f66e3754..4c35bb3a5 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -51,10 +51,6 @@ export class MenuComponent implements OnInit {
51 ) 51 )
52 } 52 }
53 53
54 getUserAvatarUrl () {
55 return this.user.getAvatarUrl()
56 }
57
58 isRegistrationAllowed () { 54 isRegistrationAllowed () {
59 return this.serverService.getConfig().signup.allowed 55 return this.serverService.getConfig().signup.allowed
60 } 56 }
diff --git a/client/src/app/my-account/my-account-settings/my-account-settings.component.html b/client/src/app/my-account/my-account-settings/my-account-settings.component.html
index 7ae27dc75..e11d93c01 100644
--- a/client/src/app/my-account/my-account-settings/my-account-settings.component.html
+++ b/client/src/app/my-account/my-account-settings/my-account-settings.component.html
@@ -1,5 +1,5 @@
1<div class="user"> 1<div class="user">
2 <img [src]="getAvatarUrl()" alt="Avatar" /> 2 <img [src]="user.accountAvatarUrl" alt="Avatar" />
3 3
4 <div class="user-info"> 4 <div class="user-info">
5 <div class="user-info-username">{{ user.username }}</div> 5 <div class="user-info-username">{{ user.username }}</div>
diff --git a/client/src/app/my-account/my-account-settings/my-account-settings.component.ts b/client/src/app/my-account/my-account-settings/my-account-settings.component.ts
index 91420cc6f..06d1138e7 100644
--- a/client/src/app/my-account/my-account-settings/my-account-settings.component.ts
+++ b/client/src/app/my-account/my-account-settings/my-account-settings.component.ts
@@ -42,10 +42,6 @@ export class MyAccountSettingsComponent implements OnInit {
42 .subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed) 42 .subscribe(data => this.userVideoQuotaUsed = data.videoQuotaUsed)
43 } 43 }
44 44
45 getAvatarUrl () {
46 return this.user.getAvatarUrl()
47 }
48
49 changeAvatar () { 45 changeAvatar () {
50 const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ] 46 const avatarfile = this.avatarfileInput.nativeElement.files[ 0 ]
51 47
diff --git a/client/src/app/shared/account/account.model.ts b/client/src/app/shared/account/account.model.ts
index 10a70ac31..6a3c6451c 100644
--- a/client/src/app/shared/account/account.model.ts
+++ b/client/src/app/shared/account/account.model.ts
@@ -1,50 +1,14 @@
1import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model' 1import { Account as ServerAccount } from '../../../../../shared/models/actors/account.model'
2import { Avatar } from '../../../../../shared/models/avatars/avatar.model' 2import { Actor } from '../actor/actor.model'
3import { getAbsoluteAPIUrl } from '../misc/utils'
4 3
5export class Account implements ServerAccount { 4export class Account extends Actor implements ServerAccount {
6 id: number
7 uuid: string
8 url: string
9 name: string
10 displayName: string 5 displayName: string
11 description: string 6 description: string
12 host: string
13 followingCount: number
14 followersCount: number
15 createdAt: Date
16 updatedAt: Date
17 avatar: Avatar
18
19 static GET_ACCOUNT_AVATAR_URL (account: Account) {
20 const absoluteAPIUrl = getAbsoluteAPIUrl()
21
22 if (account && account.avatar) return absoluteAPIUrl + account.avatar.path
23
24 return window.location.origin + '/client/assets/images/default-avatar.png'
25 }
26
27 static CREATE_BY_STRING (accountName: string, host: string) {
28 const absoluteAPIUrl = getAbsoluteAPIUrl()
29 const thisHost = new URL(absoluteAPIUrl).host
30
31 if (host.trim() === thisHost) return accountName
32
33 return accountName + '@' + host
34 }
35 7
36 constructor (hash: ServerAccount) { 8 constructor (hash: ServerAccount) {
37 this.id = hash.id 9 super(hash)
38 this.uuid = hash.uuid 10
39 this.url = hash.url
40 this.name = hash.name
41 this.displayName = hash.displayName 11 this.displayName = hash.displayName
42 this.description = hash.description 12 this.description = hash.description
43 this.host = hash.host
44 this.followingCount = hash.followingCount
45 this.followersCount = hash.followersCount
46 this.createdAt = new Date(hash.createdAt.toString())
47 this.updatedAt = new Date(hash.updatedAt.toString())
48 this.avatar = hash.avatar
49 } 13 }
50} 14}
diff --git a/client/src/app/shared/actor/actor.model.ts b/client/src/app/shared/actor/actor.model.ts
new file mode 100644
index 000000000..56ff780b7
--- /dev/null
+++ b/client/src/app/shared/actor/actor.model.ts
@@ -0,0 +1,50 @@
1import { Actor as ActorServer } from '../../../../../shared/models/actors/actor.model'
2import { getAbsoluteAPIUrl } from '@app/shared/misc/utils'
3import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
4
5export abstract class Actor implements ActorServer {
6 id: number
7 uuid: string
8 url: string
9 name: string
10 host: string
11 followingCount: number
12 followersCount: number
13 createdAt: Date
14 updatedAt: Date
15 avatar: Avatar
16
17 avatarUrl: string
18
19 static GET_ACTOR_AVATAR_URL (actor: { avatar: Avatar }) {
20 const absoluteAPIUrl = getAbsoluteAPIUrl()
21
22 if (actor && actor.avatar) return absoluteAPIUrl + actor.avatar.path
23
24 return window.location.origin + '/client/assets/images/default-avatar.png'
25 }
26
27 static CREATE_BY_STRING (accountName: string, host: string) {
28 const absoluteAPIUrl = getAbsoluteAPIUrl()
29 const thisHost = new URL(absoluteAPIUrl).host
30
31 if (host.trim() === thisHost) return accountName
32
33 return accountName + '@' + host
34 }
35
36 protected constructor (hash: ActorServer) {
37 this.id = hash.id
38 this.uuid = hash.uuid
39 this.url = hash.url
40 this.name = hash.name
41 this.host = hash.host
42 this.followingCount = hash.followingCount
43 this.followersCount = hash.followersCount
44 this.createdAt = new Date(hash.createdAt.toString())
45 this.updatedAt = new Date(hash.updatedAt.toString())
46 this.avatar = hash.avatar
47
48 this.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(this)
49 }
50}
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts
index 2178eebc8..20019e47a 100644
--- a/client/src/app/shared/shared.module.ts
+++ b/client/src/app/shared/shared.module.ts
@@ -32,6 +32,7 @@ import { VideoFeedComponent } from './video/video-feed.component'
32import { VideoThumbnailComponent } from './video/video-thumbnail.component' 32import { VideoThumbnailComponent } from './video/video-thumbnail.component'
33import { VideoService } from './video/video.service' 33import { VideoService } from './video/video.service'
34import { AccountService } from '@app/shared/account/account.service' 34import { AccountService } from '@app/shared/account/account.service'
35import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
35 36
36@NgModule({ 37@NgModule({
37 imports: [ 38 imports: [
@@ -106,7 +107,8 @@ import { AccountService } from '@app/shared/account/account.service'
106 UserService, 107 UserService,
107 VideoService, 108 VideoService,
108 AccountService, 109 AccountService,
109 MarkdownService 110 MarkdownService,
111 VideoChannelService
110 ] 112 ]
111}) 113})
112export class SharedModule { } 114export class SharedModule { }
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts
index 2bdc48a1d..d4551de89 100644
--- a/client/src/app/shared/users/user.model.ts
+++ b/client/src/app/shared/users/user.model.ts
@@ -1,6 +1,6 @@
1import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared' 1import { Account, hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
2import { Account } from '../account/account.model'
3import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' 2import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type'
3import { Actor } from '@app/shared/actor/actor.model'
4 4
5export type UserConstructorHash = { 5export type UserConstructorHash = {
6 id: number, 6 id: number,
@@ -25,6 +25,7 @@ export class User implements UserServerModel {
25 account: Account 25 account: Account
26 videoChannels: VideoChannel[] 26 videoChannels: VideoChannel[]
27 createdAt: Date 27 createdAt: Date
28 accountAvatarUrl: string
28 29
29 constructor (hash: UserConstructorHash) { 30 constructor (hash: UserConstructorHash) {
30 this.id = hash.id 31 this.id = hash.id
@@ -52,19 +53,23 @@ export class User implements UserServerModel {
52 if (hash.createdAt !== undefined) { 53 if (hash.createdAt !== undefined) {
53 this.createdAt = hash.createdAt 54 this.createdAt = hash.createdAt
54 } 55 }
56
57 this.updateComputedAttributes()
55 } 58 }
56 59
57 hasRight (right: UserRight) { 60 hasRight (right: UserRight) {
58 return hasUserRight(this.role, right) 61 return hasUserRight(this.role, right)
59 } 62 }
60 63
61 getAvatarUrl () {
62 return Account.GET_ACCOUNT_AVATAR_URL(this.account)
63 }
64
65 patch (obj: UserServerModel) { 64 patch (obj: UserServerModel) {
66 for (const key of Object.keys(obj)) { 65 for (const key of Object.keys(obj)) {
67 this[key] = obj[key] 66 this[key] = obj[key]
68 } 67 }
68
69 this.updateComputedAttributes()
70 }
71
72 private updateComputedAttributes () {
73 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
69 } 74 }
70} 75}
diff --git a/client/src/app/shared/video-channel/video-channel.model.ts b/client/src/app/shared/video-channel/video-channel.model.ts
new file mode 100644
index 000000000..01381ac30
--- /dev/null
+++ b/client/src/app/shared/video-channel/video-channel.model.ts
@@ -0,0 +1,23 @@
1import { VideoChannel as ServerVideoChannel } from '../../../../../shared/models/videos/video-channel.model'
2import { Actor } from '../actor/actor.model'
3
4export class VideoChannel extends Actor implements ServerVideoChannel {
5 displayName: string
6 description: string
7 support: string
8 isLocal: boolean
9 ownerAccount?: {
10 id: number
11 uuid: string
12 }
13
14 constructor (hash: ServerVideoChannel) {
15 super(hash)
16
17 this.displayName = hash.displayName
18 this.description = hash.description
19 this.support = hash.support
20 this.isLocal = hash.isLocal
21 this.ownerAccount = hash.ownerAccount
22 }
23}
diff --git a/client/src/app/shared/video-channel/video-channel.service.ts b/client/src/app/shared/video-channel/video-channel.service.ts
new file mode 100644
index 000000000..1f9088c38
--- /dev/null
+++ b/client/src/app/shared/video-channel/video-channel.service.ts
@@ -0,0 +1,36 @@
1import { Injectable } from '@angular/core'
2import 'rxjs/add/operator/catch'
3import 'rxjs/add/operator/map'
4import { Observable } from 'rxjs/Observable'
5import { RestExtractor } from '../rest/rest-extractor.service'
6import { RestService } from '../rest/rest.service'
7import { HttpClient } from '@angular/common/http'
8import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos'
9import { AccountService } from '../account/account.service'
10import { ResultList } from '../../../../../shared'
11import { VideoChannel } from './video-channel.model'
12
13@Injectable()
14export class VideoChannelService {
15 constructor (
16 private authHttp: HttpClient,
17 private restExtractor: RestExtractor,
18 private restService: RestService
19 ) {}
20
21 getVideoChannels (accountId: number): Observable<ResultList<VideoChannel>> {
22 return this.authHttp.get<ResultList<VideoChannelServer>>(AccountService.BASE_ACCOUNT_URL + accountId + '/video-channels')
23 .map(res => this.extractVideoChannels(res))
24 .catch((res) => this.restExtractor.handleError(res))
25 }
26
27 private extractVideoChannels (result: ResultList<VideoChannelServer>) {
28 const videoChannels: VideoChannel[] = []
29
30 for (const videoChannelJSON of result.data) {
31 videoChannels.push(new VideoChannel(videoChannelJSON))
32 }
33
34 return { data: videoChannels, total: result.total }
35 }
36}
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index 2e85f40ef..f56eecaeb 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -1,13 +1,14 @@
1import { Account } from '@app/shared/account/account.model'
2import { User } from '../' 1import { User } from '../'
3import { Video as VideoServerModel, VideoPrivacy } from '../../../../../shared' 2import { Video as VideoServerModel, VideoPrivacy } from '../../../../../shared'
4import { Avatar } from '../../../../../shared/models/avatars/avatar.model' 3import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
5import { VideoConstant } from '../../../../../shared/models/videos/video.model' 4import { VideoConstant } from '../../../../../shared/models/videos/video.model'
6import { getAbsoluteAPIUrl } from '../misc/utils' 5import { getAbsoluteAPIUrl } from '../misc/utils'
7import { ServerConfig } from '../../../../../shared/models' 6import { ServerConfig } from '../../../../../shared/models'
7import { Actor } from '@app/shared/actor/actor.model'
8 8
9export class Video implements VideoServerModel { 9export class Video implements VideoServerModel {
10 by: string 10 by: string
11 accountAvatarUrl: string
11 createdAt: Date 12 createdAt: Date
12 updatedAt: Date 13 updatedAt: Date
13 publishedAt: Date 14 publishedAt: Date
@@ -85,7 +86,8 @@ export class Video implements VideoServerModel {
85 this.nsfw = hash.nsfw 86 this.nsfw = hash.nsfw
86 this.account = hash.account 87 this.account = hash.account
87 88
88 this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host) 89 this.by = Actor.CREATE_BY_STRING(hash.account.name, hash.account.host)
90 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
89 } 91 }
90 92
91 isVideoNSFWForUser (user: User, serverConfig: ServerConfig) { 93 isVideoNSFWForUser (user: User, serverConfig: ServerConfig) {
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
index e393daa79..54d7286db 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.html
@@ -1,6 +1,6 @@
1<form novalidate [formGroup]="form" (ngSubmit)="formValidated()"> 1<form novalidate [formGroup]="form" (ngSubmit)="formValidated()">
2 <div class="avatar-and-textarea"> 2 <div class="avatar-and-textarea">
3 <img [src]="getUserAvatarUrl()" alt="Avatar" /> 3 <img [src]="user.accountAvatarUrl" alt="Avatar" />
4 4
5 <div class="form-group"> 5 <div class="form-group">
6 <textarea placeholder="Add comment..." formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }" 6 <textarea placeholder="Add comment..." formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }"
diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
index 731652fda..d1ca1968b 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts
@@ -100,10 +100,6 @@ export class VideoCommentAddComponent extends FormReactive implements OnInit {
100 return this.form.value['text'] 100 return this.form.value['text']
101 } 101 }
102 102
103 getUserAvatarUrl () {
104 return this.user.getAvatarUrl()
105 }
106
107 private addCommentReply (commentCreate: VideoCommentCreate) { 103 private addCommentReply (commentCreate: VideoCommentCreate) {
108 return this.videoCommentService 104 return this.videoCommentService
109 .addCommentReply(this.video.id, this.parentComment.id, commentCreate) 105 .addCommentReply(this.video.id, this.parentComment.id, commentCreate)
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.html
index 8a649e88f..06808ef80 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html
@@ -1,5 +1,5 @@
1<div class="root-comment"> 1<div class="root-comment">
2 <img [src]="getAvatarUrl(comment.account)" alt="Avatar" /> 2 <img [src]="comment.accountAvatarUrl" alt="Avatar" />
3 3
4 <div class="comment"> 4 <div class="comment">
5 <div *ngIf="highlightedComment === true" class="highlighted-comment">Highlighted comment</div> 5 <div *ngIf="highlightedComment === true" class="highlighted-comment">Highlighted comment</div>
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
index 26fc9d0b8..e90008de9 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
@@ -1,11 +1,9 @@
1import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' 1import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'
2import { LinkifierService } from '@app/videos/+video-watch/comment/linkifier.service' 2import { LinkifierService } from '@app/videos/+video-watch/comment/linkifier.service'
3import * as sanitizeHtml from 'sanitize-html' 3import * as sanitizeHtml from 'sanitize-html'
4import { Account as AccountInterface } from '../../../../../../shared/models/actors'
5import { UserRight } from '../../../../../../shared/models/users' 4import { UserRight } from '../../../../../../shared/models/users'
6import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' 5import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
7import { AuthService } from '../../../core/auth' 6import { AuthService } from '../../../core/auth'
8import { Account } from '../../../shared/account/account.model'
9import { Video } from '../../../shared/video/video.model' 7import { Video } from '../../../shared/video/video.model'
10import { VideoComment } from './video-comment.model' 8import { VideoComment } from './video-comment.model'
11 9
@@ -80,10 +78,6 @@ export class VideoCommentComponent implements OnInit, OnChanges {
80 this.resetReply.emit() 78 this.resetReply.emit()
81 } 79 }
82 80
83 getAvatarUrl (account: AccountInterface) {
84 return Account.GET_ACCOUNT_AVATAR_URL(account)
85 }
86
87 isRemovableByUser () { 81 isRemovableByUser () {
88 return this.isUserLoggedIn() && 82 return this.isUserLoggedIn() &&
89 ( 83 (
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.model.ts b/client/src/app/videos/+video-watch/comment/video-comment.model.ts
index 8fa02aee1..fe591811e 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.model.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment.model.ts
@@ -1,6 +1,6 @@
1import { Account } from '@app/shared/account/account.model'
2import { Account as AccountInterface } from '../../../../../../shared/models/actors' 1import { Account as AccountInterface } from '../../../../../../shared/models/actors'
3import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model' 2import { VideoComment as VideoCommentServerModel } from '../../../../../../shared/models/videos/video-comment.model'
3import { Actor } from '@app/shared/actor/actor.model'
4 4
5export class VideoComment implements VideoCommentServerModel { 5export class VideoComment implements VideoCommentServerModel {
6 id: number 6 id: number
@@ -14,6 +14,7 @@ export class VideoComment implements VideoCommentServerModel {
14 account: AccountInterface 14 account: AccountInterface
15 totalReplies: number 15 totalReplies: number
16 by: string 16 by: string
17 accountAvatarUrl
17 18
18 constructor (hash: VideoCommentServerModel) { 19 constructor (hash: VideoCommentServerModel) {
19 this.id = hash.id 20 this.id = hash.id
@@ -27,6 +28,7 @@ export class VideoComment implements VideoCommentServerModel {
27 this.account = hash.account 28 this.account = hash.account
28 this.totalReplies = hash.totalReplies 29 this.totalReplies = hash.totalReplies
29 30
30 this.by = Account.CREATE_BY_STRING(this.account.name, this.account.host) 31 this.by = Actor.CREATE_BY_STRING(this.account.name, this.account.host)
32 this.accountAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.account)
31 } 33 }
32} 34}
diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html
index 036d75d3c..5d3361561 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.html
+++ b/client/src/app/videos/+video-watch/video-watch.component.html
@@ -24,7 +24,7 @@
24 <div class="video-info-by"> 24 <div class="video-info-by">
25 <a [routerLink]="[ '/account', video.account.id ]" title="Go the account page"> 25 <a [routerLink]="[ '/account', video.account.id ]" title="Go the account page">
26 <span>By {{ video.by }}</span> 26 <span>By {{ video.by }}</span>
27 <img [src]="getAvatarPath()" alt="Account avatar" /> 27 <img [src]="video.accountAvatarUrl" alt="Account avatar" />
28 </a> 28 </a>
29 </div> 29 </div>
30 </div> 30 </div>
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index 4b0c49583..615b969e5 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -228,10 +228,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
228 return this.video.isBlackistableBy(this.user) 228 return this.video.isBlackistableBy(this.user)
229 } 229 }
230 230
231 getAvatarPath () {
232 return Account.GET_ACCOUNT_AVATAR_URL(this.video.account)
233 }
234
235 getVideoPoster () { 231 getVideoPoster () {
236 if (!this.video) return '' 232 if (!this.video) return ''
237 233