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