diff options
Diffstat (limited to 'client/src/app/+videos/video-list/trending')
5 files changed, 0 insertions, 266 deletions
diff --git a/client/src/app/+videos/video-list/trending/index.ts b/client/src/app/+videos/video-list/trending/index.ts deleted file mode 100644 index 70835885a..000000000 --- a/client/src/app/+videos/video-list/trending/index.ts +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | export * from './video-trending-header.component' | ||
2 | export * from './video-trending.component' | ||
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 deleted file mode 100644 index db81ce6a1..000000000 --- a/client/src/app/+videos/video-list/trending/video-trending-header.component.html +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | <div class="btn-group btn-group-toggle" ngbRadioGroup name="radioBasic" [(ngModel)]="data.model" (ngModelChange)="setSort()"> | ||
2 | <ng-container *ngFor="let button of buttons"> | ||
3 | <label *ngIf="!button.hidden" ngbButtonLabel class="btn-light" placement="bottom right-bottom left-bottom" [ngbTooltip]="button.tooltip" container="body"> | ||
4 | <my-global-icon [iconName]="button.iconName"></my-global-icon> | ||
5 | <input ngbButton type="radio" [value]="button.value"> {{ button.label }} | ||
6 | </label> | ||
7 | </ng-container> | ||
8 | </div> | ||
diff --git a/client/src/app/+videos/video-list/trending/video-trending-header.component.scss b/client/src/app/+videos/video-list/trending/video-trending-header.component.scss deleted file mode 100644 index 54b072314..000000000 --- a/client/src/app/+videos/video-list/trending/video-trending-header.component.scss +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | @use '_mixins' as *; | ||
2 | |||
3 | .btn-group label { | ||
4 | border: 1px solid transparent; | ||
5 | border-radius: 9999px !important; | ||
6 | padding: 5px 16px; | ||
7 | opacity: .8; | ||
8 | |||
9 | &:not(:first-child) { | ||
10 | @include margin-left(.5rem); | ||
11 | } | ||
12 | |||
13 | my-global-icon { | ||
14 | @include margin-right(.1rem); | ||
15 | |||
16 | position: relative; | ||
17 | top: -2px; | ||
18 | height: 1rem; | ||
19 | } | ||
20 | } | ||
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 deleted file mode 100644 index c94655c74..000000000 --- a/client/src/app/+videos/video-list/trending/video-trending-header.component.ts +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | import { Subscription } from 'rxjs' | ||
2 | import { Component, HostBinding, Inject, OnDestroy, OnInit } from '@angular/core' | ||
3 | import { ActivatedRoute, Router } from '@angular/router' | ||
4 | import { AuthService, RedirectService } from '@app/core' | ||
5 | import { ServerService } from '@app/core/server/server.service' | ||
6 | import { GlobalIconName } from '@app/shared/shared-icons' | ||
7 | import { VideoListHeaderComponent } from '@app/shared/shared-video-miniature' | ||
8 | |||
9 | interface VideoTrendingHeaderItem { | ||
10 | label: string | ||
11 | iconName: GlobalIconName | ||
12 | value: string | ||
13 | tooltip?: string | ||
14 | hidden?: boolean | ||
15 | } | ||
16 | |||
17 | @Component({ | ||
18 | selector: 'my-video-trending-title-page', | ||
19 | styleUrls: [ './video-trending-header.component.scss' ], | ||
20 | templateUrl: './video-trending-header.component.html' | ||
21 | }) | ||
22 | export class VideoTrendingHeaderComponent extends VideoListHeaderComponent implements OnInit, OnDestroy { | ||
23 | @HostBinding('class') class = 'title-page title-page-single' | ||
24 | |||
25 | buttons: VideoTrendingHeaderItem[] | ||
26 | |||
27 | private algorithmChangeSub: Subscription | ||
28 | |||
29 | constructor ( | ||
30 | @Inject('data') public data: any, | ||
31 | private route: ActivatedRoute, | ||
32 | private router: Router, | ||
33 | private auth: AuthService, | ||
34 | private serverService: ServerService, | ||
35 | private redirectService: RedirectService | ||
36 | ) { | ||
37 | super(data) | ||
38 | |||
39 | this.buttons = [ | ||
40 | { | ||
41 | label: $localize`:A variant of Trending videos based on the number of recent interactions, minus user history:Best`, | ||
42 | iconName: 'award', | ||
43 | value: 'best', | ||
44 | tooltip: $localize`Videos with the most interactions for recent videos, minus user history`, | ||
45 | hidden: true | ||
46 | }, | ||
47 | { | ||
48 | label: $localize`:A variant of Trending videos based on the number of recent interactions:Hot`, | ||
49 | iconName: 'flame', | ||
50 | value: 'hot', | ||
51 | tooltip: $localize`Videos with the most interactions for recent videos`, | ||
52 | hidden: true | ||
53 | }, | ||
54 | { | ||
55 | label: $localize`:Main variant of Trending videos based on number of recent views:Views`, | ||
56 | iconName: 'trending', | ||
57 | value: 'most-viewed', | ||
58 | tooltip: $localize`Videos with the most views during the last 24 hours` | ||
59 | }, | ||
60 | { | ||
61 | label: $localize`:A variant of Trending videos based on the number of likes:Likes`, | ||
62 | iconName: 'like', | ||
63 | value: 'most-liked', | ||
64 | tooltip: $localize`Videos that have the most likes` | ||
65 | } | ||
66 | ] | ||
67 | } | ||
68 | |||
69 | ngOnInit () { | ||
70 | const serverConfig = this.serverService.getHTMLConfig() | ||
71 | const algEnabled = serverConfig.trending.videos.algorithms.enabled | ||
72 | |||
73 | this.buttons = this.buttons.map(b => { | ||
74 | b.hidden = !algEnabled.includes(b.value) | ||
75 | |||
76 | // Best is adapted by the user history so | ||
77 | if (b.value === 'best' && !this.auth.isLoggedIn()) { | ||
78 | b.hidden = true | ||
79 | } | ||
80 | |||
81 | return b | ||
82 | }) | ||
83 | |||
84 | this.algorithmChangeSub = this.route.queryParams.subscribe( | ||
85 | queryParams => { | ||
86 | this.data.model = queryParams['alg'] || this.redirectService.getDefaultTrendingAlgorithm() | ||
87 | } | ||
88 | ) | ||
89 | } | ||
90 | |||
91 | ngOnDestroy () { | ||
92 | if (this.algorithmChangeSub) this.algorithmChangeSub.unsubscribe() | ||
93 | } | ||
94 | |||
95 | setSort () { | ||
96 | const alg = this.data.model !== this.redirectService.getDefaultTrendingAlgorithm() | ||
97 | ? this.data.model | ||
98 | : undefined | ||
99 | |||
100 | this.router.navigate( | ||
101 | [], | ||
102 | { | ||
103 | relativeTo: this.route, | ||
104 | queryParams: { alg }, | ||
105 | queryParamsHandling: 'merge' | ||
106 | } | ||
107 | ) | ||
108 | } | ||
109 | } | ||
diff --git a/client/src/app/+videos/video-list/trending/video-trending.component.ts b/client/src/app/+videos/video-list/trending/video-trending.component.ts deleted file mode 100644 index 085f29a8b..000000000 --- a/client/src/app/+videos/video-list/trending/video-trending.component.ts +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | import { Subscription } from 'rxjs' | ||
2 | import { first, switchMap } from 'rxjs/operators' | ||
3 | import { Component, ComponentFactoryResolver, Injector, OnDestroy, OnInit } from '@angular/core' | ||
4 | import { ActivatedRoute, Params, Router } from '@angular/router' | ||
5 | import { AuthService, LocalStorageService, Notifier, RedirectService, ScreenService, ServerService, UserService } from '@app/core' | ||
6 | import { HooksService } from '@app/core/plugins/hooks.service' | ||
7 | import { immutableAssign } from '@app/helpers' | ||
8 | import { VideoService } from '@app/shared/shared-main' | ||
9 | import { AbstractVideoList } from '@app/shared/shared-video-miniature' | ||
10 | import { VideoSortField } from '@shared/models' | ||
11 | import { VideoTrendingHeaderComponent } from './video-trending-header.component' | ||
12 | |||
13 | @Component({ | ||
14 | selector: 'my-videos-hot', | ||
15 | styleUrls: [ '../../../shared/shared-video-miniature/abstract-video-list.scss' ], | ||
16 | templateUrl: '../../../shared/shared-video-miniature/abstract-video-list.html' | ||
17 | }) | ||
18 | export class VideoTrendingComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
19 | HeaderComponent = VideoTrendingHeaderComponent | ||
20 | titlePage: string | ||
21 | defaultSort: VideoSortField = '-trending' | ||
22 | |||
23 | loadUserVideoPreferences = true | ||
24 | |||
25 | private algorithmChangeSub: Subscription | ||
26 | |||
27 | constructor ( | ||
28 | protected router: Router, | ||
29 | protected serverService: ServerService, | ||
30 | protected route: ActivatedRoute, | ||
31 | protected notifier: Notifier, | ||
32 | protected authService: AuthService, | ||
33 | protected userService: UserService, | ||
34 | protected screenService: ScreenService, | ||
35 | protected storageService: LocalStorageService, | ||
36 | protected cfr: ComponentFactoryResolver, | ||
37 | private videoService: VideoService, | ||
38 | private redirectService: RedirectService, | ||
39 | private hooks: HooksService | ||
40 | ) { | ||
41 | super() | ||
42 | |||
43 | this.defaultSort = this.parseAlgorithm(this.redirectService.getDefaultTrendingAlgorithm()) | ||
44 | |||
45 | this.headerComponentInjector = this.getInjector() | ||
46 | } | ||
47 | |||
48 | ngOnInit () { | ||
49 | super.ngOnInit() | ||
50 | |||
51 | this.generateSyndicationList() | ||
52 | |||
53 | // Subscribe to alg change after we loaded the data | ||
54 | // The initial alg load is handled by the parent class | ||
55 | this.algorithmChangeSub = this.onDataSubject | ||
56 | .pipe( | ||
57 | first(), | ||
58 | switchMap(() => this.route.queryParams) | ||
59 | ).subscribe(queryParams => { | ||
60 | const oldSort = this.sort | ||
61 | |||
62 | this.loadPageRouteParams(queryParams) | ||
63 | |||
64 | if (oldSort !== this.sort) this.reloadVideos() | ||
65 | } | ||
66 | ) | ||
67 | } | ||
68 | |||
69 | ngOnDestroy () { | ||
70 | super.ngOnDestroy() | ||
71 | if (this.algorithmChangeSub) this.algorithmChangeSub.unsubscribe() | ||
72 | } | ||
73 | |||
74 | getVideosObservable (page: number) { | ||
75 | const newPagination = immutableAssign(this.pagination, { currentPage: page }) | ||
76 | const params = { | ||
77 | videoPagination: newPagination, | ||
78 | sort: this.sort, | ||
79 | categoryOneOf: this.categoryOneOf, | ||
80 | languageOneOf: this.languageOneOf, | ||
81 | nsfwPolicy: this.nsfwPolicy, | ||
82 | skipCount: true | ||
83 | } | ||
84 | |||
85 | return this.hooks.wrapObsFun( | ||
86 | this.videoService.getVideos.bind(this.videoService), | ||
87 | params, | ||
88 | 'common', | ||
89 | 'filter:api.trending-videos.videos.list.params', | ||
90 | 'filter:api.trending-videos.videos.list.result' | ||
91 | ) | ||
92 | } | ||
93 | |||
94 | generateSyndicationList () { | ||
95 | this.syndicationItems = this.videoService.getVideoFeedUrls(this.sort, undefined, this.categoryOneOf) | ||
96 | } | ||
97 | |||
98 | getInjector () { | ||
99 | return Injector.create({ | ||
100 | providers: [ { | ||
101 | provide: 'data', | ||
102 | useValue: { | ||
103 | model: this.defaultSort | ||
104 | } | ||
105 | } ] | ||
106 | }) | ||
107 | } | ||
108 | |||
109 | protected loadPageRouteParams (queryParams: Params) { | ||
110 | const algorithm = queryParams['alg'] || this.redirectService.getDefaultTrendingAlgorithm() | ||
111 | |||
112 | this.sort = this.parseAlgorithm(algorithm) | ||
113 | } | ||
114 | |||
115 | private parseAlgorithm (algorithm: string): VideoSortField { | ||
116 | switch (algorithm) { | ||
117 | case 'most-viewed': | ||
118 | return '-trending' | ||
119 | |||
120 | case 'most-liked': | ||
121 | return '-likes' | ||
122 | |||
123 | default: | ||
124 | return '-' + algorithm as VideoSortField | ||
125 | } | ||
126 | } | ||
127 | } | ||