]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+videos/video-list/video-local.component.ts
Update build steps for localization
[github/Chocobozzz/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 { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4 import { HooksService } from '@app/core/plugins/hooks.service'
5 import { immutableAssign } from '@app/helpers'
6 import { VideoService } from '@app/shared/shared-main'
7 import { AbstractVideoList } from '@app/shared/shared-video-miniature'
8 import { I18n } from '@ngx-translate/i18n-polyfill'
9 import { UserRight, VideoFilter, VideoSortField } from '@shared/models'
10
11 @Component({
12 selector: 'my-videos-local',
13 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
14 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
15 })
16 export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
17 titlePage: string
18 sort = '-publishedAt' as VideoSortField
19 filter: VideoFilter = 'local'
20
21 useUserVideoPreferences = true
22
23 constructor (
24 protected i18n: I18n,
25 protected router: Router,
26 protected serverService: ServerService,
27 protected route: ActivatedRoute,
28 protected notifier: Notifier,
29 protected authService: AuthService,
30 protected userService: UserService,
31 protected screenService: ScreenService,
32 protected storageService: LocalStorageService,
33 private videoService: VideoService,
34 private hooks: HooksService
35 ) {
36 super()
37
38 this.titlePage = i18n('Local videos')
39 }
40
41 ngOnInit () {
42 super.ngOnInit()
43
44 if (this.authService.isLoggedIn()) {
45 const user = this.authService.getUser()
46 this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS)
47 }
48
49 this.generateSyndicationList()
50 }
51
52 ngOnDestroy () {
53 super.ngOnDestroy()
54 }
55
56 getVideosObservable (page: number) {
57 const newPagination = immutableAssign(this.pagination, { currentPage: page })
58 const params = {
59 videoPagination: newPagination,
60 sort: this.sort,
61 filter: this.filter,
62 categoryOneOf: this.categoryOneOf,
63 languageOneOf: this.languageOneOf,
64 nsfwPolicy: this.nsfwPolicy,
65 skipCount: true
66 }
67
68 return this.hooks.wrapObsFun(
69 this.videoService.getVideos.bind(this.videoService),
70 params,
71 'common',
72 'filter:api.local-videos.videos.list.params',
73 'filter:api.local-videos.videos.list.result'
74 )
75 }
76
77 generateSyndicationList () {
78 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf)
79 }
80
81 toggleModerationDisplay () {
82 this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local'
83
84 this.reloadVideos()
85 }
86 }