]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-trending.component.ts
Fix NSFW blur on search
[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'
9b4b15f9 22 trendingDays: number
9bf9d2a5 23
989e526a
C
24 constructor (
25 protected router: Router,
26 protected route: ActivatedRoute,
f8b2c1b4 27 protected notifier: Notifier,
989e526a
C
28 protected authService: AuthService,
29 protected location: Location,
bbe0f064 30 protected screenService: ScreenService,
9b4b15f9 31 private serverService: ServerService,
b1d40cff
C
32 protected i18n: I18n,
33 private videoService: VideoService
989e526a 34 ) {
9bf9d2a5 35 super()
989e526a 36
9b4b15f9
AB
37 this.trendingDays = this.serverService.getConfig().trending.videos.intervalDays
38
39 this.titlePage = this.i18n('Trending for the last ')
40 this.trendingDays === 1 ? this.titlePage += '24 hours' : this.titlePage += this.trendingDays + ' days'
41
42 this.titleTooltip = this.i18n('trending videos are those totalizing the greatest number of views during the last ')
43 this.trendingDays === 1 ? this.titleTooltip += '24 hours.' : this.titleTooltip += this.trendingDays + ' days.'
9bf9d2a5
C
44 }
45
46 ngOnInit () {
47 super.ngOnInit()
cc1561f9 48
244e76a5 49 this.generateSyndicationList()
9bf9d2a5
C
50 }
51
9af61e84
C
52 ngOnDestroy () {
53 super.ngOnDestroy()
54 }
55
0cd4344f
C
56 getVideosObservable (page: number) {
57 const newPagination = immutableAssign(this.pagination, { currentPage: page })
d59cba29 58 return this.videoService.getVideos(newPagination, this.sort, undefined, this.categoryOneOf)
9bf9d2a5 59 }
244e76a5
RK
60
61 generateSyndicationList () {
d59cba29 62 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
244e76a5 63 }
9bf9d2a5 64}