1 import { Observable } from 'rxjs'
13 } from '@angular/core'
14 import { ActivatedRoute, Router } from '@angular/router'
15 import { AuthService, ComponentPagination, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core'
16 import { ResultList, VideoSortField } from '@shared/models'
17 import { PeerTubeTemplateDirective, Video } from '../shared-main'
18 import { AbstractVideoList } from './abstract-video-list'
19 import { MiniatureDisplayOptions, OwnerDisplayType } from './video-miniature.component'
21 export type SelectionType = { [ id: number ]: boolean }
24 selector: 'my-videos-selection',
25 templateUrl: './videos-selection.component.html',
26 styleUrls: [ './videos-selection.component.scss' ]
28 export class VideosSelectionComponent extends AbstractVideoList implements OnInit, OnDestroy, AfterContentInit {
29 @Input() pagination: ComponentPagination
30 @Input() titlePage: string
31 @Input() miniatureDisplayOptions: MiniatureDisplayOptions
32 @Input() ownerDisplayType: OwnerDisplayType
34 @Input() getVideosObservableFunction: (page: number, sort?: VideoSortField) => Observable<ResultList<Video>>
36 @ContentChildren(PeerTubeTemplateDirective) templates: QueryList<PeerTubeTemplateDirective<'rowButtons' | 'globalButtons'>>
38 @Output() selectionChange = new EventEmitter<SelectionType>()
39 @Output() videosModelChange = new EventEmitter<Video[]>()
41 _selection: SelectionType = {}
43 rowButtonsTemplate: TemplateRef<any>
44 globalButtonsTemplate: TemplateRef<any>
47 protected router: Router,
48 protected route: ActivatedRoute,
49 protected notifier: Notifier,
50 protected authService: AuthService,
51 protected userService: UserService,
52 protected screenService: ScreenService,
53 protected storageService: LocalStorageService,
54 protected serverService: ServerService
59 @Input() get selection () {
60 return this._selection
63 set selection (selection: SelectionType) {
64 this._selection = selection
65 this.selectionChange.emit(this._selection)
68 @Input() get videosModel () {
72 set videosModel (videos: Video[]) {
74 this.videosModelChange.emit(this.videos)
81 ngAfterContentInit () {
83 const t = this.templates.find(t => t.name === 'rowButtons')
84 if (t) this.rowButtonsTemplate = t.template
88 const t = this.templates.find(t => t.name === 'globalButtons')
89 if (t) this.globalButtonsTemplate = t.template
97 getVideosObservable (page: number) {
98 return this.getVideosObservableFunction(page, this.sort)
101 abortSelectionMode () {
105 isInSelectionMode () {
106 return Object.keys(this._selection).some(k => this._selection[ k ] === true)
109 generateSyndicationList () {
110 throw new Error('Method not implemented.')
113 protected onMoreVideos () {
114 this.videosModel = this.videos