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'
25 import { UserService } from '../users'
26 import { LocalStorageService } from '../misc/storage.service'
28 export type SelectionType = { [ id: number ]: boolean }
31 selector: 'my-videos-selection',
32 templateUrl: './videos-selection.component.html',
33 styleUrls: [ './videos-selection.component.scss' ]
35 export class VideosSelectionComponent extends AbstractVideoList implements OnInit, OnDestroy, AfterContentInit {
36 @Input() pagination: ComponentPagination
37 @Input() titlePage: string
38 @Input() miniatureDisplayOptions: MiniatureDisplayOptions
39 @Input() getVideosObservableFunction: (page: number, sort?: VideoSortField) => Observable<ResultList<Video>>
40 @ContentChildren(PeerTubeTemplateDirective) templates: QueryList<PeerTubeTemplateDirective<'rowButtons' | 'globalButtons'>>
42 @Output() selectionChange = new EventEmitter<SelectionType>()
43 @Output() videosModelChange = new EventEmitter<Video[]>()
45 _selection: SelectionType = {}
47 rowButtonsTemplate: TemplateRef<any>
48 globalButtonsTemplate: TemplateRef<any>
52 protected router: Router,
53 protected route: ActivatedRoute,
54 protected notifier: Notifier,
55 protected authService: AuthService,
56 protected userService: UserService,
57 protected screenService: ScreenService,
58 protected storageService: LocalStorageService,
59 protected serverService: ServerService
64 @Input() get selection () {
65 return this._selection
68 set selection (selection: SelectionType) {
69 this._selection = selection
70 this.selectionChange.emit(this._selection)
73 @Input() get videosModel () {
77 set videosModel (videos: Video[]) {
79 this.videosModelChange.emit(this.videos)
86 ngAfterContentInit () {
88 const t = this.templates.find(t => t.name === 'rowButtons')
89 if (t) this.rowButtonsTemplate = t.template
93 const t = this.templates.find(t => t.name === 'globalButtons')
94 if (t) this.globalButtonsTemplate = t.template
102 getVideosObservable (page: number) {
103 return this.getVideosObservableFunction(page, this.sort)
106 abortSelectionMode () {
110 isInSelectionMode () {
111 return Object.keys(this._selection).some(k => this._selection[ k ] === true)
114 generateSyndicationList () {
115 throw new Error('Method not implemented.')
118 protected onMoreVideos () {
119 this.videosModel = this.videos