From 3da68f0a781ebd893521e2e6fa200280c92ae815 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Tue, 26 Jan 2021 01:53:13 +0100 Subject: [PATCH 1/1] add default trending page choice, revert comments count for hot strategy --- .../edit-custom-config.component.html | 23 ++++- .../edit-custom-config.component.ts | 10 ++ .../app/+videos/video-list/trending/index.ts | 2 +- ...nent.ts => video-most-viewed.component.ts} | 4 +- .../video-trending-header.component.html | 2 +- .../video-trending-header.component.ts | 29 +++++- .../src/app/+videos/videos-routing.module.ts | 22 +++-- client/src/app/+videos/videos.module.ts | 4 +- client/src/app/core/core.module.ts | 4 +- client/src/app/core/routing/index.ts | 1 + .../src/app/core/routing/redirect.service.ts | 26 ++++- .../core/routing/trending-guard.service.ts | 14 +++ client/src/app/core/server/server.service.ts | 8 +- client/src/app/menu/menu.component.html | 6 +- .../abstract-video-list.scss | 2 +- .../video-list-header.component.html | 5 + .../video-list-header.component.ts | 12 +-- config/default.yaml | 4 + config/production.yaml.example | 4 + server/controllers/api/config.ts | 18 +++- server/helpers/audit-logger.ts | 1 + server/initializers/config.ts | 10 +- server/middlewares/validators/config.ts | 3 +- server/models/video/video-query-builder.ts | 95 ++++++++----------- server/tests/api/check-params/config.ts | 10 +- server/tests/api/server/config.ts | 10 +- server/tests/client.ts | 2 +- shared/extra-utils/server/config.ts | 10 +- shared/models/server/custom-config.model.ts | 10 +- shared/models/server/server-config.model.ts | 8 +- 30 files changed, 256 insertions(+), 103 deletions(-) rename client/src/app/+videos/video-list/trending/{video-trending.component.ts => video-most-viewed.component.ts} (95%) create mode 100644 client/src/app/core/routing/trending-guard.service.ts create mode 100644 client/src/app/shared/shared-video-miniature/video-list-header.component.html diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index 9e4691670..83b1c6a31 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html @@ -269,9 +269,13 @@
@@ -279,6 +283,19 @@
{{ formErrors.instance.defaultClientRoute }}
+
+ +
+ +
+
{{ formErrors.instance.defaultTrendingRoute }}
+
+ diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 330ab075a..e6fc4582b 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -186,6 +186,12 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A languages: null, defaultClientRoute: null, + defaultTrendingRoute: null, + pages: { + hot: { + enabled: null + } + }, customizations: { javascript: null, @@ -364,6 +370,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A return this.form.value['followings']['instance']['autoFollowIndex']['enabled'] === true } + isTrendingHotEnabled () { + return this.form.value['instance']['pages']['hot']['enabled'] === true + } + async formValidated () { const value: CustomConfig = this.form.getRawValue() 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 @@ export * from './video-trending-header.component' -export * from './video-trending.component' export * from './video-hot.component' +export * from './video-most-viewed.component' 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 similarity index 95% rename from client/src/app/+videos/video-list/trending/video-trending.component.ts rename to 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' import { VideoTrendingHeaderComponent } from './video-trending-header.component' @Component({ - selector: 'my-videos-trending', + selector: 'my-videos-most-viewed', styleUrls: [ '../../../shared/shared-video-miniature/abstract-video-list.scss' ], templateUrl: '../../../shared/shared-video-miniature/abstract-video-list.html' }) -export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { +export class VideoMostViewedComponent extends AbstractVideoList implements OnInit, OnDestroy { HeaderComponent = VideoTrendingHeaderComponent titlePage: string 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 @@
-