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