Move send video components inside a dedicated directory
[oweals/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
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('videoImportUrl') videoImportUrl: VideoImportUrlComponent
15
16   secondStepType: 'upload' | 'import-url'
17   videoName: string
18
19   constructor (
20     private serverService: ServerService
21   ) {}
22
23   onFirstStepDone (type: 'upload' | 'import-url', 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-url') return this.videoImportUrl.canDeactivate()
31
32     return { canDeactivate: true }
33   }
34
35   isVideoImportEnabled () {
36     return this.serverService.getConfig().import.videos.http.enabled
37   }
38 }