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