diff options
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/users/user.model.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/video/abstract-video-list.ts | 27 | ||||
-rw-r--r-- | client/src/app/shared/video/video.service.ts | 22 |
3 files changed, 40 insertions, 10 deletions
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index 14d13959a..95a6ce9f9 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts | |||
@@ -18,6 +18,7 @@ export class User implements UserServerModel { | |||
18 | webTorrentEnabled: boolean | 18 | webTorrentEnabled: boolean |
19 | autoPlayVideo: boolean | 19 | autoPlayVideo: boolean |
20 | videosHistoryEnabled: boolean | 20 | videosHistoryEnabled: boolean |
21 | videoLanguages: string[] | ||
21 | 22 | ||
22 | videoQuota: number | 23 | videoQuota: number |
23 | videoQuotaDaily: number | 24 | videoQuotaDaily: number |
diff --git a/client/src/app/shared/video/abstract-video-list.ts b/client/src/app/shared/video/abstract-video-list.ts index dc8f9cda9..cf4b5ef8e 100644 --- a/client/src/app/shared/video/abstract-video-list.ts +++ b/client/src/app/shared/video/abstract-video-list.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { debounceTime } from 'rxjs/operators' | 1 | import { debounceTime, first, tap } from 'rxjs/operators' |
2 | import { OnDestroy, OnInit } from '@angular/core' | 2 | import { OnDestroy, OnInit } from '@angular/core' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { fromEvent, Observable, Subscription } from 'rxjs' | 4 | import { fromEvent, Observable, of, Subscription } from 'rxjs' |
5 | import { AuthService } from '../../core/auth' | 5 | import { AuthService } from '../../core/auth' |
6 | import { ComponentPagination } from '../rest/component-pagination.model' | 6 | import { ComponentPagination } from '../rest/component-pagination.model' |
7 | import { VideoSortField } from './sort-field.type' | 7 | import { VideoSortField } from './sort-field.type' |
@@ -32,18 +32,20 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor | |||
32 | sort: VideoSortField = '-publishedAt' | 32 | sort: VideoSortField = '-publishedAt' |
33 | 33 | ||
34 | categoryOneOf?: number | 34 | categoryOneOf?: number |
35 | languageOneOf?: string[] | ||
35 | defaultSort: VideoSortField = '-publishedAt' | 36 | defaultSort: VideoSortField = '-publishedAt' |
36 | 37 | ||
37 | syndicationItems: Syndication[] = [] | 38 | syndicationItems: Syndication[] = [] |
38 | 39 | ||
39 | loadOnInit = true | 40 | loadOnInit = true |
40 | videos: Video[] = [] | 41 | useUserVideoLanguagePreferences = false |
41 | ownerDisplayType: OwnerDisplayType = 'account' | 42 | ownerDisplayType: OwnerDisplayType = 'account' |
42 | displayModerationBlock = false | 43 | displayModerationBlock = false |
43 | titleTooltip: string | 44 | titleTooltip: string |
44 | displayVideoActions = true | 45 | displayVideoActions = true |
45 | groupByDate = false | 46 | groupByDate = false |
46 | 47 | ||
48 | videos: Video[] = [] | ||
47 | disabled = false | 49 | disabled = false |
48 | 50 | ||
49 | displayOptions: MiniatureDisplayOptions = { | 51 | displayOptions: MiniatureDisplayOptions = { |
@@ -98,7 +100,12 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor | |||
98 | .subscribe(() => this.calcPageSizes()) | 100 | .subscribe(() => this.calcPageSizes()) |
99 | 101 | ||
100 | this.calcPageSizes() | 102 | this.calcPageSizes() |
101 | if (this.loadOnInit === true) this.loadMoreVideos() | 103 | |
104 | const loadUserObservable = this.loadUserVideoLanguagesIfNeeded() | ||
105 | |||
106 | if (this.loadOnInit === true) { | ||
107 | loadUserObservable.subscribe(() => this.loadMoreVideos()) | ||
108 | } | ||
102 | } | 109 | } |
103 | 110 | ||
104 | ngOnDestroy () { | 111 | ngOnDestroy () { |
@@ -245,4 +252,16 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor | |||
245 | 252 | ||
246 | this.router.navigate([ path ], { queryParams, replaceUrl: true, queryParamsHandling: 'merge' }) | 253 | this.router.navigate([ path ], { queryParams, replaceUrl: true, queryParamsHandling: 'merge' }) |
247 | } | 254 | } |
255 | |||
256 | private loadUserVideoLanguagesIfNeeded () { | ||
257 | if (!this.authService.isLoggedIn() || !this.useUserVideoLanguagePreferences) { | ||
258 | return of(true) | ||
259 | } | ||
260 | |||
261 | return this.authService.userInformationLoaded | ||
262 | .pipe( | ||
263 | first(), | ||
264 | tap(() => this.languageOneOf = this.user.videoLanguages) | ||
265 | ) | ||
266 | } | ||
248 | } | 267 | } |
diff --git a/client/src/app/shared/video/video.service.ts b/client/src/app/shared/video/video.service.ts index ef489648c..871bc9e46 100644 --- a/client/src/app/shared/video/video.service.ts +++ b/client/src/app/shared/video/video.service.ts | |||
@@ -35,12 +35,13 @@ import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model' | |||
35 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' | 35 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' |
36 | 36 | ||
37 | export interface VideosProvider { | 37 | export interface VideosProvider { |
38 | getVideos ( | 38 | getVideos (parameters: { |
39 | videoPagination: ComponentPagination, | 39 | videoPagination: ComponentPagination, |
40 | sort: VideoSortField, | 40 | sort: VideoSortField, |
41 | filter?: VideoFilter, | 41 | filter?: VideoFilter, |
42 | categoryOneOf?: number | 42 | categoryOneOf?: number, |
43 | ): Observable<{ videos: Video[], totalVideos: number }> | 43 | languageOneOf?: string[] |
44 | }): Observable<{ videos: Video[], totalVideos: number }> | ||
44 | } | 45 | } |
45 | 46 | ||
46 | @Injectable() | 47 | @Injectable() |
@@ -206,12 +207,15 @@ export class VideoService implements VideosProvider { | |||
206 | ) | 207 | ) |
207 | } | 208 | } |
208 | 209 | ||
209 | getVideos ( | 210 | getVideos (parameters: { |
210 | videoPagination: ComponentPagination, | 211 | videoPagination: ComponentPagination, |
211 | sort: VideoSortField, | 212 | sort: VideoSortField, |
212 | filter?: VideoFilter, | 213 | filter?: VideoFilter, |
213 | categoryOneOf?: number | 214 | categoryOneOf?: number, |
214 | ): Observable<{ videos: Video[], totalVideos: number }> { | 215 | languageOneOf?: string[] |
216 | }): Observable<{ videos: Video[], totalVideos: number }> { | ||
217 | const { videoPagination, sort, filter, categoryOneOf, languageOneOf } = parameters | ||
218 | |||
215 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) | 219 | const pagination = this.restService.componentPaginationToRestPagination(videoPagination) |
216 | 220 | ||
217 | let params = new HttpParams() | 221 | let params = new HttpParams() |
@@ -225,6 +229,12 @@ export class VideoService implements VideosProvider { | |||
225 | params = params.set('categoryOneOf', categoryOneOf + '') | 229 | params = params.set('categoryOneOf', categoryOneOf + '') |
226 | } | 230 | } |
227 | 231 | ||
232 | if (languageOneOf) { | ||
233 | for (const l of languageOneOf) { | ||
234 | params = params.append('languageOneOf[]', l) | ||
235 | } | ||
236 | } | ||
237 | |||
228 | return this.authHttp | 238 | return this.authHttp |
229 | .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params }) | 239 | .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params }) |
230 | .pipe( | 240 | .pipe( |