]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
`fitWidth` for `video-miniature`, fluid grid (#2830)
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channel-videos / video-channel-videos.component.ts
CommitLineData
0626e7af
C
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
0626e7af 3import { immutableAssign } from '@app/shared/misc/utils'
0626e7af
C
4import { AuthService } from '../../core/auth'
5import { ConfirmService } from '../../core/confirm'
6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7import { VideoService } from '../../shared/video/video.service'
170726f5
C
8import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
9import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
722bca90 10import { first, tap } from 'rxjs/operators'
b1d40cff 11import { I18n } from '@ngx-translate/i18n-polyfill'
734a5ceb 12import { Subscription } from 'rxjs'
bbe0f064 13import { ScreenService } from '@app/shared/misc/screen.service'
489290b8 14import { Notifier, ServerService } from '@app/core'
d3217560
RK
15import { UserService } from '@app/shared'
16import { LocalStorageService } from '@app/shared/misc/storage.service'
0626e7af
C
17
18@Component({
170726f5 19 selector: 'my-video-channel-videos',
0626e7af
C
20 templateUrl: '../../shared/video/abstract-video-list.html',
21 styleUrls: [
22 '../../shared/video/abstract-video-list.scss',
170726f5 23 './video-channel-videos.component.scss'
0626e7af
C
24 ]
25})
170726f5 26export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
b1d40cff 27 titlePage: string
0626e7af
C
28 loadOnInit = false
29
170726f5 30 private videoChannel: VideoChannel
734a5ceb 31 private videoChannelSub: Subscription
0626e7af
C
32
33 constructor (
34c7f429 34 protected i18n: I18n,
0626e7af 35 protected router: Router,
489290b8 36 protected serverService: ServerService,
0626e7af
C
37 protected route: ActivatedRoute,
38 protected authService: AuthService,
d3217560 39 protected userService: UserService,
f8b2c1b4 40 protected notifier: Notifier,
0626e7af 41 protected confirmService: ConfirmService,
bbe0f064 42 protected screenService: ScreenService,
d3217560 43 protected storageService: LocalStorageService,
170726f5 44 private videoChannelService: VideoChannelService,
0626e7af
C
45 private videoService: VideoService
46 ) {
47 super()
b1d40cff
C
48
49 this.titlePage = this.i18n('Published videos')
e66883b3
RK
50 this.displayOptions = {
51 ...this.displayOptions,
52 avatar: false
53 }
0626e7af
C
54 }
55
56 ngOnInit () {
57 super.ngOnInit()
58
170726f5 59 // Parent get the video channel for us
734a5ceb 60 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
722bca90
C
61 .pipe(first())
62 .subscribe(videoChannel => {
63 this.videoChannel = videoChannel
0626e7af 64
722bca90
C
65 this.reloadVideos()
66 this.generateSyndicationList()
67 })
0626e7af
C
68 }
69
70 ngOnDestroy () {
734a5ceb
C
71 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
72
0626e7af
C
73 super.ngOnDestroy()
74 }
75
76 getVideosObservable (page: number) {
77 const newPagination = immutableAssign(this.pagination, { currentPage: page })
78
0bf1f265
C
79 return this.videoService
80 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
b1d40cff 81 .pipe(
93cae479 82 tap(({ total }) => {
0b1de586 83 this.titlePage = this.i18n(`{total, plural, =1 {Published 1 video} other {Published {{total}} videos}}`, { total })
b1d40cff
C
84 })
85 )
0626e7af
C
86 }
87
88 generateSyndicationList () {
170726f5 89 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
0626e7af
C
90 }
91}