aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/video-add.component.ts
blob: d38a53db90a89150ddabdfb967b93ffae960b1c1 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                    
                                                                                        

                                                                                     
                                         
 

                            
                                            
                                             
  


                                                                  
 

                                     
 



                                        


                                                                  

   
                    

                                                                                 
 
                                  
   



                                                                   
 
import { Component, ViewChild } from '@angular/core'
import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service'
import { VideoImportComponent } from '@app/videos/+video-edit/video-import.component'
import { VideoUploadComponent } from '@app/videos/+video-edit/video-upload.component'
import { ServerService } from '@app/core'

@Component({
  selector: 'my-videos-add',
  templateUrl: './video-add.component.html',
  styleUrls: [ './video-add.component.scss' ]
})
export class VideoAddComponent implements CanComponentDeactivate {
  @ViewChild('videoUpload') videoUpload: VideoUploadComponent
  @ViewChild('videoImport') videoImport: VideoImportComponent

  secondStepType: 'upload' | 'import'
  videoName: string

  constructor (
    private serverService: ServerService
  ) {}

  onFirstStepDone (type: 'upload' | 'import', videoName: string) {
    this.secondStepType = type
    this.videoName = videoName
  }

  canDeactivate () {
    if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate()
    if (this.secondStepType === 'import') return this.videoImport.canDeactivate()

    return { canDeactivate: true }
  }

  isVideoImportEnabled () {
    return this.serverService.getConfig().import.video.http.enabled
  }
}