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