]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
629fd4450b9762714b4df3bd423c725f1cf032e9
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channel-videos / video-channel-videos.component.ts
1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { immutableAssign } from '@app/shared/misc/utils'
4 import { AuthService } from '../../core/auth'
5 import { ConfirmService } from '../../core/confirm'
6 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7 import { VideoService } from '../../shared/video/video.service'
8 import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
9 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
10 import { first, tap } from 'rxjs/operators'
11 import { I18n } from '@ngx-translate/i18n-polyfill'
12 import { Subscription } from 'rxjs'
13 import { ScreenService } from '@app/shared/misc/screen.service'
14 import { Notifier, ServerService } from '@app/core'
15
16 @Component({
17 selector: 'my-video-channel-videos',
18 templateUrl: '../../shared/video/abstract-video-list.html',
19 styleUrls: [
20 '../../shared/video/abstract-video-list.scss',
21 './video-channel-videos.component.scss'
22 ]
23 })
24 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
25 titlePage: string
26 loadOnInit = false
27
28 private videoChannel: VideoChannel
29 private videoChannelSub: Subscription
30
31 constructor (
32 protected i18n: I18n,
33 protected router: Router,
34 protected serverService: ServerService,
35 protected route: ActivatedRoute,
36 protected authService: AuthService,
37 protected notifier: Notifier,
38 protected confirmService: ConfirmService,
39 protected screenService: ScreenService,
40 private videoChannelService: VideoChannelService,
41 private videoService: VideoService
42 ) {
43 super()
44
45 this.titlePage = this.i18n('Published videos')
46 }
47
48 ngOnInit () {
49 super.ngOnInit()
50
51 // Parent get the video channel for us
52 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
53 .pipe(first())
54 .subscribe(videoChannel => {
55 this.videoChannel = videoChannel
56
57 this.reloadVideos()
58 this.generateSyndicationList()
59 })
60 }
61
62 ngOnDestroy () {
63 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
64
65 super.ngOnDestroy()
66 }
67
68 getVideosObservable (page: number) {
69 const newPagination = immutableAssign(this.pagination, { currentPage: page })
70
71 return this.videoService
72 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
73 .pipe(
74 tap(({ totalVideos }) => {
75 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
76 })
77 )
78 }
79
80 generateSyndicationList () {
81 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
82 }
83 }