diff options
author | Chocobozzz <me@florianbigard.com> | 2021-08-19 09:24:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-08-25 11:24:11 +0200 |
commit | dd24f1bb0a4b252e5342b251ba36853364da7b8e (patch) | |
tree | 41a9506d07413f056fb90425705e258f96fdc77d /client/src/app/+video-channels | |
parent | 2e80d256cc75b4b02c8efc3d3e4cdf57ddf401a8 (diff) | |
download | PeerTube-dd24f1bb0a4b252e5342b251ba36853364da7b8e.tar.gz PeerTube-dd24f1bb0a4b252e5342b251ba36853364da7b8e.tar.zst PeerTube-dd24f1bb0a4b252e5342b251ba36853364da7b8e.zip |
Add video filters to common video pages
Diffstat (limited to 'client/src/app/+video-channels')
3 files changed, 57 insertions, 67 deletions
diff --git a/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.html b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.html index b69d1682a..fa58963ce 100644 --- a/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.html +++ b/client/src/app/+video-channels/video-channel-playlists/video-channel-playlists.component.html | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | <div i18n class="no-results" *ngIf="pagination.totalItems === 0">This channel does not have playlists.</div> | 6 | <div i18n class="no-results" *ngIf="pagination.totalItems === 0">This channel does not have playlists.</div> |
7 | 7 | ||
8 | <div class="playlists" myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [autoInit]="true" [dataObservable]="onDataSubject.asObservable()"> | 8 | <div class="playlists" myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [dataObservable]="onDataSubject.asObservable()"> |
9 | <div *ngFor="let playlist of videoPlaylists" class="playlist-wrapper"> | 9 | <div *ngFor="let playlist of videoPlaylists" class="playlist-wrapper"> |
10 | <my-video-playlist-miniature [playlist]="playlist" [toManage]="false" [displayAsRow]="displayAsRow()"></my-video-playlist-miniature> | 10 | <my-video-playlist-miniature [playlist]="playlist" [toManage]="false" [displayAsRow]="displayAsRow()"></my-video-playlist-miniature> |
11 | </div> | 11 | </div> |
diff --git a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.html b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.html new file mode 100644 index 000000000..1b6b72f1e --- /dev/null +++ b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.html | |||
@@ -0,0 +1,21 @@ | |||
1 | <my-videos-list | ||
2 | *ngIf="videoChannel" | ||
3 | |||
4 | [title]="title" | ||
5 | [displayTitle]="false" | ||
6 | |||
7 | [getVideosObservableFunction]="getVideosObservableFunction" | ||
8 | [getSyndicationItemsFunction]="getSyndicationItemsFunction" | ||
9 | |||
10 | [defaultSort]="defaultSort" | ||
11 | |||
12 | [displayFilters]="true" | ||
13 | [displayModerationBlock]="true" | ||
14 | [displayOptions]="displayOptions" | ||
15 | [displayAsRow]="displayAsRow()" | ||
16 | |||
17 | [loadUserVideoPreferences]="true" | ||
18 | |||
19 | [disabled]="disabled" | ||
20 | > | ||
21 | </my-videos-list> | ||
diff --git a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts index ef8fd79b9..43fce475d 100644 --- a/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts +++ b/client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts | |||
@@ -1,27 +1,21 @@ | |||
1 | import { forkJoin, Subscription } from 'rxjs' | 1 | import { Subscription } from 'rxjs' |
2 | import { first } from 'rxjs/operators' | 2 | import { first } from 'rxjs/operators' |
3 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' | 3 | import { Component, OnDestroy, OnInit } from '@angular/core' |
4 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core' |
5 | import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core' | ||
6 | import { immutableAssign } from '@app/helpers' | ||
7 | import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' | 5 | import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' |
8 | import { AbstractVideoList, MiniatureDisplayOptions } from '@app/shared/shared-video-miniature' | 6 | import { MiniatureDisplayOptions, VideoFilters } from '@app/shared/shared-video-miniature' |
9 | import { VideoFilter } from '@shared/models' | 7 | import { VideoSortField } from '@shared/models/videos' |
10 | 8 | ||
11 | @Component({ | 9 | @Component({ |
12 | selector: 'my-video-channel-videos', | 10 | selector: 'my-video-channel-videos', |
13 | templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html', | 11 | templateUrl: './video-channel-videos.component.html' |
14 | styleUrls: [ | ||
15 | '../../shared/shared-video-miniature/abstract-video-list.scss' | ||
16 | ] | ||
17 | }) | 12 | }) |
18 | export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy { | 13 | export class VideoChannelVideosComponent implements OnInit, OnDestroy, DisableForReuseHook { |
19 | // No value because we don't want a page title | 14 | getVideosObservableFunction = this.getVideosObservable.bind(this) |
20 | titlePage: string | 15 | getSyndicationItemsFunction = this.getSyndicationItems.bind(this) |
21 | loadOnInit = false | ||
22 | loadUserVideoPreferences = true | ||
23 | 16 | ||
24 | filter: VideoFilter = null | 17 | title = $localize`Videos` |
18 | defaultSort = '-publishedAt' as VideoSortField | ||
25 | 19 | ||
26 | displayOptions: MiniatureDisplayOptions = { | 20 | displayOptions: MiniatureDisplayOptions = { |
27 | date: true, | 21 | date: true, |
@@ -34,80 +28,55 @@ export class VideoChannelVideosComponent extends AbstractVideoList implements On | |||
34 | blacklistInfo: false | 28 | blacklistInfo: false |
35 | } | 29 | } |
36 | 30 | ||
37 | private videoChannel: VideoChannel | 31 | videoChannel: VideoChannel |
32 | disabled = false | ||
33 | |||
38 | private videoChannelSub: Subscription | 34 | private videoChannelSub: Subscription |
39 | 35 | ||
40 | constructor ( | 36 | constructor ( |
41 | protected router: Router, | 37 | private screenService: ScreenService, |
42 | protected serverService: ServerService, | ||
43 | protected route: ActivatedRoute, | ||
44 | protected authService: AuthService, | ||
45 | protected userService: UserService, | ||
46 | protected notifier: Notifier, | ||
47 | protected confirmService: ConfirmService, | ||
48 | protected screenService: ScreenService, | ||
49 | protected storageService: LocalStorageService, | ||
50 | protected cfr: ComponentFactoryResolver, | ||
51 | private videoChannelService: VideoChannelService, | 38 | private videoChannelService: VideoChannelService, |
52 | private videoService: VideoService | 39 | private videoService: VideoService |
53 | ) { | 40 | ) { |
54 | super() | ||
55 | |||
56 | this.titlePage = $localize`Published videos` | ||
57 | this.displayOptions = { | ||
58 | ...this.displayOptions, | ||
59 | avatar: false | ||
60 | } | ||
61 | } | 41 | } |
62 | 42 | ||
63 | ngOnInit () { | 43 | ngOnInit () { |
64 | super.ngOnInit() | ||
65 | |||
66 | this.enableAllFilterIfPossible() | ||
67 | |||
68 | // Parent get the video channel for us | 44 | // Parent get the video channel for us |
69 | this.videoChannelSub = forkJoin([ | 45 | this.videoChannelService.videoChannelLoaded.pipe(first()) |
70 | this.videoChannelService.videoChannelLoaded.pipe(first()), | 46 | .subscribe(videoChannel => { |
71 | this.onUserLoadedSubject.pipe(first()) | 47 | this.videoChannel = videoChannel |
72 | ]).subscribe(([ videoChannel ]) => { | 48 | }) |
73 | this.videoChannel = videoChannel | ||
74 | |||
75 | this.reloadVideos() | ||
76 | this.generateSyndicationList() | ||
77 | }) | ||
78 | } | 49 | } |
79 | 50 | ||
80 | ngOnDestroy () { | 51 | ngOnDestroy () { |
81 | if (this.videoChannelSub) this.videoChannelSub.unsubscribe() | 52 | if (this.videoChannelSub) this.videoChannelSub.unsubscribe() |
82 | |||
83 | super.ngOnDestroy() | ||
84 | } | 53 | } |
85 | 54 | ||
86 | getVideosObservable (page: number) { | 55 | getVideosObservable (pagination: ComponentPaginationLight, filters: VideoFilters) { |
87 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | 56 | const params = { |
88 | const options = { | 57 | ...filters.toVideosAPIObject(), |
58 | |||
59 | videoPagination: pagination, | ||
89 | videoChannel: this.videoChannel, | 60 | videoChannel: this.videoChannel, |
90 | videoPagination: newPagination, | 61 | skipCount: true |
91 | sort: this.sort, | ||
92 | nsfwPolicy: this.nsfwPolicy, | ||
93 | videoFilter: this.filter | ||
94 | } | 62 | } |
95 | 63 | ||
96 | return this.videoService | 64 | return this.videoService.getVideoChannelVideos(params) |
97 | .getVideoChannelVideos(options) | ||
98 | } | 65 | } |
99 | 66 | ||
100 | generateSyndicationList () { | 67 | getSyndicationItems () { |
101 | this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id) | 68 | return this.videoService.getVideoChannelFeedUrls(this.videoChannel.id) |
102 | } | 69 | } |
103 | 70 | ||
104 | toggleModerationDisplay () { | 71 | displayAsRow () { |
105 | this.filter = this.buildLocalFilter(this.filter, null) | 72 | return this.screenService.isInMobileView() |
73 | } | ||
106 | 74 | ||
107 | this.reloadVideos() | 75 | disableForReuse () { |
76 | this.disabled = true | ||
108 | } | 77 | } |
109 | 78 | ||
110 | displayAsRow () { | 79 | enabledForReuse () { |
111 | return this.screenService.isInMobileView() | 80 | this.disabled = false |
112 | } | 81 | } |
113 | } | 82 | } |