From e2409062dedf8856c56ef1bdc98ca623e21c4f3b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 3 Apr 2019 16:17:41 +0200 Subject: Refactor video miniatures --- .../shared/video/video-miniature.component.html | 34 +++++++++-- .../shared/video/video-miniature.component.scss | 68 +++++++++++++++++++++- .../app/shared/video/video-miniature.component.ts | 57 +++++++++++++++++- 3 files changed, 147 insertions(+), 12 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html index 2c635fa2f..f4ae0b0dd 100644 --- a/client/src/app/shared/video/video-miniature.component.html +++ b/client/src/app/shared/video/video-miniature.component.html @@ -1,4 +1,4 @@ -
+
@@ -7,19 +7,41 @@ class="video-miniature-name" [routerLink]="[ '/videos/watch', video.uuid ]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur }" > - Unlisted - Private + + Unlisted + Private + {{ video.name }} - {{ video.publishedAt | myFromNow }} - {{ video.views | myNumberFormatter }} views + + {{ video.publishedAt | myFromNow }} + - + {{ video.views | myNumberFormatter }} views + - - + {{ video.byVideoChannel }} + +
+ {{ video.privacy.label }} + - + {{ getStateLabel(video) }} +
+ +
+ Blacklisted + {{ video.blacklistedReason }} +
+ +
+ Sensitive +
+
diff --git a/client/src/app/shared/video/video-miniature.component.scss b/client/src/app/shared/video/video-miniature.component.scss index 4799e00c2..fdc3dc033 100644 --- a/client/src/app/shared/video/video-miniature.component.scss +++ b/client/src/app/shared/video/video-miniature.component.scss @@ -4,15 +4,14 @@ .video-miniature { width: $video-miniature-width; - - display: inline-block; + display: inline-flex; + flex-direction: column; margin-bottom: 30px; height: 195px; vertical-align: top; .video-miniature-information { width: 200px; - margin-top: 2px; line-height: normal; .video-miniature-name { @@ -37,5 +36,68 @@ color: $grey-foreground-hover-color; } } + + .video-info-privacy, + .video-info-blacklisted .blacklisted-label, + .video-info-nsfw { + font-weight: $font-semibold; + } + + .video-info-blacklisted { + color: red; + + .blacklisted-reason::before { + content: ' - '; + } + } + + .video-info-nsfw { + color: red; + } + } + + &.display-as-row { + flex-direction: row; + margin-bottom: 0; + height: auto; + width: 100%; + + my-video-thumbnail { + margin-right: 10px; + } + + .video-miniature-information { + width: auto; + + .video-miniature-name { + @include ellipsis-multiline(1.3em, 2); + + margin-top: 2px; + margin-bottom: 5px; + } + + .video-miniature-created-at-views, + .video-miniature-account, + .video-miniature-channel { + font-size: 14px; + } + + .video-info-privacy { + margin-top: 5px; + } + + .video-info-blacklisted { + margin-top: 3px; + } + } + + @media screen and (max-width: $small-view) { + flex-direction: column; + height: auto; + + my-video-thumbnail { + margin-right: 0; + } + } } } 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 @@ -import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core' +import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit } from '@angular/core' import { User } from '../users' import { Video } from './video.model' import { ServerService } from '@app/core' -import { VideoPrivacy } from '../../../../../shared' +import { VideoPrivacy, VideoState } from '../../../../../shared' +import { I18n } from '@ngx-translate/i18n-polyfill' export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' +export type MiniatureDisplayOptions = { + date?: boolean + views?: boolean + by?: boolean + privacyLabel?: boolean + privacyText?: boolean + state?: boolean + blacklistInfo?: boolean + nsfw?: boolean +} @Component({ selector: 'my-video-miniature', @@ -15,11 +26,26 @@ export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' export class VideoMiniatureComponent implements OnInit { @Input() user: User @Input() video: Video + @Input() ownerDisplayType: OwnerDisplayType = 'account' + @Input() displayOptions: MiniatureDisplayOptions = { + date: true, + views: true, + by: true, + privacyLabel: false, + privacyText: false, + state: false, + blacklistInfo: false + } + @Input() displayAsRow = false private ownerDisplayTypeChosen: 'account' | 'videoChannel' - constructor (private serverService: ServerService) { } + constructor ( + private serverService: ServerService, + private i18n: I18n, + @Inject(LOCALE_ID) private localeId: string + ) { } get isVideoBlur () { return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) @@ -58,4 +84,29 @@ export class VideoMiniatureComponent implements OnInit { isPrivateVideo () { return this.video.privacy.id === VideoPrivacy.PRIVATE } + + getStateLabel (video: Video) { + if (video.privacy.id !== VideoPrivacy.PRIVATE && video.state.id === VideoState.PUBLISHED) { + return this.i18n('Published') + } + + if (video.scheduledUpdate) { + const updateAt = new Date(video.scheduledUpdate.updateAt.toString()).toLocaleString(this.localeId) + return this.i18n('Publication scheduled on ') + updateAt + } + + if (video.state.id === VideoState.TO_TRANSCODE && video.waitTranscoding === true) { + return this.i18n('Waiting transcoding') + } + + if (video.state.id === VideoState.TO_TRANSCODE) { + return this.i18n('To transcode') + } + + if (video.state.id === VideoState.TO_IMPORT) { + return this.i18n('To import') + } + + return '' + } } -- cgit v1.2.3