aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/video-list
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2021-01-22 00:12:44 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-01-28 15:55:34 +0100
commit5bcbcbe338ef5a1ed14f084311d013fbb25dabcf (patch)
treeb0f6382b30b67f1f7adddaf7d12af9adae0c9f5d /client/src/app/+videos/video-list
parent7a4994873c0b3394d04e16e877fc7418bc8b146a (diff)
downloadPeerTube-5bcbcbe338ef5a1ed14f084311d013fbb25dabcf.tar.gz
PeerTube-5bcbcbe338ef5a1ed14f084311d013fbb25dabcf.tar.zst
PeerTube-5bcbcbe338ef5a1ed14f084311d013fbb25dabcf.zip
modularize abstract video list header and implement video hotness recommendation variant
Diffstat (limited to 'client/src/app/+videos/video-list')
-rw-r--r--client/src/app/+videos/video-list/index.ts3
-rw-r--r--client/src/app/+videos/video-list/trending/index.ts4
-rw-r--r--client/src/app/+videos/video-list/trending/video-hot.component.ts85
-rw-r--r--client/src/app/+videos/video-list/trending/video-most-liked.component.ts (renamed from client/src/app/+videos/video-list/video-most-liked.component.ts)25
-rw-r--r--client/src/app/+videos/video-list/trending/video-trending-header.component.html6
-rw-r--r--client/src/app/+videos/video-list/trending/video-trending-header.component.scss17
-rw-r--r--client/src/app/+videos/video-list/trending/video-trending-header.component.ts59
-rw-r--r--client/src/app/+videos/video-list/trending/video-trending.component.ts (renamed from client/src/app/+videos/video-list/video-trending.component.ts)30
-rw-r--r--client/src/app/+videos/video-list/video-local.component.ts3
-rw-r--r--client/src/app/+videos/video-list/video-recently-added.component.ts3
-rw-r--r--client/src/app/+videos/video-list/video-user-subscriptions.component.ts6
11 files changed, 222 insertions, 19 deletions
diff --git a/client/src/app/+videos/video-list/index.ts b/client/src/app/+videos/video-list/index.ts
index af1bd58b7..dc27e29e2 100644
--- a/client/src/app/+videos/video-list/index.ts
+++ b/client/src/app/+videos/video-list/index.ts
@@ -1,5 +1,4 @@
1export * from './overview' 1export * from './overview'
2export * from './trending'
2export * from './video-local.component' 3export * from './video-local.component'
3export * from './video-recently-added.component' 4export * from './video-recently-added.component'
4export * from './video-trending.component'
5export * from './video-most-liked.component'
diff --git a/client/src/app/+videos/video-list/trending/index.ts b/client/src/app/+videos/video-list/trending/index.ts
new file mode 100644
index 000000000..8bae205a5
--- /dev/null
+++ b/client/src/app/+videos/video-list/trending/index.ts
@@ -0,0 +1,4 @@
1export * from './video-trending-header.component'
2export * from './video-trending.component'
3export * from './video-hot.component'
4export * from './video-most-liked.component'
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}
diff --git a/client/src/app/+videos/video-list/video-most-liked.component.ts b/client/src/app/+videos/video-list/trending/video-most-liked.component.ts
index 93408d76b..1781cc6aa 100644
--- a/client/src/app/+videos/video-list/video-most-liked.component.ts
+++ b/client/src/app/+videos/video-list/trending/video-most-liked.component.ts
@@ -1,4 +1,4 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, ComponentFactoryResolver, Injector, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core' 3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4import { HooksService } from '@app/core/plugins/hooks.service' 4import { HooksService } from '@app/core/plugins/hooks.service'
@@ -6,13 +6,15 @@ import { immutableAssign } from '@app/helpers'
6import { VideoService } from '@app/shared/shared-main' 6import { VideoService } from '@app/shared/shared-main'
7import { AbstractVideoList } from '@app/shared/shared-video-miniature' 7import { AbstractVideoList } from '@app/shared/shared-video-miniature'
8import { VideoSortField } from '@shared/models' 8import { VideoSortField } from '@shared/models'
9import { VideoTrendingHeaderComponent } from './video-trending-header.component'
9 10
10@Component({ 11@Component({
11 selector: 'my-videos-most-liked', 12 selector: 'my-videos-most-liked',
12 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ], 13 styleUrls: [ '../../../shared/shared-video-miniature/abstract-video-list.scss' ],
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html' 14 templateUrl: '../../../shared/shared-video-miniature/abstract-video-list.html'
14}) 15})
15export class VideoMostLikedComponent extends AbstractVideoList implements OnInit { 16export class VideoMostLikedComponent extends AbstractVideoList implements OnInit {
17 HeaderComponent = VideoTrendingHeaderComponent
16 titlePage: string 18 titlePage: string
17 defaultSort: VideoSortField = '-likes' 19 defaultSort: VideoSortField = '-likes'
18 20
@@ -27,19 +29,19 @@ export class VideoMostLikedComponent extends AbstractVideoList implements OnInit
27 protected userService: UserService, 29 protected userService: UserService,
28 protected screenService: ScreenService, 30 protected screenService: ScreenService,
29 protected storageService: LocalStorageService, 31 protected storageService: LocalStorageService,
32 protected cfr: ComponentFactoryResolver,
30 private videoService: VideoService, 33 private videoService: VideoService,
31 private hooks: HooksService 34 private hooks: HooksService
32 ) { 35 ) {
33 super() 36 super()
37
38 this.headerComponentInjector = this.getInjector()
34 } 39 }
35 40
36 ngOnInit () { 41 ngOnInit () {
37 super.ngOnInit() 42 super.ngOnInit()
38 43
39 this.generateSyndicationList() 44 this.generateSyndicationList()
40
41 this.titlePage = $localize`Most liked videos`
42 this.titleTooltip = $localize`Videos that have the most likes.`
43 } 45 }
44 46
45 getVideosObservable (page: number) { 47 getVideosObservable (page: number) {
@@ -65,4 +67,15 @@ export class VideoMostLikedComponent extends AbstractVideoList implements OnInit
65 generateSyndicationList () { 67 generateSyndicationList () {
66 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf) 68 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
67 } 69 }
70
71 getInjector () {
72 return Injector.create({
73 providers: [{
74 provide: 'data',
75 useValue: {
76 model: this.defaultSort
77 }
78 }]
79 })
80 }
68} 81}
diff --git a/client/src/app/+videos/video-list/trending/video-trending-header.component.html b/client/src/app/+videos/video-list/trending/video-trending-header.component.html
new file mode 100644
index 000000000..6319ee6d3
--- /dev/null
+++ b/client/src/app/+videos/video-list/trending/video-trending-header.component.html
@@ -0,0 +1,6 @@
1<div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" [(ngModel)]="data.model" (ngModelChange)="setSort()">
2 <label *ngFor="let button of buttons" ngbButtonLabel class="btn-light" placement="bottom" [ngbTooltip]="button.tooltip" container="body">
3 <my-global-icon [iconName]="button.iconName"></my-global-icon>
4 <input ngbButton type="radio" [value]="button.value"> {{ button.label }}
5 </label>
6</div> \ No newline at end of file
diff --git a/client/src/app/+videos/video-list/trending/video-trending-header.component.scss b/client/src/app/+videos/video-list/trending/video-trending-header.component.scss
new file mode 100644
index 000000000..923a1d67a
--- /dev/null
+++ b/client/src/app/+videos/video-list/trending/video-trending-header.component.scss
@@ -0,0 +1,17 @@
1.btn-group label {
2 border: 1px solid transparent;
3 border-radius: 9999px !important;
4 padding: 5px 16px;
5 opacity: .8;
6
7 &:not(:first-child) {
8 margin-left: .5rem;
9 }
10
11 my-global-icon {
12 position: relative;
13 top: -2px;
14 height: 1rem;
15 margin-right: .1rem;
16 }
17} \ No newline at end of file
diff --git a/client/src/app/+videos/video-list/trending/video-trending-header.component.ts b/client/src/app/+videos/video-list/trending/video-trending-header.component.ts
new file mode 100644
index 000000000..125f14e33
--- /dev/null
+++ b/client/src/app/+videos/video-list/trending/video-trending-header.component.ts
@@ -0,0 +1,59 @@
1import { Component, Inject } from '@angular/core'
2import { Router } from '@angular/router'
3import { VideoListHeaderComponent } from '@app/shared/shared-video-miniature'
4import { GlobalIconName } from '@app/shared/shared-icons'
5import { VideoSortField } from '@shared/models'
6
7interface VideoTrendingHeaderItem {
8 label: string
9 iconName: GlobalIconName
10 value: VideoSortField
11 path: string
12 tooltip?: string
13}
14
15@Component({
16 selector: 'video-trending-title-page',
17 host: { 'class': 'title-page title-page-single' },
18 styleUrls: [ './video-trending-header.component.scss' ],
19 templateUrl: './video-trending-header.component.html'
20})
21export class VideoTrendingHeaderComponent extends VideoListHeaderComponent {
22 buttons: VideoTrendingHeaderItem[]
23
24 constructor (
25 @Inject('data') public data: any,
26 private router: Router
27 ) {
28 super(data)
29
30 this.buttons = [
31 {
32 label: $localize`:A variant of Trending videos based on the number of recent interactions:Hot`,
33 iconName: 'flame',
34 value: '-hot',
35 path: 'hot',
36 tooltip: $localize`Videos totalizing the most interactions for recent videos`,
37 },
38 {
39 label: $localize`:Main variant of Trending videos based on number of recent views:Views`,
40 iconName: 'trending',
41 value: '-trending',
42 path: 'trending',
43 tooltip: $localize`Videos totalizing the most views during the last 24 hours`,
44 },
45 {
46 label: $localize`:a variant of Trending videos based on the number of likes:Likes`,
47 iconName: 'like',
48 value: '-likes',
49 path: 'most-liked',
50 tooltip: $localize`Videos that have the most likes`
51 }
52 ]
53 }
54
55 setSort () {
56 const path = this.buttons.find(b => b.value === this.data.model).path
57 this.router.navigate([ `/videos/${path}` ])
58 }
59}
diff --git a/client/src/app/+videos/video-list/video-trending.component.ts b/client/src/app/+videos/video-list/trending/video-trending.component.ts
index a188795d1..e77231586 100644
--- a/client/src/app/+videos/video-list/video-trending.component.ts
+++ b/client/src/app/+videos/video-list/trending/video-trending.component.ts
@@ -1,4 +1,4 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, ComponentFactoryResolver, Injector, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core' 3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4import { HooksService } from '@app/core/plugins/hooks.service' 4import { HooksService } from '@app/core/plugins/hooks.service'
@@ -6,13 +6,15 @@ import { immutableAssign } from '@app/helpers'
6import { VideoService } from '@app/shared/shared-main' 6import { VideoService } from '@app/shared/shared-main'
7import { AbstractVideoList } from '@app/shared/shared-video-miniature' 7import { AbstractVideoList } from '@app/shared/shared-video-miniature'
8import { VideoSortField } from '@shared/models' 8import { VideoSortField } from '@shared/models'
9import { VideoTrendingHeaderComponent } from './video-trending-header.component'
9 10
10@Component({ 11@Component({
11 selector: 'my-videos-trending', 12 selector: 'my-videos-trending',
12 styleUrls: [ '../../shared/shared-video-miniature/abstract-video-list.scss' ], 13 styleUrls: [ '../../../shared/shared-video-miniature/abstract-video-list.scss' ],
13 templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html' 14 templateUrl: '../../../shared/shared-video-miniature/abstract-video-list.html'
14}) 15})
15export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { 16export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy {
17 HeaderComponent = VideoTrendingHeaderComponent
16 titlePage: string 18 titlePage: string
17 defaultSort: VideoSortField = '-trending' 19 defaultSort: VideoSortField = '-trending'
18 20
@@ -27,10 +29,13 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
27 protected userService: UserService, 29 protected userService: UserService,
28 protected screenService: ScreenService, 30 protected screenService: ScreenService,
29 protected storageService: LocalStorageService, 31 protected storageService: LocalStorageService,
32 protected cfr: ComponentFactoryResolver,
30 private videoService: VideoService, 33 private videoService: VideoService,
31 private hooks: HooksService 34 private hooks: HooksService
32 ) { 35 ) {
33 super() 36 super()
37
38 this.headerComponentInjector = this.getInjector()
34 } 39 }
35 40
36 ngOnInit () { 41 ngOnInit () {
@@ -43,13 +48,13 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
43 const trendingDays = config.trending.videos.intervalDays 48 const trendingDays = config.trending.videos.intervalDays
44 49
45 if (trendingDays === 1) { 50 if (trendingDays === 1) {
46 this.titlePage = $localize`Trending for the last 24 hours`
47 this.titleTooltip = $localize`Trending videos are those totalizing the greatest number of views during the last 24 hours` 51 this.titleTooltip = $localize`Trending videos are those totalizing the greatest number of views during the last 24 hours`
48 return 52 } else {
53 this.titleTooltip = $localize`Trending videos are those totalizing the greatest number of views during the last ${trendingDays} days`
49 } 54 }
50 55
51 this.titlePage = $localize`Trending for the last ${trendingDays} days` 56 this.headerComponentInjector = this.getInjector()
52 this.titleTooltip = $localize`Trending videos are those totalizing the greatest number of views during the last ${trendingDays} days` 57 this.setHeader()
53 }) 58 })
54 } 59 }
55 60
@@ -80,4 +85,15 @@ export class VideoTrendingComponent extends AbstractVideoList implements OnInit,
80 generateSyndicationList () { 85 generateSyndicationList () {
81 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf) 86 this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf)
82 } 87 }
88
89 getInjector () {
90 return Injector.create({
91 providers: [{
92 provide: 'data',
93 useValue: {
94 model: this.defaultSort
95 }
96 }]
97 })
98 }
83} 99}
diff --git a/client/src/app/+videos/video-list/video-local.component.ts b/client/src/app/+videos/video-list/video-local.component.ts
index 20dd61db9..af7eecff4 100644
--- a/client/src/app/+videos/video-list/video-local.component.ts
+++ b/client/src/app/+videos/video-list/video-local.component.ts
@@ -1,4 +1,4 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core' 3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4import { HooksService } from '@app/core/plugins/hooks.service' 4import { HooksService } from '@app/core/plugins/hooks.service'
@@ -28,6 +28,7 @@ export class VideoLocalComponent extends AbstractVideoList implements OnInit, On
28 protected userService: UserService, 28 protected userService: UserService,
29 protected screenService: ScreenService, 29 protected screenService: ScreenService,
30 protected storageService: LocalStorageService, 30 protected storageService: LocalStorageService,
31 protected cfr: ComponentFactoryResolver,
31 private videoService: VideoService, 32 private videoService: VideoService,
32 private hooks: HooksService 33 private hooks: HooksService
33 ) { 34 ) {
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
index 34db6aabd..2f4908074 100644
--- a/client/src/app/+videos/video-list/video-recently-added.component.ts
+++ b/client/src/app/+videos/video-list/video-recently-added.component.ts
@@ -1,4 +1,4 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core' 3import { AuthService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
4import { HooksService } from '@app/core/plugins/hooks.service' 4import { HooksService } from '@app/core/plugins/hooks.service'
@@ -28,6 +28,7 @@ export class VideoRecentlyAddedComponent extends AbstractVideoList implements On
28 protected userService: UserService, 28 protected userService: UserService,
29 protected screenService: ScreenService, 29 protected screenService: ScreenService,
30 protected storageService: LocalStorageService, 30 protected storageService: LocalStorageService,
31 protected cfr: ComponentFactoryResolver,
31 private videoService: VideoService, 32 private videoService: VideoService,
32 private hooks: HooksService 33 private hooks: HooksService
33 ) { 34 ) {
diff --git a/client/src/app/+videos/video-list/video-user-subscriptions.component.ts b/client/src/app/+videos/video-list/video-user-subscriptions.component.ts
index 62d862ec9..e352a2b2c 100644
--- a/client/src/app/+videos/video-list/video-user-subscriptions.component.ts
+++ b/client/src/app/+videos/video-list/video-user-subscriptions.component.ts
@@ -1,6 +1,6 @@
1 1
2import { switchMap } from 'rxjs/operators' 2import { switchMap } from 'rxjs/operators'
3import { Component, OnDestroy, OnInit } from '@angular/core' 3import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router' 4import { ActivatedRoute, Router } from '@angular/router'
5import { AuthService, LocalStorageService, Notifier, ScopedTokensService, ScreenService, ServerService, UserService } from '@app/core' 5import { AuthService, LocalStorageService, Notifier, ScopedTokensService, ScreenService, ServerService, UserService } from '@app/core'
6import { HooksService } from '@app/core/plugins/hooks.service' 6import { HooksService } from '@app/core/plugins/hooks.service'
@@ -33,6 +33,7 @@ export class VideoUserSubscriptionsComponent extends AbstractVideoList implement
33 protected screenService: ScreenService, 33 protected screenService: ScreenService,
34 protected storageService: LocalStorageService, 34 protected storageService: LocalStorageService,
35 private userSubscription: UserSubscriptionService, 35 private userSubscription: UserSubscriptionService,
36 protected cfr: ComponentFactoryResolver,
36 private hooks: HooksService, 37 private hooks: HooksService,
37 private videoService: VideoService, 38 private videoService: VideoService,
38 private scopedTokensService: ScopedTokensService 39 private scopedTokensService: ScopedTokensService
@@ -102,7 +103,8 @@ export class VideoUserSubscriptionsComponent extends AbstractVideoList implement
102 } 103 }
103 104
104 generateSyndicationList () { 105 generateSyndicationList () {
105 // not implemented yet 106 /* method disabled: the view provides its own */
107 throw new Error('Method not implemented.')
106 } 108 }
107 109
108 activateCopiedMessage () { 110 activateCopiedMessage () {