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 { I18n } from '@ngx-translate/i18n-polyfill'
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 {
30 @Input() pagination: ComponentPagination
31 @Input() titlePage: string
32 @Input() miniatureDisplayOptions: MiniatureDisplayOptions
33 @Input() ownerDisplayType: OwnerDisplayType
35 @Input() getVideosObservableFunction: (page: number, sort?: VideoSortField) => Observable<ResultList<Video>>
37 @ContentChildren(PeerTubeTemplateDirective) templates: QueryList<PeerTubeTemplateDirective<'rowButtons' | 'globalButtons'>>
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 userService: UserService,
54 protected screenService: ScreenService,
55 protected storageService: LocalStorageService,
56 protected serverService: ServerService
61 @Input() get selection () {
62 return this._selection
65 set selection (selection: SelectionType) {
66 this._selection = selection
67 this.selectionChange.emit(this._selection)
70 @Input() get videosModel () {
74 set videosModel (videos: Video[]) {
76 this.videosModelChange.emit(this.videos)
83 ngAfterContentInit () {
85 const t = this.templates.find(t => t.name === 'rowButtons')
86 if (t) this.rowButtonsTemplate = t.template
90 const t = this.templates.find(t => t.name === 'globalButtons')
91 if (t) this.globalButtonsTemplate = t.template
99 getVideosObservable (page: number) {
100 return this.getVideosObservableFunction(page, this.sort)
103 abortSelectionMode () {
107 isInSelectionMode () {
108 return Object.keys(this._selection).some(k => this._selection[ k ] === true)
111 generateSyndicationList () {
112 throw new Error('Method not implemented.')
115 protected onMoreVideos () {
116 this.videosModel = this.videos