2021-07-01 17:28:47 +02:00
|
|
|
import { finalize } from 'rxjs/operators'
|
2023-01-25 08:59:42 +01:00
|
|
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
|
2021-07-01 17:28:47 +02:00
|
|
|
import { AuthService, Notifier } from '@app/core'
|
2021-08-17 14:42:53 +02:00
|
|
|
import { FindInBulkService } from '@app/shared/shared-search'
|
|
|
|
import { Video } from '../../shared-main'
|
2021-05-31 11:33:49 +02:00
|
|
|
import { MiniatureDisplayOptions } from '../../shared-video-miniature'
|
2021-06-29 16:16:12 +02:00
|
|
|
import { CustomMarkupComponent } from './shared'
|
2021-05-27 15:59:55 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Markup component that creates a video miniature only
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'my-video-miniature-markup',
|
|
|
|
templateUrl: 'video-miniature-markup.component.html',
|
2023-01-13 09:39:35 +01:00
|
|
|
styleUrls: [ 'video-miniature-markup.component.scss' ],
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
2021-05-27 15:59:55 +02:00
|
|
|
})
|
2021-06-29 16:16:12 +02:00
|
|
|
export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
|
2021-05-27 15:59:55 +02:00
|
|
|
@Input() uuid: string
|
2021-06-09 09:32:47 +02:00
|
|
|
@Input() onlyDisplayTitle: boolean
|
2021-10-18 15:41:20 +02:00
|
|
|
@Input() video: Video
|
2021-05-27 15:59:55 +02:00
|
|
|
|
2021-06-29 16:16:12 +02:00
|
|
|
@Output() loaded = new EventEmitter<boolean>()
|
|
|
|
|
2021-05-27 15:59:55 +02:00
|
|
|
displayOptions: MiniatureDisplayOptions = {
|
|
|
|
date: true,
|
|
|
|
views: true,
|
|
|
|
by: true,
|
|
|
|
avatar: false,
|
|
|
|
privacyLabel: false,
|
|
|
|
privacyText: false,
|
|
|
|
state: false,
|
|
|
|
blacklistInfo: false
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor (
|
|
|
|
private auth: AuthService,
|
2021-08-02 15:29:09 +02:00
|
|
|
private findInBulk: FindInBulkService,
|
2023-01-25 08:59:42 +01:00
|
|
|
private notifier: Notifier,
|
|
|
|
private cd: ChangeDetectorRef
|
2021-05-27 15:59:55 +02:00
|
|
|
) { }
|
|
|
|
|
|
|
|
getUser () {
|
|
|
|
return this.auth.getUser()
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit () {
|
2021-06-09 09:32:47 +02:00
|
|
|
if (this.onlyDisplayTitle) {
|
|
|
|
for (const key of Object.keys(this.displayOptions)) {
|
|
|
|
this.displayOptions[key] = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 15:41:20 +02:00
|
|
|
if (this.video) return
|
|
|
|
|
2021-08-02 15:29:09 +02:00
|
|
|
this.findInBulk.getVideo(this.uuid)
|
2021-07-01 17:28:47 +02:00
|
|
|
.pipe(finalize(() => this.loaded.emit(true)))
|
2021-08-17 11:27:47 +02:00
|
|
|
.subscribe({
|
2023-01-25 08:59:42 +01:00
|
|
|
next: video => {
|
|
|
|
this.video = video
|
|
|
|
this.cd.markForCheck()
|
|
|
|
},
|
2021-06-29 16:16:12 +02:00
|
|
|
|
2021-08-17 11:27:47 +02:00
|
|
|
error: err => this.notifier.error($localize`Error in video miniature component: ${err.message}`)
|
|
|
|
})
|
2021-05-27 15:59:55 +02:00
|
|
|
}
|
|
|
|
}
|