]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-trending.component.ts
Help translators to translate trending title/tooltip
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-trending.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 { AuthService } from '../../core/auth'
6 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7 import { VideoSortField } from '../../shared/video/sort-field.type'
8 import { VideoService } from '../../shared/video/video.service'
9 import { I18n } from '@ngx-translate/i18n-polyfill'
10 import { ScreenService } from '@app/shared/misc/screen.service'
11 import { Notifier, ServerService } from '@app/core'
12
13 @Component({
14 selector: 'my-videos-trending',
15 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
16 templateUrl: '../../shared/video/abstract-video-list.html'
17 })
18 export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
19 titlePage: string
20 currentRoute = '/videos/trending'
21 defaultSort: VideoSortField = '-trending'
22
23 constructor (
24 protected router: Router,
25 protected route: ActivatedRoute,
26 protected notifier: Notifier,
27 protected authService: AuthService,
28 protected location: Location,
29 protected screenService: ScreenService,
30 private serverService: ServerService,
31 protected i18n: I18n,
32 private videoService: VideoService
33 ) {
34 super()
35 }
36
37 ngOnInit () {
38 super.ngOnInit()
39
40 this.generateSyndicationList()
41
42 const trendingDays = this.serverService.getConfig().trending.videos.intervalDays
43
44 if (trendingDays === 1) {
45 this.titlePage = this.i18n('Trending for the last 24 hours')
46 this.titleTooltip = this.i18n('Trending videos are those totalizing the greatest number of views during the last 24 hours.')
47 } else {
48 this.titlePage = this.i18n('Trending for the last {{days}} days', { days: trendingDays })
49 this.titleTooltip = this.i18n(
50 'Trending videos are those totalizing the greatest number of views during the last {{days}} days.',
51 { days: trendingDays }
52 )
53 }
54 }
55
56 ngOnDestroy () {
57 super.ngOnDestroy()
58 }
59
60 getVideosObservable (page: number) {
61 const newPagination = immutableAssign(this.pagination, { currentPage: page })
62 return this.videoService.getVideos(newPagination, this.sort, undefined, this.categoryOneOf)
63 }
64
65 generateSyndicationList () {
66 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
67 }
68 }