import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms'
import { InstanceService } from '@app/shared/shared-instance'
import { VideoCaptionEdit, VideoCaptionWithPathEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
+import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
+import { logger } from '@root-helpers/logger'
import { PluginInfo } from '@root-helpers/plugins-manager'
import {
HTMLServerConfig,
VideoDetails,
VideoPrivacy
} from '@shared/models'
+import { VideoSource } from '@shared/models/videos/video-source'
import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
-import { VideoCaptionEditModalComponent } from './video-caption-edit-modal/video-caption-edit-modal.component'
+import { VideoCaptionEditModalContentComponent } from './video-caption-edit-modal-content/video-caption-edit-modal-content.component'
import { VideoEditType } from './video-edit.type'
type VideoLanguages = VideoConstant<string> & { group?: string }
@Input() forbidScheduledPublication = true
@Input() videoCaptions: VideoCaptionWithPathEdit[] = []
+ @Input() videoSource: VideoSource
+
+ @Input() hideWaitTranscoding = false
- @Input() waitTranscodingEnabled = true
@Input() type: VideoEditType
@Input() liveVideo: LiveVideo
@ViewChild('videoCaptionAddModal', { static: true }) videoCaptionAddModal: VideoCaptionAddModalComponent
- @ViewChild('videoCaptionEditModal', { static: true }) editCaptionModal: VideoCaptionEditModalComponent
@Output() formBuilt = new EventEmitter<void>()
@Output() pluginFieldsAdded = new EventEmitter<void>()
private i18nPrimengCalendarService: I18nPrimengCalendarService,
private ngZone: NgZone,
private hooks: HooksService,
- private cd: ChangeDetectorRef
+ private cd: ChangeDetectorRef,
+ private modalService: NgbModal
) {
this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone()
this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat()
nsfw: 'false',
commentsEnabled: this.serverConfig.defaults.publish.commentsEnabled,
downloadEnabled: this.serverConfig.defaults.publish.downloadEnabled,
- waitTranscoding: 'true',
+ waitTranscoding: true,
licence: this.serverConfig.defaults.publish.licence,
tags: []
}
this.trackChannelChange()
this.trackPrivacyChange()
- this.trackLivePermanentFieldChange()
this.formBuilt.emit()
}
this.schedulerInterval = setInterval(() => this.minScheduledDate = new Date(), 1000 * 60) // Update every minute
})
- this.hooks.runAction('action:video-edit.init', 'video-edit', { type: this.type })
+ const updateFormForPlugins = (values: any) => {
+ this.form.patchValue(values)
+ this.cd.detectChanges()
+ }
+ this.hooks.runAction('action:video-edit.init', 'video-edit', { type: this.type, updateForm: updateFormForPlugins })
+
+ this.form.valueChanges.subscribe(() => {
+ this.hooks.runAction('action:video-edit.form.updated', 'video-edit', { type: this.type, formValues: this.form.value })
+ })
}
ngOnDestroy () {
this.videoCaptionAddModal.show()
}
+ openEditCaptionModal (videoCaption: VideoCaptionWithPathEdit) {
+ const modalRef = this.modalService.open(VideoCaptionEditModalContentComponent, { centered: true, keyboard: false })
+ modalRef.componentInstance.videoCaption = videoCaption
+ modalRef.componentInstance.serverConfig = this.serverConfig
+ modalRef.componentInstance.captionEdited.subscribe(this.onCaptionEdited.bind(this))
+ }
+
isSaveReplayEnabled () {
return this.serverConfig.live.allowReplay
}
for (const setting of this.pluginFields) {
await this.pluginService.translateSetting(setting.pluginInfo.plugin.npmName, setting.commonOptions)
+ // Not a form input, just a HTML tag
+ if (setting.commonOptions.type === 'html') continue
+
const validator = async (control: AbstractControl) => {
if (!setting.commonOptions.error) return null
const oldChannel = this.userVideoChannels.find(c => c.id === oldChannelId)
if (!newChannel || !oldChannel) {
- console.error('Cannot find new or old channel.')
+ logger.error('Cannot find new or old channel.')
return
}
)
}
- private trackLivePermanentFieldChange () {
- // We will update the "support" field depending on the channel
- this.form.controls['permanentLive']
- .valueChanges
- .subscribe(
- permanentLive => {
- const saveReplayControl = this.form.controls['saveReplay']
-
- if (permanentLive === true) {
- saveReplayControl.setValue(false)
- saveReplayControl.disable()
- } else {
- saveReplayControl.enable()
- }
- }
- )
- }
-
private updateSupportField (support: string) {
return this.form.patchValue({ support: support || '' })
}