]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-list/video-local.component.ts
Merge branch 'master' into develop
[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 { immutableAssign } from '@app/shared/misc/utils'
4 import { AuthService } from '../../core/auth'
5 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
6 import { VideoSortField } from '../../shared/video/sort-field.type'
7 import { VideoService } from '../../shared/video/video.service'
8 import { VideoFilter } from '../../../../../shared/models/videos/video-query.type'
9 import { I18n } from '@ngx-translate/i18n-polyfill'
10 import { ScreenService } from '@app/shared/misc/screen.service'
11 import { UserRight } from '../../../../../shared/models/users'
12 import { Notifier, ServerService } from '@app/core'
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 })
19 export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
20 titlePage: string
21 sort = '-publishedAt' as VideoSortField
22 filter: VideoFilter = 'local'
23
24 constructor (
25 protected router: Router,
26 protected serverService: ServerService,
27 protected route: ActivatedRoute,
28 protected notifier: Notifier,
29 protected authService: AuthService,
30 protected screenService: ScreenService,
31 private i18n: I18n,
32 private videoService: VideoService
33 ) {
34 super()
35
36 this.titlePage = i18n('Local videos')
37 }
38
39 ngOnInit () {
40 super.ngOnInit()
41
42 if (this.authService.isLoggedIn()) {
43 const user = this.authService.getUser()
44 this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS)
45 }
46
47 this.generateSyndicationList()
48 }
49
50 ngOnDestroy () {
51 super.ngOnDestroy()
52 }
53
54 getVideosObservable (page: number) {
55 const newPagination = immutableAssign(this.pagination, { currentPage: page })
56
57 return this.videoService.getVideos(newPagination, this.sort, this.filter, this.categoryOneOf)
58 }
59
60 generateSyndicationList () {
61 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf)
62 }
63
64 toggleModerationDisplay () {
65 this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local'
66
67 this.reloadVideos()
68 }
69 }