]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+videos/video-list/trending/video-trending-header.component.ts
modularize abstract video list header and implement video hotness recommendation...
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / video-list / trending / video-trending-header.component.ts
CommitLineData
5bcbcbe3
RK
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}