]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/video-list/video-local.component.ts
tell the user to fork the repo (#1856)
[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'
066e94c5
C
13
14@Component({
15 selector: 'my-videos-local',
16 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
17 templateUrl: '../../shared/video/abstract-video-list.html'
18})
9af61e84 19export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
989e526a 20 titlePage: string
136cce4d 21 sort = '-publishedAt' as VideoSortField
7b87d2d5 22 filter: VideoFilter = 'local'
066e94c5 23
989e526a
C
24 constructor (
25 protected router: Router,
489290b8 26 protected serverService: ServerService,
989e526a 27 protected route: ActivatedRoute,
f8b2c1b4 28 protected notifier: Notifier,
989e526a 29 protected authService: AuthService,
bbe0f064 30 protected screenService: ScreenService,
489290b8 31 private i18n: I18n,
b1d40cff 32 private videoService: VideoService
989e526a 33 ) {
066e94c5 34 super()
989e526a
C
35
36 this.titlePage = i18n('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 })
56
d59cba29 57 return this.videoService.getVideos(newPagination, this.sort, this.filter, this.categoryOneOf)
066e94c5 58 }
244e76a5
RK
59
60 generateSyndicationList () {
d59cba29 61 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf)
244e76a5 62 }
017c3dca
C
63
64 toggleModerationDisplay () {
65 this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local'
66
67 this.reloadVideos()
68 }
066e94c5 69}