diff options
Diffstat (limited to 'client/src/app/videos/shared/video.model.ts')
-rw-r--r-- | client/src/app/videos/shared/video.model.ts | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/client/src/app/videos/shared/video.model.ts b/client/src/app/videos/shared/video.model.ts deleted file mode 100644 index 0dd41d71b..000000000 --- a/client/src/app/videos/shared/video.model.ts +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | import { Video as VideoServerModel } from '../../../../../shared' | ||
2 | import { User } from '../../shared' | ||
3 | |||
4 | export class Video implements VideoServerModel { | ||
5 | account: string | ||
6 | by: string | ||
7 | createdAt: Date | ||
8 | updatedAt: Date | ||
9 | categoryLabel: string | ||
10 | category: number | ||
11 | licenceLabel: string | ||
12 | licence: number | ||
13 | languageLabel: string | ||
14 | language: number | ||
15 | description: string | ||
16 | duration: number | ||
17 | durationLabel: string | ||
18 | id: number | ||
19 | uuid: string | ||
20 | isLocal: boolean | ||
21 | name: string | ||
22 | serverHost: string | ||
23 | tags: string[] | ||
24 | thumbnailPath: string | ||
25 | thumbnailUrl: string | ||
26 | previewPath: string | ||
27 | previewUrl: string | ||
28 | embedPath: string | ||
29 | embedUrl: string | ||
30 | views: number | ||
31 | likes: number | ||
32 | dislikes: number | ||
33 | nsfw: boolean | ||
34 | |||
35 | private static createByString (account: string, serverHost: string) { | ||
36 | return account + '@' + serverHost | ||
37 | } | ||
38 | |||
39 | private static createDurationString (duration: number) { | ||
40 | const minutes = Math.floor(duration / 60) | ||
41 | const seconds = duration % 60 | ||
42 | const minutesPadding = minutes >= 10 ? '' : '0' | ||
43 | const secondsPadding = seconds >= 10 ? '' : '0' | ||
44 | |||
45 | return minutesPadding + minutes.toString() + ':' + secondsPadding + seconds.toString() | ||
46 | } | ||
47 | |||
48 | constructor (hash: VideoServerModel) { | ||
49 | let absoluteAPIUrl = API_URL | ||
50 | if (!absoluteAPIUrl) { | ||
51 | // The API is on the same domain | ||
52 | absoluteAPIUrl = window.location.origin | ||
53 | } | ||
54 | |||
55 | this.account = hash.account | ||
56 | this.createdAt = new Date(hash.createdAt.toString()) | ||
57 | this.categoryLabel = hash.categoryLabel | ||
58 | this.category = hash.category | ||
59 | this.licenceLabel = hash.licenceLabel | ||
60 | this.licence = hash.licence | ||
61 | this.languageLabel = hash.languageLabel | ||
62 | this.language = hash.language | ||
63 | this.description = hash.description | ||
64 | this.duration = hash.duration | ||
65 | this.durationLabel = Video.createDurationString(hash.duration) | ||
66 | this.id = hash.id | ||
67 | this.uuid = hash.uuid | ||
68 | this.isLocal = hash.isLocal | ||
69 | this.name = hash.name | ||
70 | this.serverHost = hash.serverHost | ||
71 | this.tags = hash.tags | ||
72 | this.thumbnailPath = hash.thumbnailPath | ||
73 | this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath | ||
74 | this.previewPath = hash.previewPath | ||
75 | this.previewUrl = absoluteAPIUrl + hash.previewPath | ||
76 | this.embedPath = hash.embedPath | ||
77 | this.embedUrl = absoluteAPIUrl + hash.embedPath | ||
78 | this.views = hash.views | ||
79 | this.likes = hash.likes | ||
80 | this.dislikes = hash.dislikes | ||
81 | this.nsfw = hash.nsfw | ||
82 | |||
83 | this.by = Video.createByString(hash.account, hash.serverHost) | ||
84 | } | ||
85 | |||
86 | isVideoNSFWForUser (user: User) { | ||
87 | // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos... | ||
88 | return (this.nsfw && (!user || user.displayNSFW === false)) | ||
89 | } | ||
90 | } | ||