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'
23 import { I18n } from '@ngx-translate/i18n-polyfill'
25 export type SelectionType = { [ id: number ]: boolean }
28 selector: 'my-videos-selection',
29 templateUrl: './videos-selection.component.html',
30 styleUrls: [ './videos-selection.component.scss' ]
32 export class VideosSelectionComponent extends AbstractVideoList implements OnInit, OnDestroy, AfterContentInit {
33 @Input() pagination: ComponentPagination
34 @Input() titlePage: string
35 @Input() miniatureDisplayOptions: MiniatureDisplayOptions
36 @Input() getVideosObservableFunction: (page: number, sort?: VideoSortField) => Observable<{ videos: Video[], totalVideos: number }>
37 @ContentChildren(PeerTubeTemplateDirective) templates: QueryList<PeerTubeTemplateDirective>
39 @Output() selectionChange = new EventEmitter<SelectionType>()
40 @Output() videosModelChange = new EventEmitter<Video[]>()
42 _selection: SelectionType = {}
44 rowButtonsTemplate: TemplateRef<any>
45 globalButtonsTemplate: TemplateRef<any>
49 protected router: Router,
50 protected route: ActivatedRoute,
51 protected notifier: Notifier,
52 protected authService: AuthService,
53 protected screenService: ScreenService,
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