]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-trending.component.ts
Fix contributing guide concerning unit tests
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-trending.component.ts
CommitLineData
9af61e84 1import { Component, OnDestroy, OnInit } from '@angular/core'
9bf9d2a5 2import { ActivatedRoute, Router } from '@angular/router'
0cd4344f 3import { immutableAssign } from '@app/shared/misc/utils'
9bf9d2a5 4import { NotificationsService } from 'angular2-notifications'
b2731bff 5import { AuthService } from '../../core/auth'
7bfd1b1e 6import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7b87d2d5 7import { VideoSortField } from '../../shared/video/sort-field.type'
f3aaa9a9 8import { 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 15export 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}