]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
Add video filters to common video pages
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channel-videos / video-channel-videos.component.ts
CommitLineData
dd24f1bb 1import { Subscription } from 'rxjs'
9df52d66 2import { first } from 'rxjs/operators'
dd24f1bb
C
3import { Component, OnDestroy, OnInit } from '@angular/core'
4import { ComponentPaginationLight, DisableForReuseHook, ScreenService } from '@app/core'
67ed6552 5import { VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
dd24f1bb
C
6import { MiniatureDisplayOptions, VideoFilters } from '@app/shared/shared-video-miniature'
7import { VideoSortField } from '@shared/models/videos'
0626e7af
C
8
9@Component({
170726f5 10 selector: 'my-video-channel-videos',
dd24f1bb 11 templateUrl: './video-channel-videos.component.html'
0626e7af 12})
dd24f1bb
C
13export class VideoChannelVideosComponent implements OnInit, OnDestroy, DisableForReuseHook {
14 getVideosObservableFunction = this.getVideosObservable.bind(this)
15 getSyndicationItemsFunction = this.getSyndicationItems.bind(this)
0626e7af 16
dd24f1bb
C
17 title = $localize`Videos`
18 defaultSort = '-publishedAt' as VideoSortField
0aa52e17 19
900f7820
C
20 displayOptions: MiniatureDisplayOptions = {
21 date: true,
22 views: true,
23 by: false,
24 avatar: false,
25 privacyLabel: true,
26 privacyText: false,
27 state: false,
28 blacklistInfo: false
29 }
30
dd24f1bb
C
31 videoChannel: VideoChannel
32 disabled = false
33
734a5ceb 34 private videoChannelSub: Subscription
0626e7af
C
35
36 constructor (
dd24f1bb 37 private screenService: ScreenService,
170726f5 38 private videoChannelService: VideoChannelService,
0626e7af
C
39 private videoService: VideoService
40 ) {
0626e7af
C
41 }
42
43 ngOnInit () {
170726f5 44 // Parent get the video channel for us
dd24f1bb
C
45 this.videoChannelService.videoChannelLoaded.pipe(first())
46 .subscribe(videoChannel => {
47 this.videoChannel = videoChannel
48 })
0626e7af
C
49 }
50
51 ngOnDestroy () {
734a5ceb 52 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
0626e7af
C
53 }
54
dd24f1bb
C
55 getVideosObservable (pagination: ComponentPaginationLight, filters: VideoFilters) {
56 const params = {
57 ...filters.toVideosAPIObject(),
58
59 videoPagination: pagination,
0aa52e17 60 videoChannel: this.videoChannel,
dd24f1bb 61 skipCount: true
0aa52e17 62 }
0626e7af 63
dd24f1bb 64 return this.videoService.getVideoChannelVideos(params)
0626e7af
C
65 }
66
dd24f1bb
C
67 getSyndicationItems () {
68 return this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
0626e7af 69 }
0aa52e17 70
dd24f1bb
C
71 displayAsRow () {
72 return this.screenService.isInMobileView()
73 }
0aa52e17 74
dd24f1bb
C
75 disableForReuse () {
76 this.disabled = true
0aa52e17 77 }
4d5e572f 78
dd24f1bb
C
79 enabledForReuse () {
80 this.disabled = false
4d5e572f 81 }
0626e7af 82}