]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - 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
1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
3import { immutableAssign } from '@app/shared/misc/utils'
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'
8import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
9import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
10import { first, tap } from 'rxjs/operators'
11import { I18n } from '@ngx-translate/i18n-polyfill'
12import { Subscription } from 'rxjs'
13import { ScreenService } from '@app/shared/misc/screen.service'
14import { Notifier, ServerService } from '@app/core'
15import { UserService } from '@app/shared'
16import { LocalStorageService } from '@app/shared/misc/storage.service'
17
18@Component({
19 selector: 'my-video-channel-videos',
20 templateUrl: '../../shared/video/abstract-video-list.html',
21 styleUrls: [
22 '../../shared/video/abstract-video-list.scss',
23 './video-channel-videos.component.scss'
24 ]
25})
26export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
27 titlePage: string
28 loadOnInit = false
29
30 private videoChannel: VideoChannel
31 private videoChannelSub: Subscription
32
33 constructor (
34 protected i18n: I18n,
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
46 ) {
47 super()
48
49 this.titlePage = this.i18n('Published videos')
50 this.displayOptions = {
51 ...this.displayOptions,
52 avatar: false
53 }
54 }
55
56 ngOnInit () {
57 super.ngOnInit()
58
59 // Parent get the video channel for us
60 this.videoChannelSub = this.videoChannelService.videoChannelLoaded
61 .pipe(first())
62 .subscribe(videoChannel => {
63 this.videoChannel = videoChannel
64
65 this.reloadVideos()
66 this.generateSyndicationList()
67 })
68 }
69
70 ngOnDestroy () {
71 if (this.videoChannelSub) this.videoChannelSub.unsubscribe()
72
73 super.ngOnDestroy()
74 }
75
76 getVideosObservable (page: number) {
77 const newPagination = immutableAssign(this.pagination, { currentPage: page })
78
79 return this.videoService
80 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
81 .pipe(
82 tap(({ total }) => {
83 this.titlePage = this.i18n(`{total, plural, =1 {Published 1 video} other {Published {{total}} videos}}`, { total })
84 })
85 )
86 }
87
88 generateSyndicationList () {
89 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
90 }
91}