]>
Commit | Line | Data |
---|---|---|
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' | |
12 | ||
13 | @Component({ | |
14 | selector: 'my-videos-trending', | |
15 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], | |
16 | templateUrl: '../../shared/video/abstract-video-list.html' | |
17 | }) | |
18 | export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { | |
19 | titlePage: string | |
20 | currentRoute = '/videos/trending' | |
21 | defaultSort: VideoSortField = '-trending' | |
22 | trendingDays: number | |
23 | ||
24 | constructor ( | |
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, | |
32 | protected i18n: I18n, | |
33 | private videoService: VideoService | |
34 | ) { | |
35 | super() | |
36 | ||
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.' | |
44 | } | |
45 | ||
46 | ngOnInit () { | |
47 | super.ngOnInit() | |
48 | ||
49 | this.generateSyndicationList() | |
50 | } | |
51 | ||
52 | ngOnDestroy () { | |
53 | super.ngOnDestroy() | |
54 | } | |
55 | ||
56 | getVideosObservable (page: number) { | |
57 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
58 | return this.videoService.getVideos(newPagination, this.sort, undefined, this.categoryOneOf) | |
59 | } | |
60 | ||
61 | generateSyndicationList () { | |
62 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf) | |
63 | } | |
64 | } |