aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-video-miniature/abstract-video-list.ts')
-rw-r--r--client/src/app/shared/shared-video-miniature/abstract-video-list.ts50
1 files changed, 47 insertions, 3 deletions
diff --git a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
index a5f22585d..3e84589cd 100644
--- a/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
+++ b/client/src/app/shared/shared-video-miniature/abstract-video-list.ts
@@ -1,6 +1,16 @@
1import { fromEvent, Observable, Subject, Subscription } from 'rxjs' 1import { fromEvent, Observable, Subject, Subscription } from 'rxjs'
2import { debounceTime, switchMap, tap } from 'rxjs/operators' 2import { debounceTime, switchMap, tap } from 'rxjs/operators'
3import { Directive, OnDestroy, OnInit } from '@angular/core' 3import {
4 AfterContentInit,
5 ComponentFactoryResolver,
6 Directive,
7 Injector,
8 OnDestroy,
9 OnInit,
10 Type,
11 ViewChild,
12 ViewContainerRef
13} from '@angular/core'
4import { ActivatedRoute, Router } from '@angular/router' 14import { ActivatedRoute, Router } from '@angular/router'
5import { 15import {
6 AuthService, 16 AuthService,
@@ -19,6 +29,7 @@ import { ServerConfig, UserRight, VideoFilter, VideoSortField } from '@shared/mo
19import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' 29import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type'
20import { Syndication, Video } from '../shared-main' 30import { Syndication, Video } from '../shared-main'
21import { MiniatureDisplayOptions, OwnerDisplayType } from './video-miniature.component' 31import { MiniatureDisplayOptions, OwnerDisplayType } from './video-miniature.component'
32import { GenericHeaderComponent, VideoListHeaderComponent } from './video-list-header.component'
22 33
23enum GroupDate { 34enum GroupDate {
24 UNKNOWN = 0, 35 UNKNOWN = 0,
@@ -32,7 +43,12 @@ enum GroupDate {
32 43
33@Directive() 44@Directive()
34// tslint:disable-next-line: directive-class-suffix 45// tslint:disable-next-line: directive-class-suffix
35export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableForReuseHook { 46export abstract class AbstractVideoList implements OnInit, OnDestroy, AfterContentInit, DisableForReuseHook {
47 @ViewChild('videoListHeader', { static: true, read: ViewContainerRef }) videoListHeader: ViewContainerRef
48
49 HeaderComponent: Type<GenericHeaderComponent> = VideoListHeaderComponent
50 headerComponentInjector: Injector
51
36 pagination: ComponentPaginationLight = { 52 pagination: ComponentPaginationLight = {
37 currentPage: 1, 53 currentPage: 1,
38 itemsPerPage: 25 54 itemsPerPage: 25
@@ -92,6 +108,7 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
92 protected abstract screenService: ScreenService 108 protected abstract screenService: ScreenService
93 protected abstract storageService: LocalStorageService 109 protected abstract storageService: LocalStorageService
94 protected abstract router: Router 110 protected abstract router: Router
111 protected abstract cfr: ComponentFactoryResolver
95 abstract titlePage: string 112 abstract titlePage: string
96 113
97 private resizeSubscription: Subscription 114 private resizeSubscription: Subscription
@@ -153,6 +170,13 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
153 if (this.resizeSubscription) this.resizeSubscription.unsubscribe() 170 if (this.resizeSubscription) this.resizeSubscription.unsubscribe()
154 } 171 }
155 172
173 ngAfterContentInit () {
174 if (this.videoListHeader) {
175 // some components don't use the header: they use their own template, like my-history.component.html
176 this.setHeader.apply(this, [ this.HeaderComponent, this.headerComponentInjector ])
177 }
178 }
179
156 disableForReuse () { 180 disableForReuse () {
157 this.disabled = true 181 this.disabled = true
158 } 182 }
@@ -268,7 +292,27 @@ export abstract class AbstractVideoList implements OnInit, OnDestroy, DisableFor
268 } 292 }
269 293
270 toggleModerationDisplay () { 294 toggleModerationDisplay () {
271 throw new Error('toggleModerationDisplay is not implemented') 295 throw new Error('toggleModerationDisplay ' + $localize`function is not implemented`)
296 }
297
298 setHeader (
299 t: Type<any> = this.HeaderComponent,
300 i: Injector = this.headerComponentInjector
301 ) {
302 const injector = i || Injector.create({
303 providers: [{
304 provide: 'data',
305 useValue: {
306 titlePage: this.titlePage,
307 titleTooltip: this.titleTooltip
308 }
309 }]
310 })
311 const viewContainerRef = this.videoListHeader
312 viewContainerRef.clear()
313
314 const componentFactory = this.cfr.resolveComponentFactory(t)
315 viewContainerRef.createComponent(componentFactory, 0, injector)
272 } 316 }
273 317
274 // On videos hook for children that want to do something 318 // On videos hook for children that want to do something