]>
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' |
9bf9d2a5 | 4 | import { NotificationsService } from 'angular2-notifications' |
b2731bff | 5 | import { AuthService } from '../../core/auth' |
7bfd1b1e | 6 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' |
7b87d2d5 | 7 | import { VideoSortField } from '../../shared/video/sort-field.type' |
f3aaa9a9 | 8 | import { VideoService } from '../../shared/video/video.service' |
9bf9d2a5 C |
9 | |
10 | @Component({ | |
11 | selector: 'my-videos-trending', | |
202f6b6c C |
12 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], |
13 | templateUrl: '../../shared/video/abstract-video-list.html' | |
9bf9d2a5 | 14 | }) |
9af61e84 | 15 | export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { |
9bf9d2a5 | 16 | titlePage = 'Trending' |
2bbb3412 | 17 | currentRoute = '/videos/trending' |
7b87d2d5 | 18 | defaultSort: VideoSortField = '-views' |
9bf9d2a5 C |
19 | |
20 | constructor (protected router: Router, | |
21 | protected route: ActivatedRoute, | |
22 | protected notificationsService: NotificationsService, | |
b2731bff | 23 | protected authService: AuthService, |
9bf9d2a5 C |
24 | private videoService: VideoService) { |
25 | super() | |
26 | } | |
27 | ||
28 | ngOnInit () { | |
29 | super.ngOnInit() | |
cc1561f9 | 30 | |
244e76a5 | 31 | this.generateSyndicationList() |
9bf9d2a5 C |
32 | } |
33 | ||
9af61e84 C |
34 | ngOnDestroy () { |
35 | super.ngOnDestroy() | |
36 | } | |
37 | ||
0cd4344f C |
38 | getVideosObservable (page: number) { |
39 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
40 | return this.videoService.getVideos(newPagination, this.sort) | |
9bf9d2a5 | 41 | } |
244e76a5 RK |
42 | |
43 | generateSyndicationList () { | |
7b87d2d5 | 44 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort) |
244e76a5 | 45 | } |
9bf9d2a5 | 46 | } |