diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-29 16:16:24 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-10 14:02:41 +0200 |
commit | 5fb2e2888ce032c638e4b75d07458642f0833e52 (patch) | |
tree | 8830d873569316889b8134027e9a43b198cca38f /client/src/app/shared/video/video-miniature.component.ts | |
parent | 62e7be634bc189f942ae51cb4b080079ab503ff0 (diff) | |
download | PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.gz PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.tar.zst PeerTube-5fb2e2888ce032c638e4b75d07458642f0833e52.zip |
First implem global search
Diffstat (limited to 'client/src/app/shared/video/video-miniature.component.ts')
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.ts | 38 |
1 files changed, 30 insertions, 8 deletions
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 @@ | |||
1 | import { switchMap } from 'rxjs/operators' | ||
1 | import { | 2 | import { |
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' |
12 | import { User } from '../users' | ||
13 | import { Video } from './video.model' | ||
14 | import { AuthService, ServerService } from '@app/core' | 13 | import { AuthService, ServerService } from '@app/core' |
15 | import { ServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '../../../../../shared' | ||
16 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
17 | import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component' | ||
18 | import { ScreenService } from '@app/shared/misc/screen.service' | 14 | import { ScreenService } from '@app/shared/misc/screen.service' |
19 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' | 15 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' |
20 | import { switchMap } from 'rxjs/operators' | 16 | import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component' |
17 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
18 | import { ServerConfig, VideoPlaylistType, VideoPrivacy, VideoState } from '../../../../../shared' | ||
19 | import { User } from '../users' | ||
20 | import { Video } from './video.model' | ||
21 | 21 | ||
22 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' | 22 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' |
23 | export type MiniatureDisplayOptions = { | 23 | export 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 () { |