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'
24 import { ResultList } from '@shared/models'
26 export type SelectionType = { [ id: number ]: boolean }
29 selector: 'my-videos-selection',
30 templateUrl: './videos-selection.component.html',
31 styleUrls: [ './videos-selection.component.scss' ]
33 export class VideosSelectionComponent extends AbstractVideoList implements OnInit, OnDestroy, AfterContentInit {
34 @Input() pagination: ComponentPagination
35 @Input() titlePage: string
36 @Input() miniatureDisplayOptions: MiniatureDisplayOptions
37 @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>
50 protected router: Router,
51 protected route: ActivatedRoute,
52 protected notifier: Notifier,
53 protected authService: AuthService,
54 protected screenService: ScreenService,
55 protected serverService: ServerService
60 @Input() get selection () {
61 return this._selection
64 set selection (selection: SelectionType) {
65 this._selection = selection
66 this.selectionChange.emit(this._selection)
69 @Input() get videosModel () {
73 set videosModel (videos: Video[]) {
75 this.videosModelChange.emit(this.videos)
82 ngAfterContentInit () {
84 const t = this.templates.find(t => t.name === 'rowButtons')
85 if (t) this.rowButtonsTemplate = t.template
89 const t = this.templates.find(t => t.name === 'globalButtons')
90 if (t) this.globalButtonsTemplate = t.template
98 getVideosObservable (page: number) {
99 return this.getVideosObservableFunction(page, this.sort)
102 abortSelectionMode () {
106 isInSelectionMode () {
107 return Object.keys(this._selection).some(k => this._selection[ k ] === true)
110 generateSyndicationList () {
111 throw new Error('Method not implemented.')
114 protected onMoreVideos () {
115 this.videosModel = this.videos