]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-local.component.ts
Translated using Weblate (Spanish)
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-local.component.ts
CommitLineData
9af61e84 1import { Component, OnDestroy, OnInit } from '@angular/core'
066e94c5
C
2import { ActivatedRoute, Router } from '@angular/router'
3import { immutableAssign } from '@app/shared/misc/utils'
066e94c5
C
4import { AuthService } from '../../core/auth'
5import { AbstractVideoList } from '../../shared/video/abstract-video-list'
7b87d2d5 6import { VideoSortField } from '../../shared/video/sort-field.type'
066e94c5 7import { VideoService } from '../../shared/video/video.service'
7b87d2d5 8import { VideoFilter } from '../../../../../shared/models/videos/video-query.type'
989e526a 9import { I18n } from '@ngx-translate/i18n-polyfill'
bbe0f064 10import { ScreenService } from '@app/shared/misc/screen.service'
017c3dca 11import { UserRight } from '../../../../../shared/models/users'
489290b8 12import { Notifier, ServerService } from '@app/core'
93cae479 13import { HooksService } from '@app/core/plugins/hooks.service'
d3217560
RK
14import { UserService } from '@app/shared'
15import { LocalStorageService } from '@app/shared/misc/storage.service'
066e94c5
C
16
17@Component({
18 selector: 'my-videos-local',
19 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
20 templateUrl: '../../shared/video/abstract-video-list.html'
21})
9af61e84 22export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
989e526a 23 titlePage: string
136cce4d 24 sort = '-publishedAt' as VideoSortField
7b87d2d5 25 filter: VideoFilter = 'local'
066e94c5 26
3caf77d3
C
27 useUserVideoLanguagePreferences = true
28
989e526a 29 constructor (
34c7f429 30 protected i18n: I18n,
989e526a 31 protected router: Router,
489290b8 32 protected serverService: ServerService,
989e526a 33 protected route: ActivatedRoute,
f8b2c1b4 34 protected notifier: Notifier,
989e526a 35 protected authService: AuthService,
d3217560 36 protected userService: UserService,
bbe0f064 37 protected screenService: ScreenService,
d3217560 38 protected storageService: LocalStorageService,
93cae479
C
39 private videoService: VideoService,
40 private hooks: HooksService
989e526a 41 ) {
066e94c5 42 super()
989e526a
C
43
44 this.titlePage = i18n('Local videos')
066e94c5
C
45 }
46
47 ngOnInit () {
48 super.ngOnInit()
cc1561f9 49
017c3dca
C
50 if (this.authService.isLoggedIn()) {
51 const user = this.authService.getUser()
52 this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS)
53 }
54
244e76a5 55 this.generateSyndicationList()
066e94c5
C
56 }
57
9af61e84
C
58 ngOnDestroy () {
59 super.ngOnDestroy()
60 }
61
066e94c5
C
62 getVideosObservable (page: number) {
63 const newPagination = immutableAssign(this.pagination, { currentPage: page })
93cae479 64 const params = {
3caf77d3
C
65 videoPagination: newPagination,
66 sort: this.sort,
67 filter: this.filter,
68 categoryOneOf: this.categoryOneOf,
440d39c5
C
69 languageOneOf: this.languageOneOf,
70 skipCount: true
93cae479
C
71 }
72
73 return this.hooks.wrapObsFun(
74 this.videoService.getVideos.bind(this.videoService),
75 params,
76 'common',
7663e55a
C
77 'filter:api.local-videos.videos.list.params',
78 'filter:api.local-videos.videos.list.result'
93cae479 79 )
066e94c5 80 }
244e76a5
RK
81
82 generateSyndicationList () {
d59cba29 83 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf)
244e76a5 84 }
017c3dca
C
85
86 toggleModerationDisplay () {
87 this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local'
88
89 this.reloadVideos()
90 }
066e94c5 91}