]>
Commit | Line | Data |
---|---|---|
9af61e84 | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
066e94c5 C |
2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { immutableAssign } from '@app/shared/misc/utils' | |
066e94c5 C |
4 | import { AuthService } from '../../core/auth' |
5 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' | |
7b87d2d5 | 6 | import { VideoSortField } from '../../shared/video/sort-field.type' |
066e94c5 | 7 | import { VideoService } from '../../shared/video/video.service' |
7b87d2d5 | 8 | import { VideoFilter } from '../../../../../shared/models/videos/video-query.type' |
989e526a | 9 | import { I18n } from '@ngx-translate/i18n-polyfill' |
bbe0f064 | 10 | import { ScreenService } from '@app/shared/misc/screen.service' |
017c3dca | 11 | import { UserRight } from '../../../../../shared/models/users' |
489290b8 | 12 | import { Notifier, ServerService } from '@app/core' |
93cae479 | 13 | import { HooksService } from '@app/core/plugins/hooks.service' |
066e94c5 C |
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 | }) | |
9af61e84 | 20 | export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy { |
989e526a | 21 | titlePage: string |
136cce4d | 22 | sort = '-publishedAt' as VideoSortField |
7b87d2d5 | 23 | filter: VideoFilter = 'local' |
066e94c5 | 24 | |
3caf77d3 C |
25 | useUserVideoLanguagePreferences = true |
26 | ||
989e526a | 27 | constructor ( |
34c7f429 | 28 | protected i18n: I18n, |
989e526a | 29 | protected router: Router, |
489290b8 | 30 | protected serverService: ServerService, |
989e526a | 31 | protected route: ActivatedRoute, |
f8b2c1b4 | 32 | protected notifier: Notifier, |
989e526a | 33 | protected authService: AuthService, |
bbe0f064 | 34 | protected screenService: ScreenService, |
93cae479 C |
35 | private videoService: VideoService, |
36 | private hooks: HooksService | |
989e526a | 37 | ) { |
066e94c5 | 38 | super() |
989e526a C |
39 | |
40 | this.titlePage = i18n('Local videos') | |
066e94c5 C |
41 | } |
42 | ||
43 | ngOnInit () { | |
44 | super.ngOnInit() | |
cc1561f9 | 45 | |
017c3dca C |
46 | if (this.authService.isLoggedIn()) { |
47 | const user = this.authService.getUser() | |
48 | this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS) | |
49 | } | |
50 | ||
244e76a5 | 51 | this.generateSyndicationList() |
066e94c5 C |
52 | } |
53 | ||
9af61e84 C |
54 | ngOnDestroy () { |
55 | super.ngOnDestroy() | |
56 | } | |
57 | ||
066e94c5 C |
58 | getVideosObservable (page: number) { |
59 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
93cae479 | 60 | const params = { |
3caf77d3 C |
61 | videoPagination: newPagination, |
62 | sort: this.sort, | |
63 | filter: this.filter, | |
64 | categoryOneOf: this.categoryOneOf, | |
65 | languageOneOf: this.languageOneOf | |
93cae479 C |
66 | } |
67 | ||
68 | return this.hooks.wrapObsFun( | |
69 | this.videoService.getVideos.bind(this.videoService), | |
70 | params, | |
71 | 'common', | |
7663e55a C |
72 | 'filter:api.local-videos.videos.list.params', |
73 | 'filter:api.local-videos.videos.list.result' | |
93cae479 | 74 | ) |
066e94c5 | 75 | } |
244e76a5 RK |
76 | |
77 | generateSyndicationList () { | |
d59cba29 | 78 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf) |
244e76a5 | 79 | } |
017c3dca C |
80 | |
81 | toggleModerationDisplay () { | |
82 | this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local' | |
83 | ||
84 | this.reloadVideos() | |
85 | } | |
066e94c5 | 86 | } |