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 import { I18n } from '@ngx-translate/i18n-polyfill'
14 import { Subscription } from 'rxjs'
15 import { ScreenService } from '@app/shared/misc/screen.service'
18 selector: 'my-video-channel-videos',
19 templateUrl: '../../shared/video/abstract-video-list.html',
21 '../../shared/video/abstract-video-list.scss',
22 './video-channel-videos.component.scss'
25 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
27 marginContent = false // Disable margin
28 currentRoute = '/video-channel/videos'
31 private videoChannel: VideoChannel
32 private videoChannelSub: Subscription
35 protected router: Router,
36 protected route: ActivatedRoute,
37 protected authService: AuthService,
38 protected notificationsService: NotificationsService,
39 protected confirmService: ConfirmService,
40 protected location: Location,
41 protected screenService: ScreenService,
43 private videoChannelService: VideoChannelService,
44 private videoService: VideoService
48 this.titlePage = this.i18n('Published videos')
54 // Parent get the video channel for us
55 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
56 .subscribe(videoChannel => {
57 this.videoChannel = videoChannel
58 this.currentRoute = '/video-channel/' + this.videoChannel.uuid + '/videos'
61 this.generateSyndicationList()
66 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
71 getVideosObservable (page: number) {
72 const newPagination = immutableAssign(this.pagination, { currentPage: page })
74 return this.videoService
75 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
77 tap(({ totalVideos }) => {
78 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
83 generateSyndicationList () {
84 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)