diff options
Diffstat (limited to 'client/src/app/+videos/video-list/video-recently-added.component.ts')
-rw-r--r-- | client/src/app/+videos/video-list/video-recently-added.component.ts | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/client/src/app/+videos/video-list/video-recently-added.component.ts b/client/src/app/+videos/video-list/video-recently-added.component.ts new file mode 100644 index 000000000..c9395133f --- /dev/null +++ b/client/src/app/+videos/video-list/video-recently-added.component.ts | |||
@@ -0,0 +1,74 @@ | |||
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 { VideoSortField } from '@shared/models' | ||
10 | |||
11 | @Component({ | ||
12 | selector: 'my-videos-recently-added', | ||
13 | styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ], | ||
14 | templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html' | ||
15 | }) | ||
16 | export class VideoRecentlyAddedComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
17 | titlePage: string | ||
18 | sort: VideoSortField = '-publishedAt' | ||
19 | groupByDate = true | ||
20 | |||
21 | useUserVideoPreferences = true | ||
22 | |||
23 | constructor ( | ||
24 | protected i18n: I18n, | ||
25 | protected route: ActivatedRoute, | ||
26 | protected serverService: ServerService, | ||
27 | protected router: Router, | ||
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('Recently added') | ||
39 | } | ||
40 | |||
41 | ngOnInit () { | ||
42 | super.ngOnInit() | ||
43 | |||
44 | this.generateSyndicationList() | ||
45 | } | ||
46 | |||
47 | ngOnDestroy () { | ||
48 | super.ngOnDestroy() | ||
49 | } | ||
50 | |||
51 | getVideosObservable (page: number) { | ||
52 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | ||
53 | const params = { | ||
54 | videoPagination: newPagination, | ||
55 | sort: this.sort, | ||
56 | categoryOneOf: this.categoryOneOf, | ||
57 | languageOneOf: this.languageOneOf, | ||
58 | nsfwPolicy: this.nsfwPolicy, | ||
59 | skipCount: true | ||
60 | } | ||
61 | |||
62 | return this.hooks.wrapObsFun( | ||
63 | this.videoService.getVideos.bind(this.videoService), | ||
64 | params, | ||
65 | 'common', | ||
66 | 'filter:api.recently-added-videos.videos.list.params', | ||
67 | 'filter:api.recently-added-videos.videos.list.result' | ||
68 | ) | ||
69 | } | ||
70 | |||
71 | generateSyndicationList () { | ||
72 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf) | ||
73 | } | ||
74 | } | ||