diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-23 14:49:20 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-23 16:00:49 +0200 |
commit | 1942f11d5ee6926ad93dc1b79fae18325ba5de18 (patch) | |
tree | 3f2a3cd9466a56c419d197ac832a3e9cbc86bec4 /client/src/app/+videos/video-list/video-local.component.ts | |
parent | 67ed6552b831df66713bac9e672738796128d33f (diff) | |
download | PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.gz PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.zst PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.zip |
Lazy load all routes
Diffstat (limited to 'client/src/app/+videos/video-list/video-local.component.ts')
-rw-r--r-- | client/src/app/+videos/video-list/video-local.component.ts | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/client/src/app/+videos/video-list/video-local.component.ts b/client/src/app/+videos/video-list/video-local.component.ts new file mode 100644 index 000000000..b4c71ac49 --- /dev/null +++ b/client/src/app/+videos/video-list/video-local.component.ts | |||
@@ -0,0 +1,86 @@ | |||
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 { I18n } from '@ngx-translate/i18n-polyfill' | ||
9 | import { UserRight, VideoFilter, VideoSortField } from '@shared/models' | ||
10 | |||
11 | @Component({ | ||
12 | selector: 'my-videos-local', | ||
13 | styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ], | ||
14 | templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html' | ||
15 | }) | ||
16 | export class VideoLocalComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
17 | titlePage: string | ||
18 | sort = '-publishedAt' as VideoSortField | ||
19 | filter: VideoFilter = 'local' | ||
20 | |||
21 | useUserVideoPreferences = true | ||
22 | |||
23 | constructor ( | ||
24 | protected i18n: I18n, | ||
25 | protected router: Router, | ||
26 | protected serverService: ServerService, | ||
27 | protected route: ActivatedRoute, | ||
28 | protected notifier: Notifier, | ||
29 | protected authService: AuthService, | ||
30 | protected userService: UserService, | ||
31 | protected screenService: ScreenService, | ||
32 | protected storageService: LocalStorageService, | ||
33 | private videoService: VideoService, | ||
34 | private hooks: HooksService | ||
35 | ) { | ||
36 | super() | ||
37 | |||
38 | this.titlePage = i18n('Local videos') | ||
39 | } | ||
40 | |||
41 | ngOnInit () { | ||
42 | super.ngOnInit() | ||
43 | |||
44 | if (this.authService.isLoggedIn()) { | ||
45 | const user = this.authService.getUser() | ||
46 | this.displayModerationBlock = user.hasRight(UserRight.SEE_ALL_VIDEOS) | ||
47 | } | ||
48 | |||
49 | this.generateSyndicationList() | ||
50 | } | ||
51 | |||
52 | ngOnDestroy () { | ||
53 | super.ngOnDestroy() | ||
54 | } | ||
55 | |||
56 | getVideosObservable (page: number) { | ||
57 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | ||
58 | const params = { | ||
59 | videoPagination: newPagination, | ||
60 | sort: this.sort, | ||
61 | filter: this.filter, | ||
62 | categoryOneOf: this.categoryOneOf, | ||
63 | languageOneOf: this.languageOneOf, | ||
64 | nsfwPolicy: this.nsfwPolicy, | ||
65 | skipCount: true | ||
66 | } | ||
67 | |||
68 | return this.hooks.wrapObsFun( | ||
69 | this.videoService.getVideos.bind(this.videoService), | ||
70 | params, | ||
71 | 'common', | ||
72 | 'filter:api.local-videos.videos.list.params', | ||
73 | 'filter:api.local-videos.videos.list.result' | ||
74 | ) | ||
75 | } | ||
76 | |||
77 | generateSyndicationList () { | ||
78 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, this.filter, this.categoryOneOf) | ||
79 | } | ||
80 | |||
81 | toggleModerationDisplay () { | ||
82 | this.filter = this.filter === 'local' ? 'all-local' as 'all-local' : 'local' as 'local' | ||
83 | |||
84 | this.reloadVideos() | ||
85 | } | ||
86 | } | ||