]>
Commit | Line | Data |
---|---|---|
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | |
2 | import { ActivatedRoute, Router } from '@angular/router' | |
3 | import { immutableAssign } from '@app/shared/misc/utils' | |
4 | import { NotificationsService } from 'angular2-notifications' | |
5 | import { AuthService } from '../../core/auth' | |
6 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' | |
7 | import { SortField } from '../../shared/video/sort-field.type' | |
8 | import { VideoService } from '../../shared/video/video.service' | |
9 | import { FeedFormat } from '../../../../../shared/models/feeds/feed-format.enum' | |
10 | import * as url from 'url' | |
11 | ||
12 | @Component({ | |
13 | selector: 'my-videos-trending', | |
14 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], | |
15 | templateUrl: '../../shared/video/abstract-video-list.html' | |
16 | }) | |
17 | export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { | |
18 | titlePage = 'Trending' | |
19 | currentRoute = '/videos/trending' | |
20 | defaultSort: SortField = '-views' | |
21 | ||
22 | constructor (protected router: Router, | |
23 | protected route: ActivatedRoute, | |
24 | protected notificationsService: NotificationsService, | |
25 | protected authService: AuthService, | |
26 | private videoService: VideoService) { | |
27 | super() | |
28 | } | |
29 | ||
30 | ngOnInit () { | |
31 | super.ngOnInit() | |
32 | this.generateSyndicationList() | |
33 | } | |
34 | ||
35 | ngOnDestroy () { | |
36 | super.ngOnDestroy() | |
37 | } | |
38 | ||
39 | getVideosObservable (page: number) { | |
40 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
41 | return this.videoService.getVideos(newPagination, this.sort) | |
42 | } | |
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 | } | |
50 | } |