]>
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' |
f3aaa9a9 C |
7 | import { SortField } from '../../shared/video/sort-field.type' |
8 | import { VideoService } from '../../shared/video/video.service' | |
244e76a5 RK |
9 | import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' |
10 | import * as url from 'url' | |
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 { |
9bf9d2a5 | 18 | titlePage = 'Trending' |
2bbb3412 | 19 | currentRoute = '/videos/trending' |
f3aaa9a9 | 20 | defaultSort: SortField = '-views' |
9bf9d2a5 C |
21 | |
22 | constructor (protected router: Router, | |
23 | protected route: ActivatedRoute, | |
24 | protected notificationsService: NotificationsService, | |
b2731bff | 25 | protected authService: AuthService, |
9bf9d2a5 C |
26 | private videoService: VideoService) { |
27 | super() | |
28 | } | |
29 | ||
30 | ngOnInit () { | |
31 | super.ngOnInit() | |
244e76a5 | 32 | this.generateSyndicationList() |
9bf9d2a5 C |
33 | } |
34 | ||
9af61e84 C |
35 | ngOnDestroy () { |
36 | super.ngOnDestroy() | |
37 | } | |
38 | ||
0cd4344f C |
39 | getVideosObservable (page: number) { |
40 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
41 | return this.videoService.getVideos(newPagination, this.sort) | |
9bf9d2a5 | 42 | } |
244e76a5 RK |
43 | |
44 | generateSyndicationList () { | |
45 | const feeds = this.videoService.getFeed('local') | |
46 | this.syndicationItems['rss 2.0'] = feeds[FeedFormat.RSS] | |
47 | this.syndicationItems['atom 1.0'] = feeds[FeedFormat.ATOM] | |
48 | this.syndicationItems['json 1.0'] = feeds[FeedFormat.JSON] | |
49 | } | |
9bf9d2a5 | 50 | } |