]>
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 { NotificationsService } from 'angular2-notifications' | |
6 | import { AuthService } from '../../core/auth' | |
7 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' | |
8 | import { VideoSortField } from '../../shared/video/sort-field.type' | |
9 | import { VideoService } from '../../shared/video/video.service' | |
10 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
11 | import { ScreenService } from '@app/shared/misc/screen.service' | |
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 = '-views' | |
22 | ||
23 | constructor ( | |
24 | protected router: Router, | |
25 | protected route: ActivatedRoute, | |
26 | protected notificationsService: NotificationsService, | |
27 | protected authService: AuthService, | |
28 | protected location: Location, | |
29 | protected screenService: ScreenService, | |
30 | protected i18n: I18n, | |
31 | private videoService: VideoService | |
32 | ) { | |
33 | super() | |
34 | ||
35 | this.titlePage = i18n('Trending') | |
36 | } | |
37 | ||
38 | ngOnInit () { | |
39 | super.ngOnInit() | |
40 | ||
41 | this.generateSyndicationList() | |
42 | } | |
43 | ||
44 | ngOnDestroy () { | |
45 | super.ngOnDestroy() | |
46 | } | |
47 | ||
48 | getVideosObservable (page: number) { | |
49 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
50 | return this.videoService.getVideos(newPagination, this.sort, undefined, this.category) | |
51 | } | |
52 | ||
53 | generateSyndicationList () { | |
54 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.category) | |
55 | } | |
56 | } |