aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/video-add-components/video-send.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-06 15:30:24 +0200
committerChocobozzz <me@florianbigard.com>2018-08-08 09:30:31 +0200
commit788487140c500abeb69ca44daf3a9e26efa8d36f (patch)
tree1870338bcd00848f9ab24067b8b9e545870723d0 /client/src/app/videos/+video-edit/video-add-components/video-send.ts
parent047559af6e7570ac98b0d11ab43e60a9c5c1f5c3 (diff)
downloadPeerTube-788487140c500abeb69ca44daf3a9e26efa8d36f.tar.gz
PeerTube-788487140c500abeb69ca44daf3a9e26efa8d36f.tar.zst
PeerTube-788487140c500abeb69ca44daf3a9e26efa8d36f.zip
Move send video components inside a dedicated directory
Diffstat (limited to 'client/src/app/videos/+video-edit/video-add-components/video-send.ts')
-rw-r--r--client/src/app/videos/+video-edit/video-add-components/video-send.ts71
1 files changed, 71 insertions, 0 deletions
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-send.ts b/client/src/app/videos/+video-edit/video-add-components/video-send.ts
new file mode 100644
index 000000000..efd182269
--- /dev/null
+++ b/client/src/app/videos/+video-edit/video-add-components/video-send.ts
@@ -0,0 +1,71 @@
1import { EventEmitter, OnInit } from '@angular/core'
2import { LoadingBarService } from '@ngx-loading-bar/core'
3import { NotificationsService } from 'angular2-notifications'
4import { catchError, switchMap, tap } from 'rxjs/operators'
5import { FormReactive } from '@app/shared'
6import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service'
7import { VideoConstant, VideoPrivacy } from '../../../../../../shared'
8import { AuthService, ServerService } from '@app/core'
9import { VideoService } from '@app/shared/video/video.service'
10import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model'
11import { VideoCaptionService } from '@app/shared/video-caption'
12import { VideoEdit } from '@app/shared/video/video-edit.model'
13import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils'
14
15export abstract class VideoSend extends FormReactive implements OnInit, CanComponentDeactivate {
16
17 userVideoChannels: { id: number, label: string, support: string }[] = []
18 videoPrivacies: VideoConstant<string>[] = []
19 videoCaptions: VideoCaptionEdit[] = []
20
21 firstStepPrivacyId = 0
22 firstStepChannelId = 0
23
24 abstract firstStepDone: EventEmitter<string>
25 protected abstract readonly DEFAULT_VIDEO_PRIVACY: VideoPrivacy
26
27 protected loadingBar: LoadingBarService
28 protected notificationsService: NotificationsService
29 protected authService: AuthService
30 protected serverService: ServerService
31 protected videoService: VideoService
32 protected videoCaptionService: VideoCaptionService
33
34 abstract canDeactivate ()
35
36 ngOnInit () {
37 this.buildForm({})
38
39 populateAsyncUserVideoChannels(this.authService, this.userVideoChannels)
40 .then(() => this.firstStepChannelId = this.userVideoChannels[ 0 ].id)
41
42 this.serverService.videoPrivaciesLoaded
43 .subscribe(
44 () => {
45 this.videoPrivacies = this.serverService.getVideoPrivacies()
46
47 this.firstStepPrivacyId = this.DEFAULT_VIDEO_PRIVACY
48 })
49 }
50
51 checkForm () {
52 this.forceCheck()
53
54 return this.form.valid
55 }
56
57 protected updateVideoAndCaptions (video: VideoEdit) {
58 this.loadingBar.start()
59
60 return this.videoService.updateVideo(video)
61 .pipe(
62 // Then update captions
63 switchMap(() => this.videoCaptionService.updateCaptions(video.id, this.videoCaptions)),
64 tap(() => this.loadingBar.complete()),
65 catchError(err => {
66 this.loadingBar.complete()
67 throw err
68 })
69 )
70 }
71}