]>
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 | ||
11 | @Component({ | |
12 | selector: 'my-videos-trending', | |
13 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], | |
14 | templateUrl: '../../shared/video/abstract-video-list.html' | |
15 | }) | |
16 | export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { | |
17 | titlePage = 'Trending' | |
18 | currentRoute = '/videos/trending' | |
19 | defaultSort: VideoSortField = '-views' | |
20 | ||
21 | constructor (protected router: Router, | |
22 | protected route: ActivatedRoute, | |
23 | protected notificationsService: NotificationsService, | |
24 | protected authService: AuthService, | |
25 | protected location: Location, | |
26 | private videoService: VideoService) { | |
27 | super() | |
28 | } | |
29 | ||
30 | ngOnInit () { | |
31 | super.ngOnInit() | |
32 | ||
33 | this.generateSyndicationList() | |
34 | } | |
35 | ||
36 | ngOnDestroy () { | |
37 | super.ngOnDestroy() | |
38 | } | |
39 | ||
40 | getVideosObservable (page: number) { | |
41 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
42 | return this.videoService.getVideos(newPagination, this.sort) | |
43 | } | |
44 | ||
45 | generateSyndicationList () { | |
46 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort) | |
47 | } | |
48 | } |