diff options
author | lutangar <johan.dufour@gmail.com> | 2021-12-22 18:36:56 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-02-28 14:29:01 +0100 |
commit | 57d74ec83d64daaf2efc6a3dad8adbcfe1f59415 (patch) | |
tree | 3d56b8c45e6f7c88149c34e9c93b994c94587107 /client/src/app/shared | |
parent | e66d0892b12c5b3b3e8a6b7a4129103a912486a9 (diff) | |
download | PeerTube-57d74ec83d64daaf2efc6a3dad8adbcfe1f59415.tar.gz PeerTube-57d74ec83d64daaf2efc6a3dad8adbcfe1f59415.tar.zst PeerTube-57d74ec83d64daaf2efc6a3dad8adbcfe1f59415.zip |
Add simple subtitle edition from video captions tab
Introduce a new __Edit__ button on a subtitle.
It opens a modal with simple textarea allowing the user to do quick corrections on a subtitle.
Diffstat (limited to 'client/src/app/shared')
3 files changed, 16 insertions, 2 deletions
diff --git a/client/src/app/shared/form-validators/video-captions-validators.ts b/client/src/app/shared/form-validators/video-captions-validators.ts index a16216422..e589fe934 100644 --- a/client/src/app/shared/form-validators/video-captions-validators.ts +++ b/client/src/app/shared/form-validators/video-captions-validators.ts | |||
@@ -14,3 +14,10 @@ export const VIDEO_CAPTION_FILE_VALIDATOR: BuildFormValidator = { | |||
14 | required: $localize`Video caption file is required.` | 14 | required: $localize`Video caption file is required.` |
15 | } | 15 | } |
16 | } | 16 | } |
17 | |||
18 | export const VIDEO_CAPTION_FILE_CONTENT_VALIDATOR: BuildFormValidator = { | ||
19 | VALIDATORS: [ Validators.required ], | ||
20 | MESSAGES: { | ||
21 | required: $localize`Caption content is required.` | ||
22 | } | ||
23 | } | ||
diff --git a/client/src/app/shared/shared-main/video-caption/video-caption-edit.model.ts b/client/src/app/shared/shared-main/video-caption/video-caption-edit.model.ts index 732f20158..129e80bc0 100644 --- a/client/src/app/shared/shared-main/video-caption/video-caption-edit.model.ts +++ b/client/src/app/shared/shared-main/video-caption/video-caption-edit.model.ts | |||
@@ -4,6 +4,8 @@ export interface VideoCaptionEdit { | |||
4 | label?: string | 4 | label?: string |
5 | } | 5 | } |
6 | 6 | ||
7 | action?: 'CREATE' | 'REMOVE' | 7 | action?: 'CREATE' | 'REMOVE' | 'UPDATE' |
8 | captionfile?: any | 8 | captionfile?: any |
9 | } | 9 | } |
10 | |||
11 | export type VideoCaptionWithPathEdit = VideoCaptionEdit & { captionPath?: string } | ||
diff --git a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts index 97b79d842..67eb09e4d 100644 --- a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts +++ b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts | |||
@@ -8,6 +8,7 @@ import { VideoService } from '@app/shared/shared-main/video' | |||
8 | import { peertubeTranslate } from '@shared/core-utils/i18n' | 8 | import { peertubeTranslate } from '@shared/core-utils/i18n' |
9 | import { ResultList, VideoCaption } from '@shared/models' | 9 | import { ResultList, VideoCaption } from '@shared/models' |
10 | import { VideoCaptionEdit } from './video-caption-edit.model' | 10 | import { VideoCaptionEdit } from './video-caption-edit.model' |
11 | import { environment } from '../../../../environments/environment' | ||
11 | 12 | ||
12 | @Injectable() | 13 | @Injectable() |
13 | export class VideoCaptionService { | 14 | export class VideoCaptionService { |
@@ -57,7 +58,7 @@ export class VideoCaptionService { | |||
57 | let obs: Observable<any> = of(undefined) | 58 | let obs: Observable<any> = of(undefined) |
58 | 59 | ||
59 | for (const videoCaption of videoCaptions) { | 60 | for (const videoCaption of videoCaptions) { |
60 | if (videoCaption.action === 'CREATE') { | 61 | if (videoCaption.action === 'CREATE' || videoCaption.action === 'UPDATE') { |
61 | obs = obs.pipe(switchMap(() => this.addCaption(videoId, videoCaption.language.id, videoCaption.captionfile))) | 62 | obs = obs.pipe(switchMap(() => this.addCaption(videoId, videoCaption.language.id, videoCaption.captionfile))) |
62 | } else if (videoCaption.action === 'REMOVE') { | 63 | } else if (videoCaption.action === 'REMOVE') { |
63 | obs = obs.pipe(switchMap(() => this.removeCaption(videoId, videoCaption.language.id))) | 64 | obs = obs.pipe(switchMap(() => this.removeCaption(videoId, videoCaption.language.id))) |
@@ -66,4 +67,8 @@ export class VideoCaptionService { | |||
66 | 67 | ||
67 | return obs | 68 | return obs |
68 | } | 69 | } |
70 | |||
71 | getCaptionContent ({ captionPath }: Pick<VideoCaption, 'captionPath'>) { | ||
72 | return this.authHttp.get(`${environment.originServerUrl}${captionPath}`, { responseType: 'text' }) | ||
73 | } | ||
69 | } | 74 | } |