]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
Upgrade to rxjs 6
[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 { Location } from '@angular/common'
4 import { immutableAssign } from '@app/shared/misc/utils'
5 import { NotificationsService } from 'angular2-notifications'
6 import { AuthService } from '../../core/auth'
7 import { ConfirmService } from '../../core/confirm'
8 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
9 import { VideoService } from '../../shared/video/video.service'
10 import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
11 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
12
13 @Component({
14 selector: 'my-video-channel-videos',
15 templateUrl: '../../shared/video/abstract-video-list.html',
16 styleUrls: [
17 '../../shared/video/abstract-video-list.scss',
18 './video-channel-videos.component.scss'
19 ]
20 })
21 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
22 titlePage = 'Published videos'
23 marginContent = false // Disable margin
24 currentRoute = '/video-channel/videos'
25 loadOnInit = false
26
27 private videoChannel: VideoChannel
28
29 constructor (
30 protected router: Router,
31 protected route: ActivatedRoute,
32 protected authService: AuthService,
33 protected notificationsService: NotificationsService,
34 protected confirmService: ConfirmService,
35 protected location: Location,
36 private videoChannelService: VideoChannelService,
37 private videoService: VideoService
38 ) {
39 super()
40 }
41
42 ngOnInit () {
43 super.ngOnInit()
44
45 // Parent get the video channel for us
46 this.videoChannelService.videoChannelLoaded
47 .subscribe(videoChannel => {
48 this.videoChannel = videoChannel
49 this.currentRoute = '/video-channel/' + this.videoChannel.uuid + '/videos'
50
51 this.loadMoreVideos(this.pagination.currentPage)
52 this.generateSyndicationList()
53 })
54 }
55
56 ngOnDestroy () {
57 super.ngOnDestroy()
58 }
59
60 getVideosObservable (page: number) {
61 const newPagination = immutableAssign(this.pagination, { currentPage: page })
62
63 return this.videoService.getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
64 }
65
66 generateSyndicationList () {
67 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
68 }
69 }