diff options
Diffstat (limited to 'client/src/app/+videos/+video-edit')
5 files changed, 113 insertions, 110 deletions
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts index db25dc6be..30c79594d 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-go-live.component.ts | |||
@@ -8,7 +8,7 @@ import { FormValidatorService } from '@app/shared/shared-forms' | |||
8 | import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' | 8 | import { Video, VideoCaptionService, VideoEdit, VideoService } from '@app/shared/shared-main' |
9 | import { LiveVideoService } from '@app/shared/shared-video-live' | 9 | import { LiveVideoService } from '@app/shared/shared-video-live' |
10 | import { LoadingBarService } from '@ngx-loading-bar/core' | 10 | import { LoadingBarService } from '@ngx-loading-bar/core' |
11 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, PeerTubeProblemDocument, ServerErrorCode, VideoPrivacy } from '@shared/models' | 11 | import { LiveVideo, LiveVideoCreate, LiveVideoUpdate, PeerTubeProblemDocument, ServerErrorCode } from '@shared/models' |
12 | import { VideoSend } from './video-send' | 12 | import { VideoSend } from './video-send' |
13 | 13 | ||
14 | @Component({ | 14 | @Component({ |
@@ -74,33 +74,34 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView | |||
74 | const toPatch = Object.assign({}, video, { privacy: this.firstStepPrivacyId }) | 74 | const toPatch = Object.assign({}, video, { privacy: this.firstStepPrivacyId }) |
75 | this.form.patchValue(toPatch) | 75 | this.form.patchValue(toPatch) |
76 | 76 | ||
77 | this.liveVideoService.goLive(video).subscribe( | 77 | this.liveVideoService.goLive(video) |
78 | res => { | 78 | .subscribe({ |
79 | this.videoId = res.video.id | 79 | next: res => { |
80 | this.videoUUID = res.video.uuid | 80 | this.videoId = res.video.id |
81 | this.isInUpdateForm = true | 81 | this.videoUUID = res.video.uuid |
82 | this.isInUpdateForm = true | ||
82 | 83 | ||
83 | this.firstStepDone.emit(name) | 84 | this.firstStepDone.emit(name) |
84 | 85 | ||
85 | this.fetchVideoLive() | 86 | this.fetchVideoLive() |
86 | }, | 87 | }, |
88 | |||
89 | error: err => { | ||
90 | this.firstStepError.emit() | ||
87 | 91 | ||
88 | err => { | 92 | let message = err.message |
89 | this.firstStepError.emit() | ||
90 | 93 | ||
91 | let message = err.message | 94 | const error = err.body as PeerTubeProblemDocument |
92 | 95 | ||
93 | const error = err.body as PeerTubeProblemDocument | 96 | if (error?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) { |
97 | message = $localize`Cannot create live because this instance have too many created lives` | ||
98 | } else if (error?.code === ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED) { | ||
99 | message = $localize`Cannot create live because you created too many lives` | ||
100 | } | ||
94 | 101 | ||
95 | if (error?.code === ServerErrorCode.MAX_INSTANCE_LIVES_LIMIT_REACHED) { | 102 | this.notifier.error(message) |
96 | message = $localize`Cannot create live because this instance have too many created lives` | ||
97 | } else if (error?.code === ServerErrorCode.MAX_USER_LIVES_LIMIT_REACHED) { | ||
98 | message = $localize`Cannot create live because you created too many lives` | ||
99 | } | 103 | } |
100 | 104 | }) | |
101 | this.notifier.error(message) | ||
102 | } | ||
103 | ) | ||
104 | } | 105 | } |
105 | 106 | ||
106 | updateSecondStep () { | 107 | updateSecondStep () { |
@@ -123,19 +124,19 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView | |||
123 | this.updateVideoAndCaptions(video), | 124 | this.updateVideoAndCaptions(video), |
124 | 125 | ||
125 | this.liveVideoService.updateLive(this.videoId, liveVideoUpdate) | 126 | this.liveVideoService.updateLive(this.videoId, liveVideoUpdate) |
126 | ]).subscribe( | 127 | ]).subscribe({ |
127 | () => { | 128 | next: () => { |
128 | this.notifier.success($localize`Live published.`) | 129 | this.notifier.success($localize`Live published.`) |
129 | 130 | ||
130 | this.router.navigateByUrl(Video.buildWatchUrl(video)) | 131 | this.router.navigateByUrl(Video.buildWatchUrl(video)) |
131 | }, | 132 | }, |
132 | 133 | ||
133 | err => { | 134 | error: err => { |
134 | this.error = err.message | 135 | this.error = err.message |
135 | scrollToTop() | 136 | scrollToTop() |
136 | console.error(err) | 137 | console.error(err) |
137 | } | 138 | } |
138 | ) | 139 | }) |
139 | } | 140 | } |
140 | 141 | ||
141 | getMaxLiveDuration () { | 142 | getMaxLiveDuration () { |
@@ -148,15 +149,15 @@ export class VideoGoLiveComponent extends VideoSend implements OnInit, AfterView | |||
148 | 149 | ||
149 | private fetchVideoLive () { | 150 | private fetchVideoLive () { |
150 | this.liveVideoService.getVideoLive(this.videoId) | 151 | this.liveVideoService.getVideoLive(this.videoId) |
151 | .subscribe( | 152 | .subscribe({ |
152 | liveVideo => { | 153 | next: liveVideo => { |
153 | this.liveVideo = liveVideo | 154 | this.liveVideo = liveVideo |
154 | }, | 155 | }, |
155 | 156 | ||
156 | err => { | 157 | error: err => { |
157 | this.firstStepError.emit() | 158 | this.firstStepError.emit() |
158 | this.notifier.error(err.message) | 159 | this.notifier.error(err.message) |
159 | } | 160 | } |
160 | ) | 161 | }) |
161 | } | 162 | } |
162 | } | 163 | } |
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 62aaeb019..fef1f5d65 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 | |||
@@ -88,40 +88,41 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af | |||
88 | 88 | ||
89 | this.loadingBar.useRef().start() | 89 | this.loadingBar.useRef().start() |
90 | 90 | ||
91 | this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe( | 91 | this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate) |
92 | res => { | 92 | .subscribe({ |
93 | this.loadingBar.useRef().complete() | 93 | next: res => { |
94 | this.firstStepDone.emit(res.video.name) | 94 | this.loadingBar.useRef().complete() |
95 | this.isImportingVideo = false | 95 | this.firstStepDone.emit(res.video.name) |
96 | this.hasImportedVideo = true | 96 | this.isImportingVideo = false |
97 | 97 | this.hasImportedVideo = true | |
98 | this.video = new VideoEdit(Object.assign(res.video, { | 98 | |
99 | commentsEnabled: videoUpdate.commentsEnabled, | 99 | this.video = new VideoEdit(Object.assign(res.video, { |
100 | downloadEnabled: videoUpdate.downloadEnabled, | 100 | commentsEnabled: videoUpdate.commentsEnabled, |
101 | privacy: { id: this.firstStepPrivacyId }, | 101 | downloadEnabled: videoUpdate.downloadEnabled, |
102 | support: null, | 102 | privacy: { id: this.firstStepPrivacyId }, |
103 | thumbnailUrl: null, | 103 | support: null, |
104 | previewUrl: null | 104 | thumbnailUrl: null, |
105 | })) | 105 | previewUrl: null |
106 | 106 | })) | |
107 | hydrateFormFromVideo(this.form, this.video, false) | 107 | |
108 | }, | 108 | hydrateFormFromVideo(this.form, this.video, false) |
109 | 109 | }, | |
110 | err => { | 110 | |
111 | this.loadingBar.useRef().complete() | 111 | error: err => { |
112 | this.isImportingVideo = false | 112 | this.loadingBar.useRef().complete() |
113 | this.firstStepError.emit() | 113 | this.isImportingVideo = false |
114 | 114 | this.firstStepError.emit() | |
115 | let message = err.message | 115 | |
116 | 116 | let message = err.message | |
117 | const error = err.body as PeerTubeProblemDocument | 117 | |
118 | if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) { | 118 | const error = err.body as PeerTubeProblemDocument |
119 | message = $localize`Torrents with only 1 file are supported.` | 119 | if (error?.code === ServerErrorCode.INCORRECT_FILES_IN_TORRENT) { |
120 | } | 120 | message = $localize`Torrents with only 1 file are supported.` |
121 | } | ||
121 | 122 | ||
122 | this.notifier.error(message) | 123 | this.notifier.error(message) |
123 | } | 124 | } |
124 | ) | 125 | }) |
125 | } | 126 | } |
126 | 127 | ||
127 | updateSecondStep () { | 128 | updateSecondStep () { |
@@ -135,19 +136,19 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Af | |||
135 | 136 | ||
136 | // Update the video | 137 | // Update the video |
137 | this.updateVideoAndCaptions(this.video) | 138 | this.updateVideoAndCaptions(this.video) |
138 | .subscribe( | 139 | .subscribe({ |
139 | () => { | 140 | next: () => { |
140 | this.isUpdatingVideo = false | 141 | this.isUpdatingVideo = false |
141 | this.notifier.success($localize`Video to import updated.`) | 142 | this.notifier.success($localize`Video to import updated.`) |
142 | 143 | ||
143 | this.router.navigate([ '/my-library', 'video-imports' ]) | 144 | this.router.navigate([ '/my-library', 'video-imports' ]) |
144 | }, | 145 | }, |
145 | 146 | ||
146 | err => { | 147 | error: err => { |
147 | this.error = err.message | 148 | this.error = err.message |
148 | scrollToTop() | 149 | scrollToTop() |
149 | console.error(err) | 150 | console.error(err) |
150 | } | 151 | } |
151 | ) | 152 | }) |
152 | } | 153 | } |
153 | } | 154 | } |
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 3243b4d38..e1893b28f 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 | |||
@@ -6,7 +6,7 @@ import { getAbsoluteAPIUrl, scrollToTop } from '@app/helpers' | |||
6 | import { FormValidatorService } from '@app/shared/shared-forms' | 6 | import { FormValidatorService } from '@app/shared/shared-forms' |
7 | import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' | 7 | import { VideoCaptionService, VideoEdit, VideoImportService, VideoService } from '@app/shared/shared-main' |
8 | import { LoadingBarService } from '@ngx-loading-bar/core' | 8 | import { LoadingBarService } from '@ngx-loading-bar/core' |
9 | import { VideoPrivacy, VideoUpdate } from '@shared/models' | 9 | import { VideoUpdate } from '@shared/models' |
10 | import { hydrateFormFromVideo } from '../shared/video-edit-utils' | 10 | import { hydrateFormFromVideo } from '../shared/video-edit-utils' |
11 | import { VideoSend } from './video-send' | 11 | import { VideoSend } from './video-send' |
12 | 12 | ||
@@ -86,8 +86,8 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV | |||
86 | ) | 86 | ) |
87 | }) | 87 | }) |
88 | ) | 88 | ) |
89 | .subscribe( | 89 | .subscribe({ |
90 | ({ video, videoCaptions }) => { | 90 | next: ({ video, videoCaptions }) => { |
91 | this.loadingBar.useRef().complete() | 91 | this.loadingBar.useRef().complete() |
92 | this.firstStepDone.emit(video.name) | 92 | this.firstStepDone.emit(video.name) |
93 | this.isImportingVideo = false | 93 | this.isImportingVideo = false |
@@ -117,13 +117,13 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV | |||
117 | hydrateFormFromVideo(this.form, this.video, true) | 117 | hydrateFormFromVideo(this.form, this.video, true) |
118 | }, | 118 | }, |
119 | 119 | ||
120 | err => { | 120 | error: err => { |
121 | this.loadingBar.useRef().complete() | 121 | this.loadingBar.useRef().complete() |
122 | this.isImportingVideo = false | 122 | this.isImportingVideo = false |
123 | this.firstStepError.emit() | 123 | this.firstStepError.emit() |
124 | this.notifier.error(err.message) | 124 | this.notifier.error(err.message) |
125 | } | 125 | } |
126 | ) | 126 | }) |
127 | } | 127 | } |
128 | 128 | ||
129 | updateSecondStep () { | 129 | updateSecondStep () { |
@@ -137,19 +137,19 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, AfterV | |||
137 | 137 | ||
138 | // Update the video | 138 | // Update the video |
139 | this.updateVideoAndCaptions(this.video) | 139 | this.updateVideoAndCaptions(this.video) |
140 | .subscribe( | 140 | .subscribe({ |
141 | () => { | 141 | next: () => { |
142 | this.isUpdatingVideo = false | 142 | this.isUpdatingVideo = false |
143 | this.notifier.success($localize`Video to import updated.`) | 143 | this.notifier.success($localize`Video to import updated.`) |
144 | 144 | ||
145 | this.router.navigate([ '/my-library', 'video-imports' ]) | 145 | this.router.navigate([ '/my-library', 'video-imports' ]) |
146 | }, | 146 | }, |
147 | 147 | ||
148 | err => { | 148 | error: err => { |
149 | this.error = err.message | 149 | this.error = err.message |
150 | scrollToTop() | 150 | scrollToTop() |
151 | console.error(err) | 151 | console.error(err) |
152 | } | 152 | } |
153 | ) | 153 | }) |
154 | } | 154 | } |
155 | } | 155 | } |
diff --git a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts index 189bc9669..b8cb4fa1e 100644 --- a/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts +++ b/client/src/app/+videos/+video-edit/video-add-components/video-upload.component.ts | |||
@@ -240,8 +240,8 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy | |||
240 | this.isUpdatingVideo = true | 240 | this.isUpdatingVideo = true |
241 | 241 | ||
242 | this.updateVideoAndCaptions(video) | 242 | this.updateVideoAndCaptions(video) |
243 | .subscribe( | 243 | .subscribe({ |
244 | () => { | 244 | next: () => { |
245 | this.isUpdatingVideo = false | 245 | this.isUpdatingVideo = false |
246 | this.isUploadingVideo = false | 246 | this.isUploadingVideo = false |
247 | 247 | ||
@@ -249,12 +249,12 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy | |||
249 | this.router.navigateByUrl(Video.buildWatchUrl(video)) | 249 | this.router.navigateByUrl(Video.buildWatchUrl(video)) |
250 | }, | 250 | }, |
251 | 251 | ||
252 | err => { | 252 | error: err => { |
253 | this.error = err.message | 253 | this.error = err.message |
254 | scrollToTop() | 254 | scrollToTop() |
255 | console.error(err) | 255 | console.error(err) |
256 | } | 256 | } |
257 | ) | 257 | }) |
258 | } | 258 | } |
259 | 259 | ||
260 | private getInputVideoFile () { | 260 | private getInputVideoFile () { |
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 1534eee82..95336dc75 100644 --- a/client/src/app/+videos/+video-edit/video-update.component.ts +++ b/client/src/app/+videos/+video-edit/video-update.component.ts | |||
@@ -47,34 +47,35 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
47 | 47 | ||
48 | this.route.data | 48 | this.route.data |
49 | .pipe(map(data => data.videoData)) | 49 | .pipe(map(data => data.videoData)) |
50 | .subscribe(({ video, videoChannels, videoCaptions, liveVideo }) => { | 50 | .subscribe({ |
51 | this.video = new VideoEdit(video) | 51 | next: ({ video, videoChannels, videoCaptions, liveVideo }) => { |
52 | this.videoDetails = video | 52 | this.video = new VideoEdit(video) |
53 | 53 | this.videoDetails = video | |
54 | this.userVideoChannels = videoChannels | 54 | |
55 | this.videoCaptions = videoCaptions | 55 | this.userVideoChannels = videoChannels |
56 | this.liveVideo = liveVideo | 56 | this.videoCaptions = videoCaptions |
57 | 57 | this.liveVideo = liveVideo | |
58 | this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE | 58 | |
59 | 59 | this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE | |
60 | // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout | 60 | |
61 | setTimeout(() => { | 61 | // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout |
62 | hydrateFormFromVideo(this.form, this.video, true) | 62 | setTimeout(() => { |
63 | 63 | hydrateFormFromVideo(this.form, this.video, true) | |
64 | if (this.liveVideo) { | 64 | |
65 | this.form.patchValue({ | 65 | if (this.liveVideo) { |
66 | saveReplay: this.liveVideo.saveReplay, | 66 | this.form.patchValue({ |
67 | permanentLive: this.liveVideo.permanentLive | 67 | saveReplay: this.liveVideo.saveReplay, |
68 | }) | 68 | permanentLive: this.liveVideo.permanentLive |
69 | } | 69 | }) |
70 | }) | 70 | } |
71 | }, | 71 | }) |
72 | }, | ||
72 | 73 | ||
73 | err => { | 74 | error: err => { |
74 | console.error(err) | 75 | console.error(err) |
75 | this.notifier.error(err.message) | 76 | this.notifier.error(err.message) |
76 | } | 77 | } |
77 | ) | 78 | }) |
78 | } | 79 | } |
79 | 80 | ||
80 | @HostListener('window:beforeunload', [ '$event' ]) | 81 | @HostListener('window:beforeunload', [ '$event' ]) |
@@ -150,8 +151,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
150 | return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate) | 151 | return this.liveVideoService.updateLive(this.video.id, liveVideoUpdate) |
151 | }) | 152 | }) |
152 | ) | 153 | ) |
153 | .subscribe( | 154 | .subscribe({ |
154 | () => { | 155 | next: () => { |
155 | this.updateDone = true | 156 | this.updateDone = true |
156 | this.isUpdatingVideo = false | 157 | this.isUpdatingVideo = false |
157 | this.loadingBar.useRef().complete() | 158 | this.loadingBar.useRef().complete() |
@@ -159,13 +160,13 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
159 | this.router.navigateByUrl(Video.buildWatchUrl(this.video)) | 160 | this.router.navigateByUrl(Video.buildWatchUrl(this.video)) |
160 | }, | 161 | }, |
161 | 162 | ||
162 | err => { | 163 | error: err => { |
163 | this.loadingBar.useRef().complete() | 164 | this.loadingBar.useRef().complete() |
164 | this.isUpdatingVideo = false | 165 | this.isUpdatingVideo = false |
165 | this.notifier.error(err.message) | 166 | this.notifier.error(err.message) |
166 | console.error(err) | 167 | console.error(err) |
167 | } | 168 | } |
168 | ) | 169 | }) |
169 | } | 170 | } |
170 | 171 | ||
171 | hydratePluginFieldsFromVideo () { | 172 | hydratePluginFieldsFromVideo () { |