]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/videos/+video-edit/video-add.component.ts
Refractor video upload/import
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-edit / video-add.component.ts
... / ...
CommitLineData
1import { Component, ViewChild } from '@angular/core'
2import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service'
3import { VideoImportComponent } from '@app/videos/+video-edit/video-import.component'
4import { VideoUploadComponent } from '@app/videos/+video-edit/video-upload.component'
5import { 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})
12export 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}