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 { first, 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'
15 import { UserService } from '@app/shared'
16 import { LocalStorageService } from '@app/shared/misc/storage.service'
19 selector: 'my-video-channel-videos',
20 templateUrl: '../../shared/video/abstract-video-list.html',
22 '../../shared/video/abstract-video-list.scss',
23 './video-channel-videos.component.scss'
26 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
30 private videoChannel: VideoChannel
31 private videoChannelSub: Subscription
35 protected router: Router,
36 protected serverService: ServerService,
37 protected route: ActivatedRoute,
38 protected authService: AuthService,
39 protected userService: UserService,
40 protected notifier: Notifier,
41 protected confirmService: ConfirmService,
42 protected screenService: ScreenService,
43 protected storageService: LocalStorageService,
44 private videoChannelService: VideoChannelService,
45 private videoService: VideoService
49 this.titlePage = this.i18n('Published videos')
55 // Parent get the video channel for us
56 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
58 .subscribe(videoChannel => {
59 this.videoChannel = videoChannel
62 this.generateSyndicationList()
67 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
72 getVideosObservable (page: number) {
73 const newPagination = immutableAssign(this.pagination, { currentPage: page })
75 return this.videoService
76 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
79 this.titlePage = this.i18n(`{total, plural, =1 {Published 1 video} other {Published {{total}} videos}}`, { total })
84 generateSyndicationList () {
85 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)