import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
-
import { VIDEO_CAPTION_FILE_CONTENT_VALIDATOR } from '@app/shared/form-validators/video-captions-validators'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { VideoCaptionEdit, VideoCaptionService, VideoCaptionWithPathEdit } from '@app/shared/shared-main'
videoCaptionLanguages: VideoConstant<string>[] = []
private openedModal: NgbModalRef
- private closingModal = false
constructor (
protected formValidatorService: FormValidatorService,
loadCaptionContent () {
const { captionPath } = this.videoCaption
- if (captionPath) {
- this.videoCaptionService.getCaptionContent({
- captionPath
- }).subscribe((res) => {
+ if (!captionPath) return
+
+ this.videoCaptionService.getCaptionContent({ captionPath })
+ .subscribe(res => {
this.form.patchValue({
captionFileContent: res
})
})
- }
}
show () {
- this.closingModal = false
-
this.openedModal = this.modalService.open(this.modal, { centered: true, keyboard: false })
}
hide () {
- this.closingModal = true
this.openedModal.close()
}
this.hide()
}
- isReplacingExistingCaption () {
- return true
- }
-
updateCaption () {
const format = 'vtt'
const languageId = this.videoCaption.language.id
const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId)
+
this.captionEdited.emit({
language: languageObject,
captionfile: new File([ this.form.value['captionFileContent'] ], `${languageId}.${format}`, {
@Input() userVideoChannels: SelectChannelItem[] = []
@Input() forbidScheduledPublication = true
- @Input() videoCaptions: (VideoCaptionWithPathEdit)[] = []
+ @Input() videoCaptions: VideoCaptionWithPathEdit[] = []
@Input() waitTranscodingEnabled = true
@Input() type: VideoEditType
import { VideoService } from '@app/shared/shared-main/video'
import { peertubeTranslate } from '@shared/core-utils/i18n'
import { ResultList, VideoCaption } from '@shared/models'
-import { VideoCaptionEdit } from './video-caption-edit.model'
import { environment } from '../../../../environments/environment'
+import { VideoCaptionEdit } from './video-caption-edit.model'
@Injectable()
export class VideoCaptionService {
}
getCaptionContent ({ captionPath }: Pick<VideoCaption, 'captionPath'>) {
- return this.authHttp.get(`${environment.originServerUrl}${captionPath}`, { responseType: 'text' })
+ return this.authHttp.get(environment.originServerUrl + captionPath, { responseType: 'text' })
}
}