From 7294aab0c879ef96c0fde15c389a2c4c1463d3c7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 20 Aug 2020 16:18:16 +0200 Subject: Add ability to set custom field to video form --- .../shared-forms/dynamic-form-field.component.html | 35 ++++++++++++++++++++++ .../shared-forms/dynamic-form-field.component.scss | 18 +++++++++++ .../shared-forms/dynamic-form-field.component.ts | 15 ++++++++++ .../app/shared/shared-forms/shared-form.module.ts | 9 ++++-- .../shared/shared-main/video/video-edit.model.ts | 6 +++- .../app/shared/shared-main/video/video.model.ts | 4 +++ .../app/shared/shared-main/video/video.service.ts | 1 + 7 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 client/src/app/shared/shared-forms/dynamic-form-field.component.html create mode 100644 client/src/app/shared/shared-forms/dynamic-form-field.component.scss create mode 100644 client/src/app/shared/shared-forms/dynamic-form-field.component.ts (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.html b/client/src/app/shared/shared-forms/dynamic-form-field.component.html new file mode 100644 index 000000000..c111ea7df --- /dev/null +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.html @@ -0,0 +1,35 @@ +
+ + + + + + + + + + + + + + + + +
+ {{ formErrors[setting.name] }} +
+ +
diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.scss b/client/src/app/shared/shared-forms/dynamic-form-field.component.scss new file mode 100644 index 000000000..70b3cf6c3 --- /dev/null +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.scss @@ -0,0 +1,18 @@ +@import '_variables'; +@import '_mixins'; + +input:not([type=submit]) { + @include peertube-input-text(340px); + + display: block; +} + +textarea { + @include peertube-textarea(340px, 200px); + + display: block; +} + +.peertube-select-container { + @include peertube-select-container(340px); +} diff --git a/client/src/app/shared/shared-forms/dynamic-form-field.component.ts b/client/src/app/shared/shared-forms/dynamic-form-field.component.ts new file mode 100644 index 000000000..b63890797 --- /dev/null +++ b/client/src/app/shared/shared-forms/dynamic-form-field.component.ts @@ -0,0 +1,15 @@ +import { Component, Input } from '@angular/core' +import { FormGroup } from '@angular/forms' +import { RegisterClientFormFieldOptions } from '@shared/models' + +@Component({ + selector: 'my-dynamic-form-field', + templateUrl: './dynamic-form-field.component.html', + styleUrls: [ './dynamic-form-field.component.scss' ] +}) + +export class DynamicFormFieldComponent { + @Input() form: FormGroup + @Input() formErrors: any + @Input() setting: RegisterClientFormFieldOptions +} diff --git a/client/src/app/shared/shared-forms/shared-form.module.ts b/client/src/app/shared/shared-forms/shared-form.module.ts index 1946ac21f..a28988f87 100644 --- a/client/src/app/shared/shared-forms/shared-form.module.ts +++ b/client/src/app/shared/shared-forms/shared-form.module.ts @@ -15,6 +15,7 @@ import { ReactiveFileComponent } from './reactive-file.component' import { SelectChannelComponent, SelectCheckboxComponent, SelectOptionsComponent, SelectTagsComponent } from './select' import { TextareaAutoResizeDirective } from './textarea-autoresize.directive' import { TimestampInputComponent } from './timestamp-input.component' +import { DynamicFormFieldComponent } from './dynamic-form-field.component' @NgModule({ imports: [ @@ -41,7 +42,9 @@ import { TimestampInputComponent } from './timestamp-input.component' SelectChannelComponent, SelectOptionsComponent, SelectTagsComponent, - SelectCheckboxComponent + SelectCheckboxComponent, + + DynamicFormFieldComponent ], exports: [ @@ -63,7 +66,9 @@ import { TimestampInputComponent } from './timestamp-input.component' SelectChannelComponent, SelectOptionsComponent, SelectTagsComponent, - SelectCheckboxComponent + SelectCheckboxComponent, + + DynamicFormFieldComponent ], providers: [ diff --git a/client/src/app/shared/shared-main/video/video-edit.model.ts b/client/src/app/shared/shared-main/video/video-edit.model.ts index 6a529e052..757b686c0 100644 --- a/client/src/app/shared/shared-main/video/video-edit.model.ts +++ b/client/src/app/shared/shared-main/video/video-edit.model.ts @@ -25,6 +25,8 @@ export class VideoEdit implements VideoUpdate { scheduleUpdate?: VideoScheduleUpdate originallyPublishedAt?: Date | string + pluginData?: any + constructor ( video?: Video & { tags: string[], @@ -55,10 +57,12 @@ export class VideoEdit implements VideoUpdate { this.scheduleUpdate = video.scheduledUpdate this.originallyPublishedAt = video.originallyPublishedAt ? new Date(video.originallyPublishedAt) : null + + this.pluginData = video.pluginData } } - patch (values: { [ id: string ]: string }) { + patch (values: { [ id: string ]: any }) { Object.keys(values).forEach((key) => { this[ key ] = values[ key ] }) diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index 73f0198e2..0dca3da0d 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts @@ -84,6 +84,8 @@ export class Video implements VideoServerModel { currentTime: number } + pluginData?: any + static buildClientUrl (videoUUID: string) { return '/videos/watch/' + videoUUID } @@ -152,6 +154,8 @@ export class Video implements VideoServerModel { this.originInstanceHost = this.account.host this.originInstanceUrl = 'https://' + this.originInstanceHost + + this.pluginData = hash.pluginData } isVideoNSFWForUser (user: User, serverConfig: ServerConfig) { diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index 48aff82b4..8a688c8ed 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -96,6 +96,7 @@ export class VideoService implements VideosProvider { downloadEnabled: video.downloadEnabled, thumbnailfile: video.thumbnailfile, previewfile: video.previewfile, + pluginData: video.pluginData, scheduleUpdate, originallyPublishedAt } -- cgit v1.2.3