diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-03 16:17:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-03 16:17:41 +0200 |
commit | e2409062dedf8856c56ef1bdc98ca623e21c4f3b (patch) | |
tree | c86f7fcbffdaa610bbadb5a4f9abf28d2acd0cdc /client/src/app/shared/video/video-miniature.component.ts | |
parent | 8fc02e476869276d35759d19248ddfe7f84ec09c (diff) | |
download | PeerTube-e2409062dedf8856c56ef1bdc98ca623e21c4f3b.tar.gz PeerTube-e2409062dedf8856c56ef1bdc98ca623e21c4f3b.tar.zst PeerTube-e2409062dedf8856c56ef1bdc98ca623e21c4f3b.zip |
Refactor video miniatures
Diffstat (limited to 'client/src/app/shared/video/video-miniature.component.ts')
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.ts | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts index 2f951a1f1..800417a79 100644 --- a/client/src/app/shared/video/video-miniature.component.ts +++ b/client/src/app/shared/video/video-miniature.component.ts | |||
@@ -1,10 +1,21 @@ | |||
1 | import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core' | 1 | import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit } from '@angular/core' |
2 | import { User } from '../users' | 2 | import { User } from '../users' |
3 | import { Video } from './video.model' | 3 | import { Video } from './video.model' |
4 | import { ServerService } from '@app/core' | 4 | import { ServerService } from '@app/core' |
5 | import { VideoPrivacy } from '../../../../../shared' | 5 | import { VideoPrivacy, VideoState } from '../../../../../shared' |
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
6 | 7 | ||
7 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' | 8 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' |
9 | export type MiniatureDisplayOptions = { | ||
10 | date?: boolean | ||
11 | views?: boolean | ||
12 | by?: boolean | ||
13 | privacyLabel?: boolean | ||
14 | privacyText?: boolean | ||
15 | state?: boolean | ||
16 | blacklistInfo?: boolean | ||
17 | nsfw?: boolean | ||
18 | } | ||
8 | 19 | ||
9 | @Component({ | 20 | @Component({ |
10 | selector: 'my-video-miniature', | 21 | selector: 'my-video-miniature', |
@@ -15,11 +26,26 @@ export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' | |||
15 | export class VideoMiniatureComponent implements OnInit { | 26 | export class VideoMiniatureComponent implements OnInit { |
16 | @Input() user: User | 27 | @Input() user: User |
17 | @Input() video: Video | 28 | @Input() video: Video |
29 | |||
18 | @Input() ownerDisplayType: OwnerDisplayType = 'account' | 30 | @Input() ownerDisplayType: OwnerDisplayType = 'account' |
31 | @Input() displayOptions: MiniatureDisplayOptions = { | ||
32 | date: true, | ||
33 | views: true, | ||
34 | by: true, | ||
35 | privacyLabel: false, | ||
36 | privacyText: false, | ||
37 | state: false, | ||
38 | blacklistInfo: false | ||
39 | } | ||
40 | @Input() displayAsRow = false | ||
19 | 41 | ||
20 | private ownerDisplayTypeChosen: 'account' | 'videoChannel' | 42 | private ownerDisplayTypeChosen: 'account' | 'videoChannel' |
21 | 43 | ||
22 | constructor (private serverService: ServerService) { } | 44 | constructor ( |
45 | private serverService: ServerService, | ||
46 | private i18n: I18n, | ||
47 | @Inject(LOCALE_ID) private localeId: string | ||
48 | ) { } | ||
23 | 49 | ||
24 | get isVideoBlur () { | 50 | get isVideoBlur () { |
25 | return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) | 51 | return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) |
@@ -58,4 +84,29 @@ export class VideoMiniatureComponent implements OnInit { | |||
58 | isPrivateVideo () { | 84 | isPrivateVideo () { |
59 | return this.video.privacy.id === VideoPrivacy.PRIVATE | 85 | return this.video.privacy.id === VideoPrivacy.PRIVATE |
60 | } | 86 | } |
87 | |||
88 | getStateLabel (video: Video) { | ||
89 | if (video.privacy.id !== VideoPrivacy.PRIVATE && video.state.id === VideoState.PUBLISHED) { | ||
90 | return this.i18n('Published') | ||
91 | } | ||
92 | |||
93 | if (video.scheduledUpdate) { | ||
94 | const updateAt = new Date(video.scheduledUpdate.updateAt.toString()).toLocaleString(this.localeId) | ||
95 | return this.i18n('Publication scheduled on ') + updateAt | ||
96 | } | ||
97 | |||
98 | if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) { | ||
99 | return this.i18n('Waiting transcoding') | ||
100 | } | ||
101 | |||
102 | if (video.state.id === VideoState.TO_TRANSCODE) { | ||
103 | return this.i18n('To transcode') | ||
104 | } | ||
105 | |||
106 | if (video.state.id === VideoState.TO_IMPORT) { | ||
107 | return this.i18n('To import') | ||
108 | } | ||
109 | |||
110 | return '' | ||
111 | } | ||
61 | } | 112 | } |