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 { 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'
17 selector: 'my-video-channel-videos',
18 templateUrl: '../../shared/video/abstract-video-list.html',
20 '../../shared/video/abstract-video-list.scss',
21 './video-channel-videos.component.scss'
24 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
26 marginContent = false // Disable margin
29 private videoChannel: VideoChannel
30 private videoChannelSub: Subscription
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,
41 private videoChannelService: VideoChannelService,
42 private videoService: VideoService
46 this.titlePage = this.i18n('Published videos')
52 // Parent get the video channel for us
53 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
54 .subscribe(videoChannel => {
55 this.videoChannel = videoChannel
58 this.generateSyndicationList()
63 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
68 getVideosObservable (page: number) {
69 const newPagination = immutableAssign(this.pagination, { currentPage: page })
71 return this.videoService
72 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
74 tap(({ totalVideos }) => {
75 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
80 generateSyndicationList () {
81 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)