]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-recently-added.component.ts
Group videos on chronological order
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-recently-added.component.ts
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 { AuthService } from '../../core/auth'
5 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
6 import { VideoSortField } from '../../shared/video/sort-field.type'
7 import { VideoService } from '../../shared/video/video.service'
8 import { I18n } from '@ngx-translate/i18n-polyfill'
9 import { ScreenService } from '@app/shared/misc/screen.service'
10 import { Notifier, ServerService } from '@app/core'
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 sort: VideoSortField = '-publishedAt'
20 groupByDate = true
21
22 constructor (
23 protected i18n: I18n,
24 protected route: ActivatedRoute,
25 protected serverService: ServerService,
26 protected router: Router,
27 protected notifier: Notifier,
28 protected authService: AuthService,
29 protected screenService: ScreenService,
30 private videoService: VideoService
31 ) {
32 super()
33
34 this.titlePage = i18n('Recently added')
35 }
36
37 ngOnInit () {
38 super.ngOnInit()
39
40 this.generateSyndicationList()
41 }
42
43 ngOnDestroy () {
44 super.ngOnDestroy()
45 }
46
47 getVideosObservable (page: number) {
48 const newPagination = immutableAssign(this.pagination, { currentPage: page })
49
50 return this.videoService.getVideos(newPagination, this.sort, undefined, this.categoryOneOf)
51 }
52
53 generateSyndicationList () {
54 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
55 }
56 }