diff options
Diffstat (limited to 'client/src/app/+videos/+video-edit/shared/video-edit.component.ts')
-rw-r--r-- | client/src/app/+videos/+video-edit/shared/video-edit.component.ts | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index f51f52160..34119f7ab 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts | |||
@@ -2,7 +2,7 @@ import { forkJoin } from 'rxjs' | |||
2 | import { map } from 'rxjs/operators' | 2 | import { map } from 'rxjs/operators' |
3 | import { SelectChannelItem } from 'src/types/select-options-item.model' | 3 | import { SelectChannelItem } from 'src/types/select-options-item.model' |
4 | import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' | 4 | import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core' |
5 | import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms' | 5 | import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms' |
6 | import { HooksService, PluginService, ServerService } from '@app/core' | 6 | import { HooksService, PluginService, ServerService } from '@app/core' |
7 | import { removeElementFromArray } from '@app/helpers' | 7 | import { removeElementFromArray } from '@app/helpers' |
8 | import { | 8 | import { |
@@ -21,13 +21,17 @@ import { | |||
21 | import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms' | 21 | import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms' |
22 | import { InstanceService } from '@app/shared/shared-instance' | 22 | import { InstanceService } from '@app/shared/shared-instance' |
23 | import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' | 23 | import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main' |
24 | import { LiveVideo, ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models' | 24 | import { LiveVideo, ServerConfig, VideoConstant, VideoDetails, VideoPrivacy } from '@shared/models' |
25 | import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model' | 25 | import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model' |
26 | import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' | 26 | import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service' |
27 | import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' | 27 | import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component' |
28 | import { VideoEditType } from './video-edit.type' | 28 | import { VideoEditType } from './video-edit.type' |
29 | 29 | ||
30 | type VideoLanguages = VideoConstant<string> & { group?: string } | 30 | type VideoLanguages = VideoConstant<string> & { group?: string } |
31 | type PluginField = { | ||
32 | commonOptions: RegisterClientFormFieldOptions | ||
33 | videoFormOptions: RegisterClientVideoFieldOptions | ||
34 | } | ||
31 | 35 | ||
32 | @Component({ | 36 | @Component({ |
33 | selector: 'my-video-edit', | 37 | selector: 'my-video-edit', |
@@ -38,9 +42,14 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
38 | @Input() form: FormGroup | 42 | @Input() form: FormGroup |
39 | @Input() formErrors: { [ id: string ]: string } = {} | 43 | @Input() formErrors: { [ id: string ]: string } = {} |
40 | @Input() validationMessages: FormReactiveValidationMessages = {} | 44 | @Input() validationMessages: FormReactiveValidationMessages = {} |
45 | |||
46 | @Input() videoToUpdate: VideoDetails | ||
47 | |||
41 | @Input() userVideoChannels: SelectChannelItem[] = [] | 48 | @Input() userVideoChannels: SelectChannelItem[] = [] |
42 | @Input() schedulePublicationPossible = true | 49 | @Input() schedulePublicationPossible = true |
50 | |||
43 | @Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = [] | 51 | @Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = [] |
52 | |||
44 | @Input() waitTranscodingEnabled = true | 53 | @Input() waitTranscodingEnabled = true |
45 | @Input() type: VideoEditType | 54 | @Input() type: VideoEditType |
46 | @Input() liveVideo: LiveVideo | 55 | @Input() liveVideo: LiveVideo |
@@ -57,9 +66,6 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
57 | videoLicences: VideoConstant<number>[] = [] | 66 | videoLicences: VideoConstant<number>[] = [] |
58 | videoLanguages: VideoLanguages[] = [] | 67 | videoLanguages: VideoLanguages[] = [] |
59 | 68 | ||
60 | tagValidators: ValidatorFn[] | ||
61 | tagValidatorsMessages: { [ name: string ]: string } | ||
62 | |||
63 | pluginDataFormGroup: FormGroup | 69 | pluginDataFormGroup: FormGroup |
64 | 70 | ||
65 | schedulePublicationEnabled = false | 71 | schedulePublicationEnabled = false |
@@ -73,10 +79,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
73 | 79 | ||
74 | serverConfig: ServerConfig | 80 | serverConfig: ServerConfig |
75 | 81 | ||
76 | pluginFields: { | 82 | pluginFields: PluginField[] = [] |
77 | commonOptions: RegisterClientFormFieldOptions | ||
78 | videoFormOptions: RegisterClientVideoFieldOptions | ||
79 | }[] = [] | ||
80 | 83 | ||
81 | private schedulerInterval: any | 84 | private schedulerInterval: any |
82 | private firstPatchDone = false | 85 | private firstPatchDone = false |
@@ -92,7 +95,6 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
92 | private ngZone: NgZone, | 95 | private ngZone: NgZone, |
93 | private hooks: HooksService | 96 | private hooks: HooksService |
94 | ) { | 97 | ) { |
95 | this.calendarLocale = this.i18nPrimengCalendarService.getCalendarLocale() | ||
96 | this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone() | 98 | this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone() |
97 | this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat() | 99 | this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat() |
98 | } | 100 | } |
@@ -251,6 +253,16 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
251 | return this.form.value['permanentLive'] === true | 253 | return this.form.value['permanentLive'] === true |
252 | } | 254 | } |
253 | 255 | ||
256 | isPluginFieldHidden (pluginField: PluginField) { | ||
257 | if (typeof pluginField.commonOptions.hidden !== 'function') return false | ||
258 | |||
259 | return pluginField.commonOptions.hidden({ | ||
260 | formValues: this.form.value, | ||
261 | videoToUpdate: this.videoToUpdate, | ||
262 | liveVideo: this.liveVideo | ||
263 | }) | ||
264 | } | ||
265 | |||
254 | private sortVideoCaptions () { | 266 | private sortVideoCaptions () { |
255 | this.videoCaptions.sort((v1, v2) => { | 267 | this.videoCaptions.sort((v1, v2) => { |
256 | if (v1.language.label < v2.language.label) return -1 | 268 | if (v1.language.label < v2.language.label) return -1 |