]>
Commit | Line | Data |
---|---|---|
c07eb946 JM |
1 | import { Component, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | |
3 | import { immutableAssign } from '@app/shared/misc/utils' | |
4 | import { AuthService } from '../../core/auth' | |
5 | import { AbstractVideoList } from '../../shared/video/abstract-video-list' | |
6 | import { VideoSortField } from '../../shared/video/sort-field.type' | |
7 | import { VideoService } from '../../shared/video/video.service' | |
8 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
9 | import { ScreenService } from '@app/shared/misc/screen.service' | |
10 | import { Notifier, ServerService } from '@app/core' | |
11 | import { HooksService } from '@app/core/plugins/hooks.service' | |
d3217560 RK |
12 | import { UserService } from '@app/shared' |
13 | import { LocalStorageService } from '@app/shared/misc/storage.service' | |
c07eb946 JM |
14 | |
15 | @Component({ | |
16 | selector: 'my-videos-most-liked', | |
17 | styleUrls: [ '../../shared/video/abstract-video-list.scss' ], | |
18 | templateUrl: '../../shared/video/abstract-video-list.html' | |
19 | }) | |
20 | export class VideoMostLikedComponent extends AbstractVideoList implements OnInit { | |
21 | titlePage: string | |
22 | defaultSort: VideoSortField = '-likes' | |
23 | ||
24 | useUserVideoLanguagePreferences = true | |
25 | ||
26 | constructor ( | |
27 | protected i18n: I18n, | |
28 | protected router: Router, | |
29 | protected serverService: ServerService, | |
30 | protected route: ActivatedRoute, | |
31 | protected notifier: Notifier, | |
32 | protected authService: AuthService, | |
d3217560 | 33 | protected userService: UserService, |
c07eb946 | 34 | protected screenService: ScreenService, |
d3217560 | 35 | protected storageService: LocalStorageService, |
c07eb946 JM |
36 | private videoService: VideoService, |
37 | private hooks: HooksService | |
38 | ) { | |
39 | super() | |
40 | } | |
41 | ||
42 | ngOnInit () { | |
43 | super.ngOnInit() | |
44 | ||
45 | this.generateSyndicationList() | |
46 | ||
ba430d75 C |
47 | this.titlePage = this.i18n('Most liked videos') |
48 | this.titleTooltip = this.i18n('Videos that have the higher number of likes.') | |
c07eb946 JM |
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, | |
440d39c5 C |
57 | languageOneOf: this.languageOneOf, |
58 | skipCount: true | |
c07eb946 JM |
59 | } |
60 | ||
61 | return this.hooks.wrapObsFun( | |
62 | this.videoService.getVideos.bind(this.videoService), | |
63 | params, | |
64 | 'common', | |
65 | 'filter:api.most-liked-videos.videos.list.params', | |
66 | 'filter:api.most-liked-videos.videos.list.result' | |
67 | ) | |
68 | } | |
69 | ||
70 | generateSyndicationList () { | |
71 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf) | |
72 | } | |
73 | } |