]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+video-channels/video-channel-videos/video-channel-videos.component.ts
Fix i18n in components
[github/Chocobozzz/PeerTube.git] / client / src / app / +video-channels / video-channel-videos / video-channel-videos.component.ts
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
15 @Component({
16 selector: 'my-video-channel-videos',
17 templateUrl: '../../shared/video/abstract-video-list.html',
18 styleUrls: [
19 '../../shared/video/abstract-video-list.scss',
20 './video-channel-videos.component.scss'
21 ]
22 })
23 export class VideoChannelVideosComponent extends AbstractVideoList implements OnInit, OnDestroy {
24 titlePage: string
25 marginContent = false // Disable margin
26 currentRoute = '/video-channel/videos'
27 loadOnInit = false
28
29 private videoChannel: VideoChannel
30
31 constructor (
32 protected router: Router,
33 protected route: ActivatedRoute,
34 protected authService: AuthService,
35 protected notificationsService: NotificationsService,
36 protected confirmService: ConfirmService,
37 protected location: Location,
38 protected i18n: I18n,
39 private videoChannelService: VideoChannelService,
40 private videoService: VideoService
41 ) {
42 super()
43
44 this.titlePage = this.i18n('Published videos')
45 }
46
47 ngOnInit () {
48 super.ngOnInit()
49
50 // Parent get the video channel for us
51 this.videoChannelService.videoChannelLoaded
52 .subscribe(videoChannel => {
53 this.videoChannel = videoChannel
54 this.currentRoute = '/video-channel/' + this.videoChannel.uuid + '/videos'
55
56 this.loadMoreVideos(this.pagination.currentPage)
57 this.generateSyndicationList()
58 })
59 }
60
61 ngOnDestroy () {
62 super.ngOnDestroy()
63 }
64
65 getVideosObservable (page: number) {
66 const newPagination = immutableAssign(this.pagination, { currentPage: page })
67
68 return this.videoService
69 .getVideoChannelVideos(this.videoChannel, newPagination, this.sort)
70 .pipe(
71 tap(({ totalVideos }) => {
72 this.titlePage = this.i18n('Published {{totalVideos}} videos', { totalVideos })
73 })
74 )
75 }
76
77 generateSyndicationList () {
78 this.syndicationItems = this.videoService.getVideoChannelFeedUrls(this.videoChannel.id)
79 }
80 }