1 import { Component, Inject, OnInit } from '@angular/core'
2 import { Router } from '@angular/router'
3 import { VideoListHeaderComponent } from '@app/shared/shared-video-miniature'
4 import { GlobalIconName } from '@app/shared/shared-icons'
5 import { VideoSortField } from '@shared/models'
6 import { ServerService } from '@app/core/server/server.service'
8 interface VideoTrendingHeaderItem {
10 iconName: GlobalIconName
18 selector: 'video-trending-title-page',
19 host: { 'class': 'title-page title-page-single' },
20 styleUrls: [ './video-trending-header.component.scss' ],
21 templateUrl: './video-trending-header.component.html'
23 export class VideoTrendingHeaderComponent extends VideoListHeaderComponent implements OnInit {
24 buttons: VideoTrendingHeaderItem[]
27 @Inject('data') public data: any,
28 private router: Router,
29 private serverService: ServerService
35 label: $localize`:A variant of Trending videos based on the number of recent interactions:Hot`,
39 tooltip: $localize`Videos totalizing the most interactions for recent videos`,
43 label: $localize`:Main variant of Trending videos based on number of recent views:Views`,
47 tooltip: $localize`Videos totalizing the most views during the last 24 hours`,
50 label: $localize`:A variant of Trending videos based on the number of likes:Likes`,
54 tooltip: $localize`Videos that have the most likes`
60 this.serverService.getConfig()
61 .subscribe(config => {
62 // don't filter if auto-blacklist is not enabled as this will be the only list
63 if (config.instance.pages.hot.enabled) {
64 const index = this.buttons.findIndex(b => b.path === 'hot')
65 this.buttons[index].hidden = false
70 get visibleButtons () {
71 return this.buttons.filter(b => !b.hidden)
75 const path = this.buttons.find(b => b.value === this.data.model).path
76 this.router.navigate([ `/videos/${path}` ])