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'
15 selector: 'my-videos-local',
16 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
17 templateUrl: '../../shared/video/abstract-video-list.html'
19 export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
21 sort = '-publishedAt' as VideoSortField
22 filter: VideoFilter = 'local'
24 useUserVideoLanguagePreferences = true
28 protected router: Router,
29 protected serverService: ServerService,
30 protected route: ActivatedRoute,
31 protected notifier: Notifier,
32 protected authService: AuthService,
33 protected screenService: ScreenService,
34 private videoService: VideoService
38 this.titlePage = i18n('Local videos')
44 if (this.authService.isLoggedIn()) {
45 const user = this.authService.getUser()
46 this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS)
49 this.generateSyndicationList()
56 getVideosObservable (page: number) {
57 const newPagination = immutableAssign(this.pagination, { currentPage: page })
59 return this.videoService.getVideos({
60 videoPagination: newPagination,
63 categoryOneOf: this.categoryOneOf,
64 languageOneOf: this.languageOneOf
68 generateSyndicationList () {
69 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf)
72 toggleModerationDisplay () {
73 this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local'