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