aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-12-06 17:15:59 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-12-06 17:15:59 +0100
commitb1fa3eba70dbd7d9e5b795ad251e293c88ebeee2 (patch)
treefffcdf00d7b475c5c2de7456a7ef3c4d47c71865 /client/src/app/shared
parentce0e281d46a7b574dcccb47958743656532bd312 (diff)
downloadPeerTube-b1fa3eba70dbd7d9e5b795ad251e293c88ebeee2.tar.gz
PeerTube-b1fa3eba70dbd7d9e5b795ad251e293c88ebeee2.tar.zst
PeerTube-b1fa3eba70dbd7d9e5b795ad251e293c88ebeee2.zip
Begin video watch design
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/account/account.model.ts20
-rw-r--r--client/src/app/shared/shared.module.ts3
-rw-r--r--client/src/app/shared/users/user.model.ts6
-rw-r--r--client/src/app/shared/video/abstract-video-list.html2
-rw-r--r--client/src/app/shared/video/video-details.model.ts9
-rw-r--r--client/src/app/shared/video/video-miniature.component.html17
-rw-r--r--client/src/app/shared/video/video-miniature.component.scss44
-rw-r--r--client/src/app/shared/video/video-miniature.component.ts17
-rw-r--r--client/src/app/shared/video/video-pagination.model.ts2
-rw-r--r--client/src/app/shared/video/video.model.ts8
10 files changed, 116 insertions, 12 deletions
diff --git a/client/src/app/shared/account/account.model.ts b/client/src/app/shared/account/account.model.ts
new file mode 100644
index 000000000..0b008188a
--- /dev/null
+++ b/client/src/app/shared/account/account.model.ts
@@ -0,0 +1,20 @@
1import { Account as ServerAccount } from '../../../../../shared/models/accounts/account.model'
2import { Avatar } from '../../../../../shared/models/avatars/avatar.model'
3
4export class Account implements ServerAccount {
5 id: number
6 uuid: string
7 name: string
8 host: string
9 followingCount: number
10 followersCount: number
11 createdAt: Date
12 updatedAt: Date
13 avatar: Avatar
14
15 static GET_ACCOUNT_AVATAR_PATH (account: Account) {
16 if (account && account.avatar) return account.avatar.path
17
18 return API_URL + '/client/assets/images/default-avatar.png'
19 }
20}
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts
index 86e1a380e..bd9aee345 100644
--- a/client/src/app/shared/shared.module.ts
+++ b/client/src/app/shared/shared.module.ts
@@ -20,6 +20,7 @@ import { RestExtractor, RestService } from './rest'
20import { UserService } from './users' 20import { UserService } from './users'
21import { VideoAbuseService } from './video-abuse' 21import { VideoAbuseService } from './video-abuse'
22import { VideoBlacklistService } from './video-blacklist' 22import { VideoBlacklistService } from './video-blacklist'
23import { VideoMiniatureComponent } from './video/video-miniature.component'
23import { VideoThumbnailComponent } from './video/video-thumbnail.component' 24import { VideoThumbnailComponent } from './video/video-thumbnail.component'
24import { VideoService } from './video/video.service' 25import { VideoService } from './video/video.service'
25 26
@@ -44,6 +45,7 @@ import { VideoService } from './video/video.service'
44 declarations: [ 45 declarations: [
45 LoaderComponent, 46 LoaderComponent,
46 VideoThumbnailComponent, 47 VideoThumbnailComponent,
48 VideoMiniatureComponent,
47 NumberFormatterPipe, 49 NumberFormatterPipe,
48 FromNowPipe 50 FromNowPipe
49 ], 51 ],
@@ -66,6 +68,7 @@ import { VideoService } from './video/video.service'
66 68
67 LoaderComponent, 69 LoaderComponent,
68 VideoThumbnailComponent, 70 VideoThumbnailComponent,
71 VideoMiniatureComponent,
69 72
70 NumberFormatterPipe, 73 NumberFormatterPipe,
71 FromNowPipe 74 FromNowPipe
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts
index b1c323114..b4d13f37c 100644
--- a/client/src/app/shared/users/user.model.ts
+++ b/client/src/app/shared/users/user.model.ts
@@ -1,5 +1,5 @@
1import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared' 1import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared'
2import { Account } from '../../../../../shared/models/accounts' 2import { Account } from '../account/account.model'
3 3
4export type UserConstructorHash = { 4export type UserConstructorHash = {
5 id: number, 5 id: number,
@@ -52,8 +52,6 @@ export class User implements UserServerModel {
52 } 52 }
53 53
54 getAvatarPath () { 54 getAvatarPath () {
55 if (this.account && this.account.avatar) return this.account.avatar.path 55 return Account.GET_ACCOUNT_AVATAR_PATH(this.account)
56
57 return API_URL + '/client/assets/images/default-avatar.png'
58 } 56 }
59} 57}
diff --git a/client/src/app/shared/video/abstract-video-list.html b/client/src/app/shared/video/abstract-video-list.html
index bd4f6b1f8..5d07a276b 100644
--- a/client/src/app/shared/video/abstract-video-list.html
+++ b/client/src/app/shared/video/abstract-video-list.html
@@ -12,7 +12,7 @@
12 > 12 >
13 <my-video-miniature 13 <my-video-miniature
14 class="ng-animate" 14 class="ng-animate"
15 *ngFor="let video of videos" [video]="video" [user]="user" [currentSort]="sort" 15 *ngFor="let video of videos" [video]="video" [user]="user"
16 > 16 >
17 </my-video-miniature> 17 </my-video-miniature>
18 </div> 18 </div>
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts
index 93c380b73..1a956da7c 100644
--- a/client/src/app/shared/video/video-details.model.ts
+++ b/client/src/app/shared/video/video-details.model.ts
@@ -1,3 +1,4 @@
1import { Account } from '../../../../../shared/models/accounts'
1import { Video } from '../../shared/video/video.model' 2import { Video } from '../../shared/video/video.model'
2import { AuthUser } from '../../core' 3import { AuthUser } from '../../core'
3import { 4import {
@@ -10,7 +11,7 @@ import {
10} from '../../../../../shared' 11} from '../../../../../shared'
11 12
12export class VideoDetails extends Video implements VideoDetailsServerModel { 13export class VideoDetails extends Video implements VideoDetailsServerModel {
13 account: string 14 accountName: string
14 by: string 15 by: string
15 createdAt: Date 16 createdAt: Date
16 updatedAt: Date 17 updatedAt: Date
@@ -44,6 +45,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
44 channel: VideoChannel 45 channel: VideoChannel
45 privacy: VideoPrivacy 46 privacy: VideoPrivacy
46 privacyLabel: string 47 privacyLabel: string
48 account: Account
47 49
48 constructor (hash: VideoDetailsServerModel) { 50 constructor (hash: VideoDetailsServerModel) {
49 super(hash) 51 super(hash)
@@ -53,6 +55,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
53 this.descriptionPath = hash.descriptionPath 55 this.descriptionPath = hash.descriptionPath
54 this.files = hash.files 56 this.files = hash.files
55 this.channel = hash.channel 57 this.channel = hash.channel
58 this.account = hash.account
56 } 59 }
57 60
58 getAppropriateMagnetUri (actualDownloadSpeed = 0) { 61 getAppropriateMagnetUri (actualDownloadSpeed = 0) {
@@ -71,7 +74,7 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
71 } 74 }
72 75
73 isRemovableBy (user: AuthUser) { 76 isRemovableBy (user: AuthUser) {
74 return user && this.isLocal === true && (this.account === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO)) 77 return user && this.isLocal === true && (this.accountName === user.username || user.hasRight(UserRight.REMOVE_ANY_VIDEO))
75 } 78 }
76 79
77 isBlackistableBy (user: AuthUser) { 80 isBlackistableBy (user: AuthUser) {
@@ -79,6 +82,6 @@ export class VideoDetails extends Video implements VideoDetailsServerModel {
79 } 82 }
80 83
81 isUpdatableBy (user: AuthUser) { 84 isUpdatableBy (user: AuthUser) {
82 return user && this.isLocal === true && user.username === this.account 85 return user && this.isLocal === true && user.username === this.accountName
83 } 86 }
84} 87}
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html
new file mode 100644
index 000000000..7ac017235
--- /dev/null
+++ b/client/src/app/shared/video/video-miniature.component.html
@@ -0,0 +1,17 @@
1<div class="video-miniature">
2 <my-video-thumbnail [video]="video" [nsfw]="isVideoNSFWForThisUser()"></my-video-thumbnail>
3
4 <div class="video-miniature-information">
5 <span class="video-miniature-name">
6 <a
7 class="video-miniature-name"
8 [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoNSFWForThisUser() }"
9 >
10 {{ video.name }}
11 </a>
12 </span>
13
14 <span class="video-miniature-created-at-views">{{ video.createdAt | myFromNow }} - {{ video.views | myNumberFormatter }} views</span>
15 <span class="video-miniature-account">{{ video.by }}</span>
16 </div>
17</div>
diff --git a/client/src/app/shared/video/video-miniature.component.scss b/client/src/app/shared/video/video-miniature.component.scss
new file mode 100644
index 000000000..37e84897b
--- /dev/null
+++ b/client/src/app/shared/video/video-miniature.component.scss
@@ -0,0 +1,44 @@
1.video-miniature {
2 display: inline-block;
3 padding-right: 15px;
4 margin-bottom: 30px;
5 height: 175px;
6 vertical-align: top;
7
8 .video-miniature-information {
9 width: 200px;
10 margin-top: 2px;
11 line-height: normal;
12
13 .video-miniature-name {
14 display: block;
15 overflow: hidden;
16 text-overflow: ellipsis;
17 white-space: nowrap;
18 font-weight: bold;
19 transition: color 0.2s;
20 font-size: 16px;
21 font-weight: $font-semibold;
22 color: #000;
23
24 &:hover {
25 text-decoration: none;
26 }
27
28 &.blur-filter {
29 filter: blur(3px);
30 padding-left: 4px;
31 }
32 }
33
34 .video-miniature-created-at-views {
35 display: block;
36 font-size: 13px;
37 }
38
39 .video-miniature-account {
40 font-size: 13px;
41 color: #585858;
42 }
43 }
44}
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts
new file mode 100644
index 000000000..4d79a74bb
--- /dev/null
+++ b/client/src/app/shared/video/video-miniature.component.ts
@@ -0,0 +1,17 @@
1import { Component, Input } from '@angular/core'
2import { User } from '../users'
3import { Video } from './video.model'
4
5@Component({
6 selector: 'my-video-miniature',
7 styleUrls: [ './video-miniature.component.scss' ],
8 templateUrl: './video-miniature.component.html'
9})
10export class VideoMiniatureComponent {
11 @Input() user: User
12 @Input() video: Video
13
14 isVideoNSFWForThisUser () {
15 return this.video.isVideoNSFWForUser(this.user)
16 }
17}
diff --git a/client/src/app/shared/video/video-pagination.model.ts b/client/src/app/shared/video/video-pagination.model.ts
index 9e71769cb..e9db61596 100644
--- a/client/src/app/shared/video/video-pagination.model.ts
+++ b/client/src/app/shared/video/video-pagination.model.ts
@@ -1,5 +1,5 @@
1export interface VideoPagination { 1export interface VideoPagination {
2 currentPage: number 2 currentPage: number
3 itemsPerPage: number 3 itemsPerPage: number
4 totalItems: number 4 totalItems?: number
5} 5}
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index 6929c8755..d86ef8f92 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -1,8 +1,9 @@
1import { Video as VideoServerModel } from '../../../../../shared' 1import { Video as VideoServerModel } from '../../../../../shared'
2import { User } from '../' 2import { User } from '../'
3import { Account } from '../../../../../shared/models/accounts'
3 4
4export class Video implements VideoServerModel { 5export class Video implements VideoServerModel {
5 account: string 6 accountName: string
6 by: string 7 by: string
7 createdAt: Date 8 createdAt: Date
8 updatedAt: Date 9 updatedAt: Date
@@ -31,6 +32,7 @@ export class Video implements VideoServerModel {
31 likes: number 32 likes: number
32 dislikes: number 33 dislikes: number
33 nsfw: boolean 34 nsfw: boolean
35 account: Account
34 36
35 private static createByString (account: string, serverHost: string) { 37 private static createByString (account: string, serverHost: string) {
36 return account + '@' + serverHost 38 return account + '@' + serverHost
@@ -52,7 +54,7 @@ export class Video implements VideoServerModel {
52 absoluteAPIUrl = window.location.origin 54 absoluteAPIUrl = window.location.origin
53 } 55 }
54 56
55 this.account = hash.account 57 this.accountName = hash.accountName
56 this.createdAt = new Date(hash.createdAt.toString()) 58 this.createdAt = new Date(hash.createdAt.toString())
57 this.categoryLabel = hash.categoryLabel 59 this.categoryLabel = hash.categoryLabel
58 this.category = hash.category 60 this.category = hash.category
@@ -80,7 +82,7 @@ export class Video implements VideoServerModel {
80 this.dislikes = hash.dislikes 82 this.dislikes = hash.dislikes
81 this.nsfw = hash.nsfw 83 this.nsfw = hash.nsfw
82 84
83 this.by = Video.createByString(hash.account, hash.serverHost) 85 this.by = Video.createByString(hash.accountName, hash.serverHost)
84 } 86 }
85 87
86 isVideoNSFWForUser (user: User) { 88 isVideoNSFWForUser (user: User) {