]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/+video-edit/video-add.component.ts
69b364ddd01943683fbd94487d7c01f12463b8ee
[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 { VideoImportComponent } from '@app/videos/+video-edit/video-import.component'
4 import { VideoUploadComponent } from '@app/videos/+video-edit/video-upload.component'
5 import { ServerService } from '@app/core'
6
7 @Component({
8 selector: 'my-videos-add',
9 templateUrl: './video-add.component.html',
10 styleUrls: [ './video-add.component.scss' ]
11 })
12 export class VideoAddComponent implements CanComponentDeactivate {
13 @ViewChild('videoUpload') videoUpload: VideoUploadComponent
14 @ViewChild('videoImport') videoImport: VideoImportComponent
15
16 secondStepType: 'upload' | 'import'
17 videoName: string
18
19 constructor (
20 private serverService: ServerService
21 ) {}
22
23 onFirstStepDone (type: 'upload' | 'import', videoName: string) {
24 this.secondStepType = type
25 this.videoName = videoName
26 }
27
28 canDeactivate () {
29 if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate()
30 if (this.secondStepType === 'import') return this.videoImport.canDeactivate()
31
32 return { canDeactivate: true }
33 }
34
35 isVideoImportEnabled () {
36 return this.serverService.getConfig().import.videos.http.enabled
37 }
38 }