]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/+video-edit/video-add.component.ts
Merge branch 'develop' of https://github.com/Chocobozzz/PeerTube into move-utils...
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-edit / video-add.component.ts
1 import { Component, ViewChild } from '@angular/core'
2 import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service'
3 import { VideoImportUrlComponent } from '@app/videos/+video-edit/video-add-components/video-import-url.component'
4 import { VideoUploadComponent } from '@app/videos/+video-edit/video-add-components/video-upload.component'
5 import { ServerService } from '@app/core'
6 import { VideoImportTorrentComponent } from '@app/videos/+video-edit/video-add-components/video-import-torrent.component'
7
8 @Component({
9 selector: 'my-videos-add',
10 templateUrl: './video-add.component.html',
11 styleUrls: [ './video-add.component.scss' ]
12 })
13 export class VideoAddComponent implements CanComponentDeactivate {
14 @ViewChild('videoUpload') videoUpload: VideoUploadComponent
15 @ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent
16 @ViewChild('videoImportTorrent') videoImportTorrent: VideoImportTorrentComponent
17
18 secondStepType: 'upload' | 'import-url' | 'import-torrent'
19 videoName: string
20
21 constructor (
22 private serverService: ServerService
23 ) {}
24
25 onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) {
26 this.secondStepType = type
27 this.videoName = videoName
28 }
29
30 onError () {
31 this.videoName = undefined
32 this.secondStepType = undefined
33 }
34
35 canDeactivate () {
36 if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate()
37 if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate()
38 if (this.secondStepType === 'import-torrent') return this.videoImportTorrent.canDeactivate()
39
40 return { canDeactivate: true }
41 }
42
43 isVideoImportHttpEnabled () {
44 return this.serverService.getConfig().import.videos.http.enabled
45 }
46
47 isVideoImportTorrentEnabled () {
48 return this.serverService.getConfig().import.videos.torrent.enabled
49 }
50 }