]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-trending.component.ts
Merge branch 'release/v1.2.0'
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-trending.component.ts
CommitLineData
9af61e84 1import { Component, OnDestroy, OnInit } from '@angular/core'
9bf9d2a5 2import { ActivatedRoute, Router } from '@angular/router'
2a2c19df 3import { Location } from '@angular/common'
0cd4344f 4import { immutableAssign } from '@app/shared/misc/utils'
b2731bff 5import { AuthService } from '../../core/auth'
7bfd1b1e 6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7b87d2d5 7import { VideoSortField } from '../../shared/video/sort-field.type'
f3aaa9a9 8import { VideoService } from '../../shared/video/video.service'
989e526a 9import { I18n } from '@ngx-translate/i18n-polyfill'
bbe0f064 10import { ScreenService } from '@app/shared/misc/screen.service'
9b4b15f9 11import { Notifier, ServerService } from '@app/core'
9bf9d2a5
C
12
13@Component({
14 selector: 'my-videos-trending',
202f6b6c
C
15 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
16 templateUrl: '../../shared/video/abstract-video-list.html'
9bf9d2a5 17})
9af61e84 18export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
989e526a 19 titlePage: string
2bbb3412 20 currentRoute = '/videos/trending'
9a629c6e 21 defaultSort: VideoSortField = '-trending'
9bf9d2a5 22
989e526a
C
23 constructor (
24 protected router: Router,
25 protected route: ActivatedRoute,
f8b2c1b4 26 protected notifier: Notifier,
989e526a
C
27 protected authService: AuthService,
28 protected location: Location,
bbe0f064 29 protected screenService: ScreenService,
9b4b15f9 30 private serverService: ServerService,
b1d40cff
C
31 protected i18n: I18n,
32 private videoService: VideoService
989e526a 33 ) {
9bf9d2a5
C
34 super()
35 }
36
37 ngOnInit () {
38 super.ngOnInit()
cc1561f9 39
244e76a5 40 this.generateSyndicationList()
7b95f313 41
572b8e02
C
42 this.serverService.configLoaded.subscribe(
43 () => {
44 const trendingDays = this.serverService.getConfig().trending.videos.intervalDays
7b95f313 45
572b8e02
C
46 if (trendingDays === 1) {
47 this.titlePage = this.i18n('Trending for the last 24 hours')
48 this.titleTooltip = this.i18n('Trending videos are those totalizing the greatest number of views during the last 24 hours.')
49 } else {
50 this.titlePage = this.i18n('Trending for the last {{days}} days', { days: trendingDays })
51 this.titleTooltip = this.i18n(
52 'Trending videos are those totalizing the greatest number of views during the last {{days}} days.',
53 { days: trendingDays }
54 )
55 }
56 })
9bf9d2a5
C
57 }
58
9af61e84
C
59 ngOnDestroy () {
60 super.ngOnDestroy()
61 }
62
0cd4344f
C
63 getVideosObservable (page: number) {
64 const newPagination = immutableAssign(this.pagination, { currentPage: page })
d59cba29 65 return this.videoService.getVideos(newPagination, this.sort, undefined, this.categoryOneOf)
9bf9d2a5 66 }
244e76a5
RK
67
68 generateSyndicationList () {
d59cba29 69 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
244e76a5 70 }
9bf9d2a5 71}