]>
Commit | Line | Data |
---|---|---|
9af61e84 | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
9bf9d2a5 | 2 | import { ActivatedRoute, Router } from '@angular/router' |
0cd4344f | 3 | import { immutableAssign } from '@app/shared/misc/utils' |
b2731bff | 4 | import { AuthService } from '../../core/auth' |
7bfd1b1e | 5 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' |
7b87d2d5 | 6 | import { VideoSortField } from '../../shared/video/sort-field.type' |
f3aaa9a9 | 7 | import { VideoService } from '../../shared/video/video.service' |
989e526a | 8 | import { I18n } from '@ngx-translate/i18n-polyfill' |
bbe0f064 | 9 | import { ScreenService } from '@app/shared/misc/screen.service' |
9b4b15f9 | 10 | import { 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 | 17 | export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { |
989e526a | 18 | titlePage: string |
9a629c6e | 19 | defaultSort: VideoSortField = '-trending' |
9bf9d2a5 | 20 | |
989e526a C |
21 | constructor ( |
22 | protected router: Router, | |
489290b8 | 23 | protected serverService: ServerService, |
989e526a | 24 | protected route: ActivatedRoute, |
f8b2c1b4 | 25 | protected notifier: Notifier, |
989e526a | 26 | protected authService: AuthService, |
bbe0f064 | 27 | protected screenService: ScreenService, |
489290b8 | 28 | private i18n: I18n, |
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 | } |