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'
15 selector: 'my-video-channel-videos',
16 templateUrl: '../../shared/video/abstract-video-list.html',
18 '../../shared/video/abstract-video-list.scss',
19 './video-channel-videos.component.scss'
22 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
23 titlePage = 'Published videos'
24 marginContent = false // Disable margin
25 currentRoute = '/video-channel/videos'
28 private videoChannel: VideoChannel
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
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'
52 this.loadMoreVideos(this.pagination.currentPage)
53 this.generateSyndicationList()
61 getVideosObservable (page: number) {
62 const newPagination = immutableAssign(this.pagination, { currentPage: page })
64 return this.videoService
65 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
66 .pipe(tap(({ totalVideos }) => this.titlePage = `Published ${totalVideos} videos`))
69 generateSyndicationList () {
70 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)