Prepare i18n files
[oweals/peertube.git] / client / src / app / videos / video-list / video-local.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 { Location } from '@angular/common'
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 { VideoFilter } from '../../../../../shared/models/videos/video-query.type'
11 import { I18n } from '@ngx-translate/i18n-polyfill'
12
13 @Component({
14   selector: 'my-videos-local',
15   styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
16   templateUrl: '../../shared/video/abstract-video-list.html'
17 })
18 export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
19   titlePage: string
20   currentRoute = '/videos/local'
21   sort = '-publishedAt' as VideoSortField
22   filter: VideoFilter = 'local'
23
24   constructor (
25     protected router: Router,
26     protected route: ActivatedRoute,
27     protected notificationsService: NotificationsService,
28     protected authService: AuthService,
29     protected location: Location,
30     private videoService: VideoService,
31     private i18n: I18n
32   ) {
33     super()
34
35     this.titlePage = i18n('Local videos')
36   }
37
38   ngOnInit () {
39     super.ngOnInit()
40
41     this.generateSyndicationList()
42   }
43
44   ngOnDestroy () {
45     super.ngOnDestroy()
46   }
47
48   getVideosObservable (page: number) {
49     const newPagination = immutableAssign(this.pagination, { currentPage: page })
50
51     return this.videoService.getVideos(newPagination, this.sort, this.filter)
52   }
53
54   generateSyndicationList () {
55     this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter)
56   }
57 }