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