]>
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' | |
2a2c19df | 4 | import { Location } from '@angular/common' |
066e94c5 C |
5 | import { AuthService } from '../../core/auth' |
6 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' | |
7b87d2d5 | 7 | import { VideoSortField } from '../../shared/video/sort-field.type' |
066e94c5 | 8 | import { VideoService } from '../../shared/video/video.service' |
7b87d2d5 | 9 | import { VideoFilter } from '../../../../../shared/models/videos/video-query.type' |
989e526a | 10 | import { I18n } from '@ngx-translate/i18n-polyfill' |
bbe0f064 | 11 | import { ScreenService } from '@app/shared/misc/screen.service' |
017c3dca | 12 | import { UserRight } from '../../../../../shared/models/users' |
f8b2c1b4 | 13 | import { Notifier } from '@app/core' |
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 |
066e94c5 | 22 | currentRoute = '/videos/local' |
136cce4d | 23 | sort = '-publishedAt' as VideoSortField |
7b87d2d5 | 24 | filter: VideoFilter = 'local' |
066e94c5 | 25 | |
989e526a C |
26 | constructor ( |
27 | protected router: Router, | |
28 | protected route: ActivatedRoute, | |
f8b2c1b4 | 29 | protected notifier: Notifier, |
989e526a C |
30 | protected authService: AuthService, |
31 | protected location: Location, | |
b1d40cff | 32 | protected i18n: I18n, |
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 | ||
d59cba29 | 59 | return this.videoService.getVideos(newPagination, this.sort, this.filter, this.categoryOneOf) |
066e94c5 | 60 | } |
244e76a5 RK |
61 | |
62 | generateSyndicationList () { | |
d59cba29 | 63 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf) |
244e76a5 | 64 | } |
017c3dca C |
65 | |
66 | toggleModerationDisplay () { | |
67 | this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local' | |
68 | ||
69 | this.reloadVideos() | |
70 | } | |
066e94c5 | 71 | } |