1 import { Observable } from 'rxjs'
5 ComponentFactoryResolver,
14 } from '@angular/core'
15 import { ActivatedRoute, Router } from '@angular/router'
16 import { AuthService, ComponentPagination, LocalStorageService, Notifier, ScreenService, ServerService, User, UserService } from '@app/core'
17 import { ResultList, VideoSortField } from '@shared/models'
18 import { PeerTubeTemplateDirective, Video } from '../shared-main'
19 import { AbstractVideoList } from './abstract-video-list'
20 import { MiniatureDisplayOptions, OwnerDisplayType } from './video-miniature.component'
22 export type SelectionType = { [ id: number ]: boolean }
25 selector: 'my-videos-selection',
26 templateUrl: './videos-selection.component.html',
27 styleUrls: [ './videos-selection.component.scss' ]
29 export class VideosSelectionComponent extends AbstractVideoList implements OnInit, OnDestroy, AfterContentInit {
31 @Input() pagination: ComponentPagination
32 @Input() titlePage: string
33 @Input() miniatureDisplayOptions: MiniatureDisplayOptions
34 @Input() ownerDisplayType: OwnerDisplayType
36 @Input() getVideosObservableFunction: (page: number, sort?: VideoSortField) => Observable<ResultList<Video>>
38 @ContentChildren(PeerTubeTemplateDirective) templates: QueryList<PeerTubeTemplateDirective<'rowButtons' | 'globalButtons'>>
40 @Output() selectionChange = new EventEmitter<SelectionType>()
41 @Output() videosModelChange = new EventEmitter<Video[]>()
43 _selection: SelectionType = {}
45 rowButtonsTemplate: TemplateRef<any>
46 globalButtonsTemplate: TemplateRef<any>
49 protected router: Router,
50 protected route: ActivatedRoute,
51 protected notifier: Notifier,
52 protected authService: AuthService,
53 protected userService: UserService,
54 protected screenService: ScreenService,
55 protected storageService: LocalStorageService,
56 protected serverService: ServerService,
57 protected cfr: ComponentFactoryResolver
62 @Input() get selection () {
63 return this._selection
66 set selection (selection: SelectionType) {
67 this._selection = selection
68 this.selectionChange.emit(this._selection)
71 @Input() get videosModel () {
75 set videosModel (videos: Video[]) {
77 this.videosModelChange.emit(this.videos)
84 ngAfterContentInit () {
86 const t = this.templates.find(t => t.name === 'rowButtons')
87 if (t) this.rowButtonsTemplate = t.template
91 const t = this.templates.find(t => t.name === 'globalButtons')
92 if (t) this.globalButtonsTemplate = t.template
100 getVideosObservable (page: number) {
101 return this.getVideosObservableFunction(page, this.sort)
104 abortSelectionMode () {
108 isInSelectionMode () {
109 return Object.keys(this._selection).some(k => this._selection[ k ] === true)
112 generateSyndicationList () {
113 throw new Error('Method not implemented.')
116 protected onMoreVideos () {
117 this.videosModel = this.videos