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