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 import { HooksService } from '@app/core/plugins/hooks.service'
16 selector: 'my-videos-local',
17 styleUrls: [ '../../shared/video/abstract-video-list.scss' ],
18 templateUrl: '../../shared/video/abstract-video-list.html'
20 export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
22 sort = '-publishedAt' as VideoSortField
23 filter: VideoFilter = 'local'
25 useUserVideoLanguagePreferences = true
29 protected router: Router,
30 protected serverService: ServerService,
31 protected route: ActivatedRoute,
32 protected notifier: Notifier,
33 protected authService: AuthService,
34 protected screenService: ScreenService,
35 private videoService: VideoService,
36 private hooks: HooksService
40 this.titlePage = i18n('Local videos')
46 if (this.authService.isLoggedIn()) {
47 const user = this.authService.getUser()
48 this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS)
51 this.generateSyndicationList()
58 getVideosObservable (page: number) {
59 const newPagination = immutableAssign(this.pagination, { currentPage: page })
61 videoPagination: newPagination,
64 categoryOneOf: this.categoryOneOf,
65 languageOneOf: this.languageOneOf,
69 return this.hooks.wrapObsFun(
70 this.videoService.getVideos.bind(this.videoService),
73 'filter:api.local-videos.videos.list.params',
74 'filter:api.local-videos.videos.list.result'
78 generateSyndicationList () {
79 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf)
82 toggleModerationDisplay () {
83 this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local'