aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts16
-rw-r--r--client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts34
-rw-r--r--client/src/app/+videos/+video-edit/video-update.component.html2
-rw-r--r--client/src/app/+videos/+video-edit/video-update.component.ts22
-rw-r--r--client/src/app/shared/shared-main/video/video-edit.model.ts68
5 files changed, 59 insertions, 83 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
index c369ba2b7..da4996902 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-torrent.component.ts
@@ -1,3 +1,4 @@
1import { switchMap } from 'rxjs'
1import { AfterViewInit, Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core' 2import { AfterViewInit, Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
2import { Router } from '@angular/router' 3import { Router } from '@angular/router'
3import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' 4import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
@@ -87,21 +88,16 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af
87 this.loadingBar.useRef().start() 88 this.loadingBar.useRef().start()
88 89
89 this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate) 90 this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate)
91 .pipe(switchMap(({ video }) => this.videoService.getVideo({ videoId: video.uuid })))
90 .subscribe({ 92 .subscribe({
91 next: res => { 93 next: video => {
92 this.loadingBar.useRef().complete() 94 this.loadingBar.useRef().complete()
93 this.firstStepDone.emit(res.video.name) 95 this.firstStepDone.emit(video.name)
94 this.isImportingVideo = false 96 this.isImportingVideo = false
95 this.hasImportedVideo = true 97 this.hasImportedVideo = true
96 98
97 this.video = new VideoEdit(Object.assign(res.video, { 99 this.video = new VideoEdit(video)
98 commentsEnabled: videoUpdate.commentsEnabled, 100 this.video.patch({ privacy: this.firstStepPrivacyId })
99 downloadEnabled: videoUpdate.downloadEnabled,
100 privacy: { id: this.firstStepPrivacyId },
101 support: null,
102 thumbnailUrl: null,
103 previewUrl: null
104 }))
105 101
106 hydrateFormFromVideo(this.form, this.video, false) 102 hydrateFormFromVideo(this.form, this.video, false)
107 }, 103 },
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
index 4c74eda84..971a2a070 100644
--- a/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
+++ b/client/src/app/+videos/+video-edit/video-add-components/video-import-url.component.ts
@@ -1,8 +1,9 @@
1import { forkJoin } from 'rxjs'
1import { map, switchMap } from 'rxjs/operators' 2import { map, switchMap } from 'rxjs/operators'
2import { AfterViewInit, Component, EventEmitter, OnInit, Output } from '@angular/core' 3import { AfterViewInit, Component, EventEmitter, OnInit, Output } from '@angular/core'
3import { Router } from '@angular/router' 4import { Router } from '@angular/router'
4import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core' 5import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'
5import { getAbsoluteAPIUrl, scrollToTop } from '@app/helpers' 6import { scrollToTop } from '@app/helpers'
6import { FormValidatorService } from '@app/shared/shared-forms' 7import { FormValidatorService } from '@app/shared/shared-forms'
7import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' 8import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main'
8import { LoadingBarService } from '@ngx-loading-bar/core' 9import { LoadingBarService } from '@ngx-loading-bar/core'
@@ -76,12 +77,11 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
76 this.videoImportService 77 this.videoImportService
77 .importVideoUrl(this.targetUrl, videoUpdate) 78 .importVideoUrl(this.targetUrl, videoUpdate)
78 .pipe( 79 .pipe(
79 switchMap(res => { 80 switchMap(previous => {
80 return this.videoCaptionService 81 return forkJoin([
81 .listCaptions(res.video.uuid) 82 this.videoCaptionService.listCaptions(previous.video.uuid),
82 .pipe( 83 this.videoService.getVideo({ videoId: previous.video.uuid })
83 map(result => ({ video: res.video, videoCaptions: result.data })) 84 ]).pipe(map(([ videoCaptionsResult, video ]) => ({ videoCaptions: videoCaptionsResult.data, video })))
84 )
85 }) 85 })
86 ) 86 )
87 .subscribe({ 87 .subscribe({
@@ -91,24 +91,8 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV
91 this.isImportingVideo = false 91 this.isImportingVideo = false
92 this.hasImportedVideo = true 92 this.hasImportedVideo = true
93 93
94 const absoluteAPIUrl = getAbsoluteAPIUrl() 94 this.video = new VideoEdit(video)
95 95 this.video.patch({ privacy: this.firstStepPrivacyId })
96 const thumbnailUrl = video.thumbnailPath
97 ? absoluteAPIUrl + video.thumbnailPath
98 : null
99
100 const previewUrl = video.previewPath
101 ? absoluteAPIUrl + video.previewPath
102 : null
103
104 this.video = new VideoEdit(Object.assign(video, {
105 commentsEnabled: videoUpdate.commentsEnabled,
106 downloadEnabled: videoUpdate.downloadEnabled,
107 privacy: { id: this.firstStepPrivacyId },
108 support: null,
109 thumbnailUrl,
110 previewUrl
111 }))
112 96
113 this.videoCaptions = videoCaptions 97 this.videoCaptions = videoCaptions
114 98
diff --git a/client/src/app/+videos/+video-edit/video-update.component.html b/client/src/app/+videos/+video-edit/video-update.component.html
index ffd125695..a33ac3db4 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.html
+++ b/client/src/app/+videos/+video-edit/video-update.component.html
@@ -1,7 +1,7 @@
1<div class="margin-content"> 1<div class="margin-content">
2 <div class="title-page"> 2 <div class="title-page">
3 <span class="me-1" i18n>Update</span> 3 <span class="me-1" i18n>Update</span>
4 <a [routerLink]="getVideoUrl()">{{ video?.name }}</a> 4 <a [routerLink]="getVideoUrl()">{{ videoDetails?.name }}</a>
5 </div> 5 </div>
6 6
7 <form novalidate [formGroup]="form"> 7 <form novalidate [formGroup]="form">
diff --git a/client/src/app/+videos/+video-edit/video-update.component.ts b/client/src/app/+videos/+video-edit/video-update.component.ts
index 43e8ba3e5..13e786a8e 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.ts
+++ b/client/src/app/+videos/+video-edit/video-update.component.ts
@@ -18,7 +18,7 @@ import { VideoSource } from '@shared/models/videos/video-source'
18 templateUrl: './video-update.component.html' 18 templateUrl: './video-update.component.html'
19}) 19})
20export class VideoUpdateComponent extends FormReactive implements OnInit { 20export class VideoUpdateComponent extends FormReactive implements OnInit {
21 video: VideoEdit 21 videoEdit: VideoEdit
22 videoDetails: VideoDetails 22 videoDetails: VideoDetails
23 videoSource: VideoSource 23 videoSource: VideoSource
24 userVideoChannels: SelectChannelItem[] = [] 24 userVideoChannels: SelectChannelItem[] = []
@@ -50,19 +50,19 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
50 const { videoData } = this.route.snapshot.data 50 const { videoData } = this.route.snapshot.data
51 const { video, videoChannels, videoCaptions, videoSource, liveVideo } = videoData 51 const { video, videoChannels, videoCaptions, videoSource, liveVideo } = videoData
52 52
53 this.video = new VideoEdit(video)
54 this.videoDetails = video 53 this.videoDetails = video
54 this.videoEdit = new VideoEdit(this.videoDetails)
55 55
56 this.userVideoChannels = videoChannels 56 this.userVideoChannels = videoChannels
57 this.videoCaptions = videoCaptions 57 this.videoCaptions = videoCaptions
58 this.videoSource = videoSource 58 this.videoSource = videoSource
59 this.liveVideo = liveVideo 59 this.liveVideo = liveVideo
60 60
61 this.forbidScheduledPublication = this.video.privacy !== VideoPrivacy.PRIVATE 61 this.forbidScheduledPublication = this.videoEdit.privacy !== VideoPrivacy.PRIVATE
62 } 62 }
63 63
64 onFormBuilt () { 64 onFormBuilt () {
65 hydrateFormFromVideo(this.form, this.video, true) 65 hydrateFormFromVideo(this.form, this.videoEdit, true)
66 66
67 if (this.liveVideo) { 67 if (this.liveVideo) {
68 this.form.patchValue({ 68 this.form.patchValue({
@@ -115,16 +115,16 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
115 return 115 return
116 } 116 }
117 117
118 this.video.patch(this.form.value) 118 this.videoEdit.patch(this.form.value)
119 119
120 this.loadingBar.useRef().start() 120 this.loadingBar.useRef().start()
121 this.isUpdatingVideo = true 121 this.isUpdatingVideo = true
122 122
123 // Update the video 123 // Update the video
124 this.videoService.updateVideo(this.video) 124 this.videoService.updateVideo(this.videoEdit)
125 .pipe( 125 .pipe(
126 // Then update captions 126 // Then update captions
127 switchMap(() => this.videoCaptionService.updateCaptions(this.video.id, this.videoCaptions)), 127 switchMap(() => this.videoCaptionService.updateCaptions(this.videoEdit.id, this.videoCaptions)),
128 128
129 switchMap(() => { 129 switchMap(() => {
130 if (!this.liveVideo) return of(undefined) 130 if (!this.liveVideo) return of(undefined)
@@ -140,7 +140,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
140 .some(key => this.liveVideo[key] !== liveVideoUpdate[key]) 140 .some(key => this.liveVideo[key] !== liveVideoUpdate[key])
141 if (!liveChanged) return of(undefined) 141 if (!liveChanged) return of(undefined)
142 142
143 return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate) 143 return this.liveVideoService.updateLive(this.videoEdit.id, liveVideoUpdate)
144 }) 144 })
145 ) 145 )
146 .subscribe({ 146 .subscribe({
@@ -149,7 +149,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
149 this.isUpdatingVideo = false 149 this.isUpdatingVideo = false
150 this.loadingBar.useRef().complete() 150 this.loadingBar.useRef().complete()
151 this.notifier.success($localize`Video updated.`) 151 this.notifier.success($localize`Video updated.`)
152 this.router.navigateByUrl(Video.buildWatchUrl(this.video)) 152 this.router.navigateByUrl(Video.buildWatchUrl(this.videoEdit))
153 }, 153 },
154 154
155 error: err => { 155 error: err => {
@@ -162,10 +162,10 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
162 } 162 }
163 163
164 hydratePluginFieldsFromVideo () { 164 hydratePluginFieldsFromVideo () {
165 if (!this.video.pluginData) return 165 if (!this.videoEdit.pluginData) return
166 166
167 this.form.patchValue({ 167 this.form.patchValue({
168 pluginData: this.video.pluginData 168 pluginData: this.videoEdit.pluginData
169 }) 169 })
170 } 170 }
171 171
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 3922ee42a..4cff01653 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
@@ -1,4 +1,6 @@
1import { Video, VideoPrivacy, VideoScheduleUpdate, VideoUpdate } from '@shared/models' 1import { getAbsoluteAPIUrl } from '@app/helpers'
2import { VideoPrivacy, VideoScheduleUpdate, VideoUpdate } from '@shared/models'
3import { VideoDetails } from './video-details.model'
2 4
3export class VideoEdit implements VideoUpdate { 5export class VideoEdit implements VideoUpdate {
4 static readonly SPECIAL_SCHEDULED_PRIVACY = -1 6 static readonly SPECIAL_SCHEDULED_PRIVACY = -1
@@ -29,40 +31,34 @@ export class VideoEdit implements VideoUpdate {
29 31
30 pluginData?: any 32 pluginData?: any
31 33
32 constructor ( 34 constructor (video?: VideoDetails) {
33 video?: Video & { 35 if (!video) return
34 tags: string[] 36
35 commentsEnabled: boolean 37 this.id = video.id
36 downloadEnabled: boolean 38 this.uuid = video.uuid
37 support: string 39 this.shortUUID = video.shortUUID
38 thumbnailUrl: string 40 this.category = video.category.id
39 previewUrl: string 41 this.licence = video.licence.id
40 }) { 42 this.language = video.language.id
41 if (video) { 43 this.description = video.description
42 this.id = video.id 44 this.name = video.name
43 this.uuid = video.uuid 45 this.tags = video.tags
44 this.shortUUID = video.shortUUID 46 this.nsfw = video.nsfw
45 this.category = video.category.id 47 this.waitTranscoding = video.waitTranscoding
46 this.licence = video.licence.id 48 this.channelId = video.channel.id
47 this.language = video.language.id 49 this.privacy = video.privacy.id
48 this.description = video.description 50 this.commentsEnabled = video.commentsEnabled
49 this.name = video.name 51 this.downloadEnabled = video.downloadEnabled
50 this.tags = video.tags 52
51 this.nsfw = video.nsfw 53 if (video.thumbnailPath) this.thumbnailUrl = getAbsoluteAPIUrl() + video.thumbnailPath
52 this.commentsEnabled = video.commentsEnabled 54 if (video.previewPath) this.previewUrl = getAbsoluteAPIUrl() + video.previewPath
53 this.downloadEnabled = video.downloadEnabled 55
54 this.waitTranscoding = video.waitTranscoding 56 this.scheduleUpdate = video.scheduledUpdate
55 this.channelId = video.channel.id 57 this.originallyPublishedAt = video.originallyPublishedAt
56 this.privacy = video.privacy.id 58 ? new Date(video.originallyPublishedAt)
57 this.support = video.support 59 : null
58 this.thumbnailUrl = video.thumbnailUrl 60
59 this.previewUrl = video.previewUrl 61 this.pluginData = video.pluginData
60
61 this.scheduleUpdate = video.scheduledUpdate
62 this.originallyPublishedAt = video.originallyPublishedAt ? new Date(video.originallyPublishedAt) : null
63
64 this.pluginData = video.pluginData
65 }
66 } 62 }
67 63
68 patch (values: { [ id: string ]: any }) { 64 patch (values: { [ id: string ]: any }) {
@@ -86,7 +82,7 @@ export class VideoEdit implements VideoUpdate {
86 82
87 // Convert originallyPublishedAt to string so that function objectToFormData() works correctly 83 // Convert originallyPublishedAt to string so that function objectToFormData() works correctly
88 if (this.originallyPublishedAt) { 84 if (this.originallyPublishedAt) {
89 const originallyPublishedAt = new Date(values['originallyPublishedAt']) 85 const originallyPublishedAt = new Date(this.originallyPublishedAt)
90 this.originallyPublishedAt = originallyPublishedAt.toISOString() 86 this.originallyPublishedAt = originallyPublishedAt.toISOString()
91 } 87 }
92 88