]>
Commit | Line | Data |
---|---|---|
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | |
2 | import { ActivatedRoute, Router } from '@angular/router' | |
3 | import { Location } from '@angular/common' | |
4 | import { immutableAssign } from '@app/shared/misc/utils' | |
5 | import { NotificationsService } from 'angular2-notifications' | |
6 | import { AuthService } from '../../core/auth' | |
7 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' | |
8 | import { VideoSortField } from '../../shared/video/sort-field.type' | |
9 | import { VideoService } from '../../shared/video/video.service' | |
10 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
11 | ||
12 | @Component({ | |
13 | selector: 'my-videos-recently-added', | |
14 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], | |
15 | templateUrl: '../../shared/video/abstract-video-list.html' | |
16 | }) | |
17 | export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy { | |
18 | titlePage: string | |
19 | currentRoute = '/videos/recently-added' | |
20 | sort: VideoSortField = '-publishedAt' | |
21 | ||
22 | constructor ( | |
23 | protected router: Router, | |
24 | protected route: ActivatedRoute, | |
25 | protected location: Location, | |
26 | protected notificationsService: NotificationsService, | |
27 | protected authService: AuthService, | |
28 | protected i18n: I18n, | |
29 | private videoService: VideoService | |
30 | ) { | |
31 | super() | |
32 | ||
33 | this.titlePage = i18n('Recently added') | |
34 | } | |
35 | ||
36 | ngOnInit () { | |
37 | super.ngOnInit() | |
38 | ||
39 | this.generateSyndicationList() | |
40 | } | |
41 | ||
42 | ngOnDestroy () { | |
43 | super.ngOnDestroy() | |
44 | } | |
45 | ||
46 | getVideosObservable (page: number) { | |
47 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
48 | ||
49 | return this.videoService.getVideos(newPagination, this.sort) | |
50 | } | |
51 | ||
52 | generateSyndicationList () { | |
53 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort) | |
54 | } | |
55 | } |