diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-01-26 01:53:13 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-01-28 15:55:34 +0100 |
commit | 3da68f0a781ebd893521e2e6fa200280c92ae815 (patch) | |
tree | 11bddf841118703c725a96851318603407fd581d /client/src/app/+videos | |
parent | 28eeb811c40325a28208231324f66f4032e5cf67 (diff) | |
download | PeerTube-3da68f0a781ebd893521e2e6fa200280c92ae815.tar.gz PeerTube-3da68f0a781ebd893521e2e6fa200280c92ae815.tar.zst PeerTube-3da68f0a781ebd893521e2e6fa200280c92ae815.zip |
add default trending page choice, revert comments count for hot strategy
Diffstat (limited to 'client/src/app/+videos')
-rw-r--r-- | client/src/app/+videos/video-list/trending/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/+videos/video-list/trending/video-most-viewed.component.ts (renamed from client/src/app/+videos/video-list/trending/video-trending.component.ts) | 4 | ||||
-rw-r--r-- | client/src/app/+videos/video-list/trending/video-trending-header.component.html | 2 | ||||
-rw-r--r-- | client/src/app/+videos/video-list/trending/video-trending-header.component.ts | 29 | ||||
-rw-r--r-- | client/src/app/+videos/videos-routing.module.ts | 22 | ||||
-rw-r--r-- | client/src/app/+videos/videos.module.ts | 4 |
6 files changed, 43 insertions, 20 deletions
diff --git a/client/src/app/+videos/video-list/trending/index.ts b/client/src/app/+videos/video-list/trending/index.ts index 8bae205a5..93f4b1df6 100644 --- a/client/src/app/+videos/video-list/trending/index.ts +++ b/client/src/app/+videos/video-list/trending/index.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | export * from './video-trending-header.component' | 1 | export * from './video-trending-header.component' |
2 | export * from './video-trending.component' | ||
3 | export * from './video-hot.component' | 2 | export * from './video-hot.component' |
3 | export * from './video-most-viewed.component' | ||
4 | export * from './video-most-liked.component' | 4 | export * from './video-most-liked.component' |
diff --git a/client/src/app/+videos/video-list/trending/video-trending.component.ts b/client/src/app/+videos/video-list/trending/video-most-viewed.component.ts index e77231586..98ced42d6 100644 --- a/client/src/app/+videos/video-list/trending/video-trending.component.ts +++ b/client/src/app/+videos/video-list/trending/video-most-viewed.component.ts | |||
@@ -9,11 +9,11 @@ import { VideoSortField } from '@shared/models' | |||
9 | import { VideoTrendingHeaderComponent } from './video-trending-header.component' | 9 | import { VideoTrendingHeaderComponent } from './video-trending-header.component' |
10 | 10 | ||
11 | @Component({ | 11 | @Component({ |
12 | selector: 'my-videos-trending', | 12 | selector: 'my-videos-most-viewed', |
13 | styleUrls: [ '../../../shared/shared-video-miniature/abstract-video-list.scss' ], | 13 | styleUrls: [ '../../../shared/shared-video-miniature/abstract-video-list.scss' ], |
14 | templateUrl: '../../../shared/shared-video-miniature/abstract-video-list.html' | 14 | templateUrl: '../../../shared/shared-video-miniature/abstract-video-list.html' |
15 | }) | 15 | }) |
16 | export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { | 16 | export class VideoMostViewedComponent extends AbstractVideoList implements OnInit, OnDestroy { |
17 | HeaderComponent = VideoTrendingHeaderComponent | 17 | HeaderComponent = VideoTrendingHeaderComponent |
18 | titlePage: string | 18 | titlePage: string |
19 | defaultSort: VideoSortField = '-trending' | 19 | defaultSort: VideoSortField = '-trending' |
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 index 6319ee6d3..a025bf1a2 100644 --- 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 | |||
@@ -1,5 +1,5 @@ | |||
1 | <div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" [(ngModel)]="data.model" (ngModelChange)="setSort()"> | 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"> | 2 | <label *ngFor="let button of visibleButtons" ngbButtonLabel class="btn-light" placement="bottom" [ngbTooltip]="button.tooltip" container="body"> |
3 | <my-global-icon [iconName]="button.iconName"></my-global-icon> | 3 | <my-global-icon [iconName]="button.iconName"></my-global-icon> |
4 | <input ngbButton type="radio" [value]="button.value"> {{ button.label }} | 4 | <input ngbButton type="radio" [value]="button.value"> {{ button.label }} |
5 | </label> | 5 | </label> |
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 @@ | |||
1 | import { Component, Inject } from '@angular/core' | 1 | import { Component, Inject, OnInit } from '@angular/core' |
2 | import { Router } from '@angular/router' | 2 | import { Router } from '@angular/router' |
3 | import { VideoListHeaderComponent } from '@app/shared/shared-video-miniature' | 3 | import { VideoListHeaderComponent } from '@app/shared/shared-video-miniature' |
4 | import { GlobalIconName } from '@app/shared/shared-icons' | 4 | import { GlobalIconName } from '@app/shared/shared-icons' |
5 | import { VideoSortField } from '@shared/models' | 5 | import { VideoSortField } from '@shared/models' |
6 | import { ServerService } from '@app/core/server/server.service' | ||
6 | 7 | ||
7 | interface VideoTrendingHeaderItem { | 8 | interface VideoTrendingHeaderItem { |
8 | label: string | 9 | label: string |
@@ -10,6 +11,7 @@ interface VideoTrendingHeaderItem { | |||
10 | value: VideoSortField | 11 | value: VideoSortField |
11 | path: string | 12 | path: string |
12 | tooltip?: string | 13 | tooltip?: string |
14 | hidden?: boolean | ||
13 | } | 15 | } |
14 | 16 | ||
15 | @Component({ | 17 | @Component({ |
@@ -18,12 +20,13 @@ interface VideoTrendingHeaderItem { | |||
18 | styleUrls: [ './video-trending-header.component.scss' ], | 20 | styleUrls: [ './video-trending-header.component.scss' ], |
19 | templateUrl: './video-trending-header.component.html' | 21 | templateUrl: './video-trending-header.component.html' |
20 | }) | 22 | }) |
21 | export class VideoTrendingHeaderComponent extends VideoListHeaderComponent { | 23 | export class VideoTrendingHeaderComponent extends VideoListHeaderComponent implements OnInit { |
22 | buttons: VideoTrendingHeaderItem[] | 24 | buttons: VideoTrendingHeaderItem[] |
23 | 25 | ||
24 | constructor ( | 26 | constructor ( |
25 | @Inject('data') public data: any, | 27 | @Inject('data') public data: any, |
26 | private router: Router | 28 | private router: Router, |
29 | private serverService: ServerService | ||
27 | ) { | 30 | ) { |
28 | super(data) | 31 | super(data) |
29 | 32 | ||
@@ -34,16 +37,17 @@ export class VideoTrendingHeaderComponent extends VideoListHeaderComponent { | |||
34 | value: '-hot', | 37 | value: '-hot', |
35 | path: 'hot', | 38 | path: 'hot', |
36 | tooltip: $localize`Videos totalizing the most interactions for recent videos`, | 39 | tooltip: $localize`Videos totalizing the most interactions for recent videos`, |
40 | hidden: true | ||
37 | }, | 41 | }, |
38 | { | 42 | { |
39 | label: $localize`:Main variant of Trending videos based on number of recent views:Views`, | 43 | label: $localize`:Main variant of Trending videos based on number of recent views:Views`, |
40 | iconName: 'trending', | 44 | iconName: 'trending', |
41 | value: '-trending', | 45 | value: '-trending', |
42 | path: 'trending', | 46 | path: 'most-viewed', |
43 | tooltip: $localize`Videos totalizing the most views during the last 24 hours`, | 47 | tooltip: $localize`Videos totalizing the most views during the last 24 hours`, |
44 | }, | 48 | }, |
45 | { | 49 | { |
46 | label: $localize`:a variant of Trending videos based on the number of likes:Likes`, | 50 | label: $localize`:A variant of Trending videos based on the number of likes:Likes`, |
47 | iconName: 'like', | 51 | iconName: 'like', |
48 | value: '-likes', | 52 | value: '-likes', |
49 | path: 'most-liked', | 53 | path: 'most-liked', |
@@ -52,6 +56,21 @@ export class VideoTrendingHeaderComponent extends VideoListHeaderComponent { | |||
52 | ] | 56 | ] |
53 | } | 57 | } |
54 | 58 | ||
59 | ngOnInit () { | ||
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 | ||
66 | } | ||
67 | }) | ||
68 | } | ||
69 | |||
70 | get visibleButtons () { | ||
71 | return this.buttons.filter(b => !b.hidden) | ||
72 | } | ||
73 | |||
55 | setSort () { | 74 | setSort () { |
56 | const path = this.buttons.find(b => b.value === this.data.model).path | 75 | const path = this.buttons.find(b => b.value === this.data.model).path |
57 | this.router.navigate([ `/videos/${path}` ]) | 76 | this.router.navigate([ `/videos/${path}` ]) |
diff --git a/client/src/app/+videos/videos-routing.module.ts b/client/src/app/+videos/videos-routing.module.ts index b6850b436..973935af8 100644 --- a/client/src/app/+videos/videos-routing.module.ts +++ b/client/src/app/+videos/videos-routing.module.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { NgModule } from '@angular/core' |
2 | import { RouterModule, Routes } from '@angular/router' | 2 | import { RouterModule, Routes } from '@angular/router' |
3 | import { LoginGuard } from '@app/core' | 3 | import { LoginGuard, TrendingGuard } from '@app/core' |
4 | import { MetaGuard } from '@ngx-meta/core' | 4 | import { MetaGuard } from '@ngx-meta/core' |
5 | import { VideoOverviewComponent } from './video-list/overview/video-overview.component' | 5 | import { VideoOverviewComponent } from './video-list/overview/video-overview.component' |
6 | import { VideoHotComponent } from './video-list/trending/video-hot.component' | 6 | import { VideoHotComponent } from './video-list/trending/video-hot.component' |
7 | import { VideoMostLikedComponent } from './video-list/trending/video-most-liked.component' | 7 | import { VideoMostLikedComponent } from './video-list/trending/video-most-liked.component' |
8 | import { VideoTrendingComponent } from './video-list/trending/video-trending.component' | 8 | import { VideoMostViewedComponent } from './video-list/trending/video-most-viewed.component' |
9 | import { VideoLocalComponent } from './video-list/video-local.component' | 9 | import { VideoLocalComponent } from './video-list/video-local.component' |
10 | import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' | 10 | import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' |
11 | import { VideoUserSubscriptionsComponent } from './video-list/video-user-subscriptions.component' | 11 | import { VideoUserSubscriptionsComponent } from './video-list/video-user-subscriptions.component' |
@@ -28,27 +28,31 @@ const videosRoutes: Routes = [ | |||
28 | }, | 28 | }, |
29 | { | 29 | { |
30 | path: 'trending', | 30 | path: 'trending', |
31 | component: VideoTrendingComponent, | 31 | canActivate: [ TrendingGuard ] |
32 | }, | ||
33 | { | ||
34 | path: 'hot', | ||
35 | component: VideoHotComponent, | ||
32 | data: { | 36 | data: { |
33 | meta: { | 37 | meta: { |
34 | title: $localize`Trending videos` | 38 | title: $localize`Hot videos` |
35 | }, | 39 | }, |
36 | reuse: { | 40 | reuse: { |
37 | enabled: true, | 41 | enabled: true, |
38 | key: 'trending-videos-list' | 42 | key: 'hot-videos-list' |
39 | } | 43 | } |
40 | } | 44 | } |
41 | }, | 45 | }, |
42 | { | 46 | { |
43 | path: 'hot', | 47 | path: 'most-viewed', |
44 | component: VideoHotComponent, | 48 | component: VideoMostViewedComponent, |
45 | data: { | 49 | data: { |
46 | meta: { | 50 | meta: { |
47 | title: $localize`Hot videos` | 51 | title: $localize`Most viewed videos` |
48 | }, | 52 | }, |
49 | reuse: { | 53 | reuse: { |
50 | enabled: true, | 54 | enabled: true, |
51 | key: 'hot-videos-list' | 55 | key: 'most-viewed-videos-list' |
52 | } | 56 | } |
53 | } | 57 | } |
54 | }, | 58 | }, |
diff --git a/client/src/app/+videos/videos.module.ts b/client/src/app/+videos/videos.module.ts index 4c88a0397..ae9c680eb 100644 --- a/client/src/app/+videos/videos.module.ts +++ b/client/src/app/+videos/videos.module.ts | |||
@@ -9,7 +9,7 @@ import { OverviewService } from './video-list' | |||
9 | import { VideoOverviewComponent } from './video-list/overview/video-overview.component' | 9 | import { VideoOverviewComponent } from './video-list/overview/video-overview.component' |
10 | import { VideoTrendingHeaderComponent } from './video-list/trending/video-trending-header.component' | 10 | import { VideoTrendingHeaderComponent } from './video-list/trending/video-trending-header.component' |
11 | import { VideoHotComponent } from './video-list/trending/video-hot.component' | 11 | import { VideoHotComponent } from './video-list/trending/video-hot.component' |
12 | import { VideoTrendingComponent } from './video-list/trending/video-trending.component' | 12 | import { VideoMostViewedComponent } from './video-list/trending/video-most-viewed.component' |
13 | import { VideoMostLikedComponent } from './video-list/trending/video-most-liked.component' | 13 | import { VideoMostLikedComponent } from './video-list/trending/video-most-liked.component' |
14 | import { VideoLocalComponent } from './video-list/video-local.component' | 14 | import { VideoLocalComponent } from './video-list/video-local.component' |
15 | import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' | 15 | import { VideoRecentlyAddedComponent } from './video-list/video-recently-added.component' |
@@ -32,7 +32,7 @@ import { VideosComponent } from './videos.component' | |||
32 | VideosComponent, | 32 | VideosComponent, |
33 | 33 | ||
34 | VideoTrendingHeaderComponent, | 34 | VideoTrendingHeaderComponent, |
35 | VideoTrendingComponent, | 35 | VideoMostViewedComponent, |
36 | VideoHotComponent, | 36 | VideoHotComponent, |
37 | VideoMostLikedComponent, | 37 | VideoMostLikedComponent, |
38 | VideoRecentlyAddedComponent, | 38 | VideoRecentlyAddedComponent, |