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'
25 protected router: Router,
26 protected route: ActivatedRoute,
27 protected notifier: Notifier,
28 protected authService: AuthService,
29 protected location: Location,
30 protected screenService: ScreenService,
31 private serverService: ServerService,
33 private videoService: VideoService
37 this.trendingDays = this.serverService.getConfig().trending.videos.intervalDays
39 this.titlePage = this.i18n('Trending for the last ')
40 this.trendingDays === 1 ? this.titlePage += '24 hours' : this.titlePage += this.trendingDays + ' days'
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.'
49 this.generateSyndicationList()
56 getVideosObservable (page: number) {
57 const newPagination = immutableAssign(this.pagination, { currentPage: page })
58 return this.videoService.getVideos(newPagination, this.sort, undefined, this.categoryOneOf)
61 generateSyndicationList () {
62 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)