aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/shared/video.model.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
commitdf98563e2104b82b119c00a3cd83cd0dc1242d25 (patch)
treea9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/videos/shared/video.model.ts
parent46757b477c1adb5f98060d15998a3852e18902a6 (diff)
downloadPeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/videos/shared/video.model.ts')
-rw-r--r--client/src/app/videos/shared/video.model.ts150
1 files changed, 75 insertions, 75 deletions
diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts
index e897eb175..f5e16fc13 100644
--- a/client/src/app/videos/shared/video.model.ts
+++ b/client/src/app/videos/shared/video.model.ts
@@ -1,56 +1,56 @@
1import { Video as VideoServerModel } from '../../../../../shared'; 1import { Video as VideoServerModel } from '../../../../../shared'
2import { User } from '../../shared'; 2import { User } from '../../shared'
3 3
4export class Video implements VideoServerModel { 4export class Video implements VideoServerModel {
5 author: string; 5 author: string
6 by: string; 6 by: string
7 createdAt: Date; 7 createdAt: Date
8 categoryLabel: string; 8 categoryLabel: string
9 category: number; 9 category: number
10 licenceLabel: string; 10 licenceLabel: string
11 licence: number; 11 licence: number
12 languageLabel: string; 12 languageLabel: string
13 language: number; 13 language: number
14 description: string; 14 description: string
15 duration: number; 15 duration: number
16 durationLabel: string; 16 durationLabel: string
17 id: string; 17 id: string
18 isLocal: boolean; 18 isLocal: boolean
19 magnetUri: string; 19 magnetUri: string
20 name: string; 20 name: string
21 podHost: string; 21 podHost: string
22 tags: string[]; 22 tags: string[]
23 thumbnailPath: string; 23 thumbnailPath: string
24 thumbnailUrl: string; 24 thumbnailUrl: string
25 views: number; 25 views: number
26 likes: number; 26 likes: number
27 dislikes: number; 27 dislikes: number
28 nsfw: boolean; 28 nsfw: boolean
29 29
30 private static createByString(author: string, podHost: string) { 30 private static createByString (author: string, podHost: string) {
31 return author + '@' + podHost; 31 return author + '@' + podHost
32 } 32 }
33 33
34 private static createDurationString(duration: number) { 34 private static createDurationString (duration: number) {
35 const minutes = Math.floor(duration / 60); 35 const minutes = Math.floor(duration / 60)
36 const seconds = duration % 60; 36 const seconds = duration % 60
37 const minutes_padding = minutes >= 10 ? '' : '0'; 37 const minutesPadding = minutes >= 10 ? '' : '0'
38 const seconds_padding = seconds >= 10 ? '' : '0'; 38 const secondsPadding = seconds >= 10 ? '' : '0'
39 39
40 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString(); 40 return minutesPadding + minutes.toString() + ':' + secondsPadding + seconds.toString()
41 } 41 }
42 42
43 constructor(hash: { 43 constructor (hash: {
44 author: string, 44 author: string,
45 createdAt: string, 45 createdAt: string,
46 categoryLabel: string, 46 categoryLabel: string,
47 category: number, 47 category: number,
48 licenceLabel: string, 48 licenceLabel: string,
49 licence: number, 49 licence: number,
50 languageLabel: string; 50 languageLabel: string
51 language: number; 51 language: number
52 description: string, 52 description: string,
53 duration: number; 53 duration: number
54 id: string, 54 id: string,
55 isLocal: boolean, 55 isLocal: boolean,
56 magnetUri: string, 56 magnetUri: string,
@@ -63,57 +63,57 @@ export class Video implements VideoServerModel {
63 dislikes: number, 63 dislikes: number,
64 nsfw: boolean 64 nsfw: boolean
65 }) { 65 }) {
66 this.author = hash.author; 66 this.author = hash.author
67 this.createdAt = new Date(hash.createdAt); 67 this.createdAt = new Date(hash.createdAt)
68 this.categoryLabel = hash.categoryLabel; 68 this.categoryLabel = hash.categoryLabel
69 this.category = hash.category; 69 this.category = hash.category
70 this.licenceLabel = hash.licenceLabel; 70 this.licenceLabel = hash.licenceLabel
71 this.licence = hash.licence; 71 this.licence = hash.licence
72 this.languageLabel = hash.languageLabel; 72 this.languageLabel = hash.languageLabel
73 this.language = hash.language; 73 this.language = hash.language
74 this.description = hash.description; 74 this.description = hash.description
75 this.duration = hash.duration; 75 this.duration = hash.duration
76 this.durationLabel = Video.createDurationString(hash.duration); 76 this.durationLabel = Video.createDurationString(hash.duration)
77 this.id = hash.id; 77 this.id = hash.id
78 this.isLocal = hash.isLocal; 78 this.isLocal = hash.isLocal
79 this.magnetUri = hash.magnetUri; 79 this.magnetUri = hash.magnetUri
80 this.name = hash.name; 80 this.name = hash.name
81 this.podHost = hash.podHost; 81 this.podHost = hash.podHost
82 this.tags = hash.tags; 82 this.tags = hash.tags
83 this.thumbnailPath = hash.thumbnailPath; 83 this.thumbnailPath = hash.thumbnailPath
84 this.thumbnailUrl = API_URL + hash.thumbnailPath; 84 this.thumbnailUrl = API_URL + hash.thumbnailPath
85 this.views = hash.views; 85 this.views = hash.views
86 this.likes = hash.likes; 86 this.likes = hash.likes
87 this.dislikes = hash.dislikes; 87 this.dislikes = hash.dislikes
88 this.nsfw = hash.nsfw; 88 this.nsfw = hash.nsfw
89 89
90 this.by = Video.createByString(hash.author, hash.podHost); 90 this.by = Video.createByString(hash.author, hash.podHost)
91 } 91 }
92 92
93 isRemovableBy(user) { 93 isRemovableBy (user) {
94 return user && this.isLocal === true && (this.author === user.username || user.isAdmin() === true); 94 return user && this.isLocal === true && (this.author === user.username || user.isAdmin() === true)
95 } 95 }
96 96
97 isBlackistableBy(user) { 97 isBlackistableBy (user) {
98 return user && user.isAdmin() === true && this.isLocal === false; 98 return user && user.isAdmin() === true && this.isLocal === false
99 } 99 }
100 100
101 isUpdatableBy(user) { 101 isUpdatableBy (user) {
102 return user && this.isLocal === true && user.username === this.author; 102 return user && this.isLocal === true && user.username === this.author
103 } 103 }
104 104
105 isVideoNSFWForUser(user: User) { 105 isVideoNSFWForUser (user: User) {
106 // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos... 106 // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos...
107 return (this.nsfw && (!user || user.displayNSFW === false)); 107 return (this.nsfw && (!user || user.displayNSFW === false))
108 } 108 }
109 109
110 patch(values: Object) { 110 patch (values: Object) {
111 Object.keys(values).forEach((key) => { 111 Object.keys(values).forEach((key) => {
112 this[key] = values[key]; 112 this[key] = values[key]
113 }); 113 })
114 } 114 }
115 115
116 toJSON() { 116 toJSON () {
117 return { 117 return {
118 author: this.author, 118 author: this.author,
119 createdAt: this.createdAt, 119 createdAt: this.createdAt,
@@ -133,6 +133,6 @@ export class Video implements VideoServerModel {
133 likes: this.likes, 133 likes: this.likes,
134 dislikes: this.dislikes, 134 dislikes: this.dislikes,
135 nsfw: this.nsfw 135 nsfw: this.nsfw
136 }; 136 }
137 } 137 }
138} 138}