]>
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 | |
3caf77d3 C |
21 | useUserVideoLanguagePreferences = true |
22 | ||
989e526a | 23 | constructor ( |
34c7f429 | 24 | protected i18n: I18n, |
989e526a | 25 | protected router: Router, |
489290b8 | 26 | protected serverService: ServerService, |
989e526a | 27 | protected route: ActivatedRoute, |
f8b2c1b4 | 28 | protected notifier: Notifier, |
989e526a | 29 | protected authService: AuthService, |
bbe0f064 | 30 | protected screenService: ScreenService, |
b1d40cff | 31 | private videoService: VideoService |
989e526a | 32 | ) { |
9bf9d2a5 C |
33 | super() |
34 | } | |
35 | ||
36 | ngOnInit () { | |
37 | super.ngOnInit() | |
cc1561f9 | 38 | |
244e76a5 | 39 | this.generateSyndicationList() |
7b95f313 | 40 | |
572b8e02 C |
41 | this.serverService.configLoaded.subscribe( |
42 | () => { | |
43 | const trendingDays = this.serverService.getConfig().trending.videos.intervalDays | |
7b95f313 | 44 | |
572b8e02 C |
45 | if (trendingDays === 1) { |
46 | this.titlePage = this.i18n('Trending for the last 24 hours') | |
1aabcae7 | 47 | this.titleTooltip = this.i18n('Trending videos are those totalizing the greatest number of views during the last 24 hours') |
572b8e02 C |
48 | } else { |
49 | this.titlePage = this.i18n('Trending for the last {{days}} days', { days: trendingDays }) | |
50 | this.titleTooltip = this.i18n( | |
1aabcae7 | 51 | 'Trending videos are those totalizing the greatest number of views during the last {{days}} days', |
572b8e02 C |
52 | { days: trendingDays } |
53 | ) | |
54 | } | |
55 | }) | |
9bf9d2a5 C |
56 | } |
57 | ||
9af61e84 C |
58 | ngOnDestroy () { |
59 | super.ngOnDestroy() | |
60 | } | |
61 | ||
0cd4344f C |
62 | getVideosObservable (page: number) { |
63 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
3caf77d3 C |
64 | return this.videoService.getVideos({ |
65 | videoPagination: newPagination, | |
66 | sort: this.sort, | |
67 | filter: undefined, | |
68 | categoryOneOf: this.categoryOneOf, | |
69 | languageOneOf: this.languageOneOf | |
70 | }) | |
9bf9d2a5 | 71 | } |
244e76a5 RK |
72 | |
73 | generateSyndicationList () { | |
d59cba29 | 74 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf) |
244e76a5 | 75 | } |
9bf9d2a5 | 76 | } |