diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-06 15:30:24 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-08 09:30:31 +0200 |
commit | 788487140c500abeb69ca44daf3a9e26efa8d36f (patch) | |
tree | 1870338bcd00848f9ab24067b8b9e545870723d0 /client/src/app/videos/+video-edit/shared | |
parent | 047559af6e7570ac98b0d11ab43e60a9c5c1f5c3 (diff) | |
download | PeerTube-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/shared')
-rw-r--r-- | client/src/app/videos/+video-edit/shared/video-send.ts | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/client/src/app/videos/+video-edit/shared/video-send.ts b/client/src/app/videos/+video-edit/shared/video-send.ts deleted file mode 100644 index bc1c7a45b..000000000 --- a/client/src/app/videos/+video-edit/shared/video-send.ts +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | import { FormReactive } from '@app/shared' | ||
2 | import { OnInit } from '@angular/core' | ||
3 | import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' | ||
4 | import { populateAsyncUserVideoChannels } from '@app/shared/misc/utils' | ||
5 | import { VideoConstant, VideoPrivacy } from '../../../../../../shared/models/videos' | ||
6 | import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model' | ||
7 | import { LoadingBarService } from '@ngx-loading-bar/core' | ||
8 | import { NotificationsService } from 'angular2-notifications' | ||
9 | import { AuthService, ServerService } from '@app/core' | ||
10 | import { VideoService } from '@app/shared/video/video.service' | ||
11 | import { VideoCaptionService } from '@app/shared/video-caption' | ||
12 | import { catchError, switchMap, tap } from 'rxjs/operators' | ||
13 | import { VideoEdit } from '@app/shared/video/video-edit.model' | ||
14 | |||
15 | export 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 | protected abstract readonly DEFAULT_VIDEO_PRIVACY: VideoPrivacy | ||
25 | |||
26 | protected loadingBar: LoadingBarService | ||
27 | protected notificationsService: NotificationsService | ||
28 | protected authService: AuthService | ||
29 | protected serverService: ServerService | ||
30 | protected videoService: VideoService | ||
31 | protected videoCaptionService: VideoCaptionService | ||
32 | |||
33 | abstract canDeactivate () | ||
34 | |||
35 | ngOnInit () { | ||
36 | this.buildForm({}) | ||
37 | |||
38 | populateAsyncUserVideoChannels(this.authService, this.userVideoChannels) | ||
39 | .then(() => this.firstStepChannelId = this.userVideoChannels[ 0 ].id) | ||
40 | |||
41 | this.serverService.videoPrivaciesLoaded | ||
42 | .subscribe( | ||
43 | () => { | ||
44 | this.videoPrivacies = this.serverService.getVideoPrivacies() | ||
45 | |||
46 | this.firstStepPrivacyId = this.DEFAULT_VIDEO_PRIVACY | ||
47 | }) | ||
48 | } | ||
49 | |||
50 | checkForm () { | ||
51 | this.forceCheck() | ||
52 | |||
53 | return this.form.valid | ||
54 | } | ||
55 | |||
56 | protected updateVideoAndCaptions (video: VideoEdit) { | ||
57 | this.loadingBar.start() | ||
58 | |||
59 | return this.videoService.updateVideo(video) | ||
60 | .pipe( | ||
61 | // Then update captions | ||
62 | switchMap(() => this.videoCaptionService.updateCaptions(video.id, this.videoCaptions)), | ||
63 | tap(() => this.loadingBar.complete()), | ||
64 | catchError(err => { | ||
65 | this.loadingBar.complete() | ||
66 | throw err | ||
67 | }) | ||
68 | ) | ||
69 | } | ||
70 | } | ||