aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/video-list/trending/video-hot.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+videos/video-list/trending/video-hot.component.ts')
-rw-r--r--client/src/app/+videos/video-list/trending/video-hot.component.ts85
1 files changed, 85 insertions, 0 deletions
diff --git a/client/src/app/+videos/video-list/trending/video-hot.component.ts b/client/src/app/+videos/video-list/trending/video-hot.component.ts
new file mode 100644
index 000000000..1617eb21e
--- /dev/null
+++ b/client/src/app/+videos/video-list/trending/video-hot.component.ts
@@ -0,0 +1,85 @@
1import { Component, ComponentFactoryResolver, Injector, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router'
3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4import { HooksService } from '@app/core/plugins/hooks.service'
5import { immutableAssign } from '@app/helpers'
6import { VideoService } from '@app/shared/shared-main'
7import { AbstractVideoList } from '@app/shared/shared-video-miniature'
8import { VideoSortField } from '@shared/models'
9import { VideoTrendingHeaderComponent } from './video-trending-header.component'
10
11@Component({
12 selector: 'my-videos-hot',
13 styleUrls: [ '../../../shared/shared-video-miniature/abstract-video-list.scss' ],
14 templateUrl: '../../../shared/shared-video-miniature/abstract-video-list.html'
15})
16export class VideoHotComponent extends AbstractVideoList implements OnInit, OnDestroy {
17 HeaderComponent = VideoTrendingHeaderComponent
18 titlePage: string
19 defaultSort: VideoSortField = '-hot'
20
21 useUserVideoPreferences = true
22
23 constructor (
24 protected router: Router,
25 protected serverService: ServerService,
26 protected route: ActivatedRoute,
27 protected notifier: Notifier,
28 protected authService: AuthService,
29 protected userService: UserService,
30 protected screenService: ScreenService,
31 protected storageService: LocalStorageService,
32 protected cfr: ComponentFactoryResolver,
33 private videoService: VideoService,
34 private hooks: HooksService
35 ) {
36 super()
37
38 this.headerComponentInjector = this.getInjector()
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.trending-videos.videos.list.params',
67 'filter:api.trending-videos.videos.list.result'
68 )
69 }
70
71 generateSyndicationList () {
72 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
73 }
74
75 getInjector () {
76 return Injector.create({
77 providers: [{
78 provide: 'data',
79 useValue: {
80 model: this.defaultSort
81 }
82 }]
83 })
84 }
85}