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