aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-29 16:16:24 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-06-10 14:02:41 +0200
commit5fb2e2888ce032c638e4b75d07458642f0833e52 (patch)
tree8830d873569316889b8134027e9a43b198cca38f /client/src/app/shared/video
parent62e7be634bc189f942ae51cb4b080079ab503ff0 (diff)
downloadPeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.gz
PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.zst
PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.zip
First implem global search
Diffstat (limited to 'client/src/app/shared/video')
-rw-r--r--client/src/app/shared/video/video-miniature.component.html4
-rw-r--r--client/src/app/shared/video/video-miniature.component.ts38
-rw-r--r--client/src/app/shared/video/video.model.ts13
3 files changed, 42 insertions, 13 deletions
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html
index d354a2930..3e23cf18c 100644
--- a/client/src/app/shared/video/video-miniature.component.html
+++ b/client/src/app/shared/video/video-miniature.component.html
@@ -1,6 +1,6 @@
1<div class="video-miniature" [ngClass]="{ 'display-as-row': displayAsRow, 'fit-width': fitWidth }" (mouseenter)="loadActions()"> 1<div class="video-miniature" [ngClass]="{ 'display-as-row': displayAsRow, 'fit-width': fitWidth }" (mouseenter)="loadActions()">
2 <my-video-thumbnail 2 <my-video-thumbnail
3 [video]="video" [nsfw]="isVideoBlur" 3 [video]="video" [nsfw]="isVideoBlur" [routerLink]="videoLink"
4 [displayWatchLaterPlaylist]="isWatchLaterPlaylistDisplayed()" [inWatchLaterPlaylist]="inWatchLaterPlaylist" (watchLaterClick)="onWatchLaterClick($event)" 4 [displayWatchLaterPlaylist]="isWatchLaterPlaylistDisplayed()" [inWatchLaterPlaylist]="inWatchLaterPlaylist" (watchLaterClick)="onWatchLaterClick($event)"
5 > 5 >
6 <ng-container ngProjectAs="label-warning" *ngIf="displayOptions.privacyLabel && isUnlistedVideo()" i18n>Unlisted</ng-container> 6 <ng-container ngProjectAs="label-warning" *ngIf="displayOptions.privacyLabel && isUnlistedVideo()" i18n>Unlisted</ng-container>
@@ -12,7 +12,7 @@
12 <a 12 <a
13 tabindex="-1" 13 tabindex="-1"
14 class="video-miniature-name" 14 class="video-miniature-name"
15 [routerLink]="[ '/videos/watch', video.uuid ]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur }" 15 [routerLink]="videoLink" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur }"
16 >{{ video.name }}</a> 16 >{{ video.name }}</a>
17 17
18 <div class="d-inline-flex"> 18 <div class="d-inline-flex">
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts
index a1d4f0e81..aa1726ca7 100644
--- a/client/src/app/shared/video/video-miniature.component.ts
+++ b/client/src/app/shared/video/video-miniature.component.ts
@@ -1,3 +1,4 @@
1import { switchMap } from 'rxjs/operators'
1import { 2import {
2 ChangeDetectionStrategy, 3 ChangeDetectionStrategy,
3 ChangeDetectorRef, 4 ChangeDetectorRef,
@@ -9,15 +10,14 @@ import {
9 OnInit, 10 OnInit,
10 Output 11 Output
11} from '@angular/core' 12} from '@angular/core'
12import { User } from '../users'
13import { Video } from './video.model'
14import { AuthService, ServerService } from '@app/core' 13import { AuthService, ServerService } from '@app/core'
15import { ServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '../../../../../shared'
16import { I18n } from '@ngx-translate/i18n-polyfill'
17import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component'
18import { ScreenService } from '@app/shared/misc/screen.service' 14import { ScreenService } from '@app/shared/misc/screen.service'
19import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' 15import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
20import { switchMap } from 'rxjs/operators' 16import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component'
17import { I18n } from '@ngx-translate/i18n-polyfill'
18import { ServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '../../../../../shared'
19import { User } from '../users'
20import { Video } from './video.model'
21 21
22export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' 22export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto'
23export type MiniatureDisplayOptions = { 23export type MiniatureDisplayOptions = {
@@ -57,6 +57,8 @@ export class VideoMiniatureComponent implements OnInit {
57 @Input() displayVideoActions = true 57 @Input() displayVideoActions = true
58 @Input() fitWidth = false 58 @Input() fitWidth = false
59 59
60 @Input() useLazyLoadUrl = false
61
60 @Output() videoBlacklisted = new EventEmitter() 62 @Output() videoBlacklisted = new EventEmitter()
61 @Output() videoUnblacklisted = new EventEmitter() 63 @Output() videoUnblacklisted = new EventEmitter()
62 @Output() videoRemoved = new EventEmitter() 64 @Output() videoRemoved = new EventEmitter()
@@ -82,6 +84,8 @@ export class VideoMiniatureComponent implements OnInit {
82 playlistElementId?: number 84 playlistElementId?: number
83 } 85 }
84 86
87 videoLink: any[] = []
88
85 private ownerDisplayTypeChosen: 'account' | 'videoChannel' 89 private ownerDisplayTypeChosen: 'account' | 'videoChannel'
86 90
87 constructor ( 91 constructor (
@@ -103,7 +107,10 @@ export class VideoMiniatureComponent implements OnInit {
103 ngOnInit () { 107 ngOnInit () {
104 this.serverConfig = this.serverService.getTmpConfig() 108 this.serverConfig = this.serverService.getTmpConfig()
105 this.serverService.getConfig() 109 this.serverService.getConfig()
106 .subscribe(config => this.serverConfig = config) 110 .subscribe(config => {
111 this.serverConfig = config
112 this.buildVideoLink()
113 })
107 114
108 this.setUpBy() 115 this.setUpBy()
109 116
@@ -113,6 +120,21 @@ export class VideoMiniatureComponent implements OnInit {
113 } 120 }
114 } 121 }
115 122
123 buildVideoLink () {
124 if (this.useLazyLoadUrl && this.video.url) {
125 const remoteUriConfig = this.serverConfig.search.remoteUri
126
127 // Redirect on the external instance if not allowed to fetch remote data
128 const externalRedirect = (!this.authService.isLoggedIn() && !remoteUriConfig.anonymous) || !remoteUriConfig.users
129 const fromPath = window.location.pathname + window.location.search
130
131 this.videoLink = [ '/search/lazy-load-video', { url: this.video.url, externalRedirect, fromPath } ]
132 return
133 }
134
135 this.videoLink = [ '/videos/watch', this.video.uuid ]
136 }
137
116 displayOwnerAccount () { 138 displayOwnerAccount () {
117 return this.ownerDisplayTypeChosen === 'account' 139 return this.ownerDisplayTypeChosen === 'account'
118 } 140 }
@@ -203,7 +225,7 @@ export class VideoMiniatureComponent implements OnInit {
203 } 225 }
204 226
205 isWatchLaterPlaylistDisplayed () { 227 isWatchLaterPlaylistDisplayed () {
206 return this.isUserLoggedIn() && this.inWatchLaterPlaylist !== undefined 228 return this.displayVideoActions && this.isUserLoggedIn() && this.inWatchLaterPlaylist !== undefined
207 } 229 }
208 230
209 private setUpBy () { 231 private setUpBy () {
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts
index 546518cca..97759f9c1 100644
--- a/client/src/app/shared/video/video.model.ts
+++ b/client/src/app/shared/video/video.model.ts
@@ -33,10 +33,15 @@ export class Video implements VideoServerModel {
33 serverHost: string 33 serverHost: string
34 thumbnailPath: string 34 thumbnailPath: string
35 thumbnailUrl: string 35 thumbnailUrl: string
36
36 previewPath: string 37 previewPath: string
37 previewUrl: string 38 previewUrl: string
39
38 embedPath: string 40 embedPath: string
39 embedUrl: string 41 embedUrl: string
42
43 url?: string
44
40 views: number 45 views: number
41 likes: number 46 likes: number
42 dislikes: number 47 dislikes: number
@@ -100,13 +105,15 @@ export class Video implements VideoServerModel {
100 this.name = hash.name 105 this.name = hash.name
101 106
102 this.thumbnailPath = hash.thumbnailPath 107 this.thumbnailPath = hash.thumbnailPath
103 this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath 108 this.thumbnailUrl = hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath)
104 109
105 this.previewPath = hash.previewPath 110 this.previewPath = hash.previewPath
106 this.previewUrl = absoluteAPIUrl + hash.previewPath 111 this.previewUrl = hash.previewUrl || (absoluteAPIUrl + hash.previewPath)
107 112
108 this.embedPath = hash.embedPath 113 this.embedPath = hash.embedPath
109 this.embedUrl = absoluteAPIUrl + hash.embedPath 114 this.embedUrl = hash.embedUrl || (absoluteAPIUrl + hash.embedPath)
115
116 this.url = hash.url
110 117
111 this.views = hash.views 118 this.views = hash.views
112 this.likes = hash.likes 119 this.likes = hash.likes