]>
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' |
d3217560 RK |
14 | import { UserService } from '@app/shared' |
15 | import { LocalStorageService } from '@app/shared/misc/storage.service' | |
066e94c5 C |
16 | |
17 | @Component({ | |
18 | selector: 'my-videos-local', | |
19 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], | |
20 | templateUrl: '../../shared/video/abstract-video-list.html' | |
21 | }) | |
9af61e84 | 22 | export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy { |
989e526a | 23 | titlePage: string |
136cce4d | 24 | sort = '-publishedAt' as VideoSortField |
7b87d2d5 | 25 | filter: VideoFilter = 'local' |
066e94c5 | 26 | |
3caf77d3 C |
27 | useUserVideoLanguagePreferences = true |
28 | ||
989e526a | 29 | constructor ( |
34c7f429 | 30 | protected i18n: I18n, |
989e526a | 31 | protected router: Router, |
489290b8 | 32 | protected serverService: ServerService, |
989e526a | 33 | protected route: ActivatedRoute, |
f8b2c1b4 | 34 | protected notifier: Notifier, |
989e526a | 35 | protected authService: AuthService, |
d3217560 | 36 | protected userService: UserService, |
bbe0f064 | 37 | protected screenService: ScreenService, |
d3217560 | 38 | protected storageService: LocalStorageService, |
93cae479 C |
39 | private videoService: VideoService, |
40 | private hooks: HooksService | |
989e526a | 41 | ) { |
066e94c5 | 42 | super() |
989e526a C |
43 | |
44 | this.titlePage = i18n('Local videos') | |
066e94c5 C |
45 | } |
46 | ||
47 | ngOnInit () { | |
48 | super.ngOnInit() | |
cc1561f9 | 49 | |
017c3dca C |
50 | if (this.authService.isLoggedIn()) { |
51 | const user = this.authService.getUser() | |
52 | this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS) | |
53 | } | |
54 | ||
244e76a5 | 55 | this.generateSyndicationList() |
066e94c5 C |
56 | } |
57 | ||
9af61e84 C |
58 | ngOnDestroy () { |
59 | super.ngOnDestroy() | |
60 | } | |
61 | ||
066e94c5 C |
62 | getVideosObservable (page: number) { |
63 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | |
93cae479 | 64 | const params = { |
3caf77d3 C |
65 | videoPagination: newPagination, |
66 | sort: this.sort, | |
67 | filter: this.filter, | |
68 | categoryOneOf: this.categoryOneOf, | |
440d39c5 C |
69 | languageOneOf: this.languageOneOf, |
70 | skipCount: true | |
93cae479 C |
71 | } |
72 | ||
73 | return this.hooks.wrapObsFun( | |
74 | this.videoService.getVideos.bind(this.videoService), | |
75 | params, | |
76 | 'common', | |
7663e55a C |
77 | 'filter:api.local-videos.videos.list.params', |
78 | 'filter:api.local-videos.videos.list.result' | |
93cae479 | 79 | ) |
066e94c5 | 80 | } |
244e76a5 RK |
81 | |
82 | generateSyndicationList () { | |
d59cba29 | 83 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf) |
244e76a5 | 84 | } |
017c3dca C |
85 | |
86 | toggleModerationDisplay () { | |
87 | this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local' | |
88 | ||
89 | this.reloadVideos() | |
90 | } | |
066e94c5 | 91 | } |