X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=inline;f=client%2Fsrc%2Fapp%2F%2Bvideos%2Fvideo-list%2Ftrending%2Fvideo-trending-header.component.ts;h=e49b61c68736688cc9189a697d01f3e7c1c86521;hb=3da68f0a781ebd893521e2e6fa200280c92ae815;hp=125f14e33b40b81f45f9fb7fc4a4b7931c8f182e;hpb=28eeb811c40325a28208231324f66f4032e5cf67;p=github%2FChocobozzz%2FPeerTube.git 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 index 125f14e33..e49b61c68 100644 --- 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 @@ -1,8 +1,9 @@ -import { Component, Inject } from '@angular/core' +import { Component, Inject, OnInit } from '@angular/core' import { Router } from '@angular/router' import { VideoListHeaderComponent } from '@app/shared/shared-video-miniature' import { GlobalIconName } from '@app/shared/shared-icons' import { VideoSortField } from '@shared/models' +import { ServerService } from '@app/core/server/server.service' interface VideoTrendingHeaderItem { label: string @@ -10,6 +11,7 @@ interface VideoTrendingHeaderItem { value: VideoSortField path: string tooltip?: string + hidden?: boolean } @Component({ @@ -18,12 +20,13 @@ interface VideoTrendingHeaderItem { styleUrls: [ './video-trending-header.component.scss' ], templateUrl: './video-trending-header.component.html' }) -export class VideoTrendingHeaderComponent extends VideoListHeaderComponent { +export class VideoTrendingHeaderComponent extends VideoListHeaderComponent implements OnInit { buttons: VideoTrendingHeaderItem[] constructor ( @Inject('data') public data: any, - private router: Router + private router: Router, + private serverService: ServerService ) { super(data) @@ -34,16 +37,17 @@ export class VideoTrendingHeaderComponent extends VideoListHeaderComponent { value: '-hot', path: 'hot', tooltip: $localize`Videos totalizing the most interactions for recent videos`, + hidden: true }, { label: $localize`:Main variant of Trending videos based on number of recent views:Views`, iconName: 'trending', value: '-trending', - path: 'trending', + path: 'most-viewed', tooltip: $localize`Videos totalizing the most views during the last 24 hours`, }, { - label: $localize`:a variant of Trending videos based on the number of likes:Likes`, + label: $localize`:A variant of Trending videos based on the number of likes:Likes`, iconName: 'like', value: '-likes', path: 'most-liked', @@ -52,6 +56,21 @@ export class VideoTrendingHeaderComponent extends VideoListHeaderComponent { ] } + ngOnInit () { + this.serverService.getConfig() + .subscribe(config => { + // don't filter if auto-blacklist is not enabled as this will be the only list + if (config.instance.pages.hot.enabled) { + const index = this.buttons.findIndex(b => b.path === 'hot') + this.buttons[index].hidden = false + } + }) + } + + get visibleButtons () { + return this.buttons.filter(b => !b.hidden) + } + setSort () { const path = this.buttons.find(b => b.value === this.data.model).path this.router.navigate([ `/videos/${path}` ])