1 import { Component, OnDestroy, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4 import { HooksService } from '@app/core/plugins/hooks.service'
5 import { immutableAssign } from '@app/helpers'
6 import { VideoService } from '@app/shared/shared-main'
7 import { AbstractVideoList } from '@app/shared/shared-video-miniature'
8 import { UserRight, VideoFilter, VideoSortField } from '@shared/models'
11 selector: 'my-videos-local',
12 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ],
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html'
15 export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy {
17 sort = '-publishedAt' as VideoSortField
18 filter: VideoFilter = 'local'
20 useUserVideoPreferences = true
23 protected router: Router,
24 protected serverService: ServerService,
25 protected route: ActivatedRoute,
26 protected notifier: Notifier,
27 protected authService: AuthService,
28 protected userService: UserService,
29 protected screenService: ScreenService,
30 protected storageService: LocalStorageService,
31 private videoService: VideoService,
32 private hooks: HooksService
36 this.titlePage = $localize`Local videos`
42 if (this.authService.isLoggedIn()) {
43 const user = this.authService.getUser()
44 this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS)
47 this.generateSyndicationList()
54 getVideosObservable (page: number) {
55 const newPagination = immutableAssign(this.pagination, { currentPage: page })
57 videoPagination: newPagination,
60 categoryOneOf: this.categoryOneOf,
61 languageOneOf: this.languageOneOf,
62 nsfwPolicy: this.nsfwPolicy,
66 return this.hooks.wrapObsFun(
67 this.videoService.getVideos.bind(this.videoService),
70 'filter:api.local-videos.videos.list.params',
71 'filter:api.local-videos.videos.list.result'
75 generateSyndicationList () {
76 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf)
79 toggleModerationDisplay () {
80 this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local'