12 } from '@angular/core'
13 import { ActivatedRoute, Router } from '@angular/router'
14 import { AbstractVideoList } from '@app/shared/video/abstract-video-list'
15 import { AuthService, Notifier, ServerService } from '@app/core'
16 import { ScreenService } from '@app/shared/misc/screen.service'
17 import { MiniatureDisplayOptions } from '@app/shared/video/video-miniature.component'
18 import { Observable } from 'rxjs'
19 import { Video } from '@app/shared/video/video.model'
20 import { PeerTubeTemplateDirective } from '@app/shared/angular/peertube-template.directive'
21 import { VideoSortField } from '@app/shared/video/sort-field.type'
22 import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
24 export type SelectionType = { [ id: number ]: boolean }
27 selector: 'my-videos-selection',
28 templateUrl: './videos-selection.component.html',
29 styleUrls: [ './videos-selection.component.scss' ]
31 export class VideosSelectionComponent extends AbstractVideoList implements OnInit, OnDestroy, AfterContentInit {
32 @Input() pagination: ComponentPagination
33 @Input() titlePage: string
34 @Input() miniatureDisplayOptions: MiniatureDisplayOptions
35 @Input() getVideosObservableFunction: (page: number, sort?: VideoSortField) => Observable<{ videos: Video[], totalVideos: number }>
36 @ContentChildren(PeerTubeTemplateDirective) templates: QueryList<PeerTubeTemplateDirective>
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 screenService: ScreenService,
52 protected serverService: ServerService
57 @Input() get selection () {
58 return this._selection
61 set selection (selection: SelectionType) {
62 this._selection = selection
63 this.selectionChange.emit(this._selection)
66 @Input() get videosModel () {
70 set videosModel (videos: Video[]) {
72 this.videosModelChange.emit(this.videos)
79 ngAfterContentInit () {
81 const t = this.templates.find(t => t.name === 'rowButtons')
82 if (t) this.rowButtonsTemplate = t.template
86 const t = this.templates.find(t => t.name === 'globalButtons')
87 if (t) this.globalButtonsTemplate = t.template
95 getVideosObservable (page: number) {
96 return this.getVideosObservableFunction(page, this.sort)
99 abortSelectionMode () {
103 isInSelectionMode () {
104 return Object.keys(this._selection).some(k => this._selection[ k ] === true)
107 generateSyndicationList () {
108 throw new Error('Method not implemented.')
111 protected onMoreVideos () {
112 this.videosModel = this.videos