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'
14 selector: 'my-videos-trending',
15 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
16 templateUrl: '../../shared/video/abstract-video-list.html'
18 export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
20 currentRoute = '/videos/trending'
21 defaultSort: VideoSortField = '-trending'
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,
32 private videoService: VideoService
40 this.generateSyndicationList()
42 this.serverService.configLoaded.subscribe(
44 const trendingDays = this.serverService.getConfig().trending.videos.intervalDays
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')
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 }
63 getVideosObservable (page: number) {
64 const newPagination = immutableAssign(this.pagination, { currentPage: page })
65 return this.videoService.getVideos(newPagination, this.sort, undefined, this.categoryOneOf)
68 generateSyndicationList () {
69 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)