]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+videos/+video-edit/shared/video-edit-utils.ts
Add warning below live stream key field
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-edit / shared / video-edit-utils.ts
CommitLineData
c6c0fa6c
C
1import { FormGroup } from '@angular/forms'
2import { VideoEdit } from '@app/shared/shared-main'
3
4function hydrateFormFromVideo (formGroup: FormGroup, video: VideoEdit, thumbnailFiles: boolean) {
5 formGroup.patchValue(video.toFormPatch())
6
7 if (thumbnailFiles === false) return
8
9 const objects = [
10 {
11 url: 'thumbnailUrl',
12 name: 'thumbnailfile'
13 },
14 {
15 url: 'previewUrl',
16 name: 'previewfile'
17 }
18 ]
19
20 for (const obj of objects) {
21 if (!video[obj.url]) continue
22
23 fetch(video[obj.url])
24 .then(response => response.blob())
25 .then(data => {
26 formGroup.patchValue({
27 [ obj.name ]: data
28 })
29 })
30 }
31}
32
33export {
34 hydrateFormFromVideo
35}