2018-08-02 13:34:09 +00:00
|
|
|
import { Component, ViewChild } from '@angular/core'
|
2018-01-25 18:01:13 +00:00
|
|
|
import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service'
|
2018-08-06 13:30:24 +00:00
|
|
|
import { VideoImportUrlComponent } from '@app/videos/+video-edit/video-add-components/video-import-url.component'
|
|
|
|
import { VideoUploadComponent } from '@app/videos/+video-edit/video-add-components/video-upload.component'
|
2018-08-03 09:10:31 +00:00
|
|
|
import { ServerService } from '@app/core'
|
2016-04-14 20:07:46 +00:00
|
|
|
|
2016-03-14 12:50:19 +00:00
|
|
|
@Component({
|
|
|
|
selector: 'my-videos-add',
|
2017-12-07 15:32:06 +00:00
|
|
|
templateUrl: './video-add.component.html',
|
2018-08-02 13:34:09 +00:00
|
|
|
styleUrls: [ './video-add.component.scss' ]
|
2016-03-14 12:50:19 +00:00
|
|
|
})
|
2018-08-02 13:34:09 +00:00
|
|
|
export class VideoAddComponent implements CanComponentDeactivate {
|
|
|
|
@ViewChild('videoUpload') videoUpload: VideoUploadComponent
|
2018-08-06 13:18:35 +00:00
|
|
|
@ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent
|
2017-09-14 15:06:31 +00:00
|
|
|
|
2018-08-06 13:18:35 +00:00
|
|
|
secondStepType: 'upload' | 'import-url'
|
2018-08-02 13:34:09 +00:00
|
|
|
videoName: string
|
2018-06-15 14:52:15 +00:00
|
|
|
|
2018-08-03 09:10:31 +00:00
|
|
|
constructor (
|
|
|
|
private serverService: ServerService
|
|
|
|
) {}
|
|
|
|
|
2018-08-06 13:18:35 +00:00
|
|
|
onFirstStepDone (type: 'upload' | 'import-url', videoName: string) {
|
2018-08-02 13:34:09 +00:00
|
|
|
this.secondStepType = type
|
|
|
|
this.videoName = videoName
|
2018-01-25 18:01:13 +00:00
|
|
|
}
|
|
|
|
|
2018-01-25 17:40:23 +00:00
|
|
|
canDeactivate () {
|
2018-08-02 13:34:09 +00:00
|
|
|
if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate()
|
2018-08-06 13:18:35 +00:00
|
|
|
if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate()
|
2018-07-12 17:02:00 +00:00
|
|
|
|
2018-08-02 13:34:09 +00:00
|
|
|
return { canDeactivate: true }
|
2017-12-07 15:32:06 +00:00
|
|
|
}
|
2018-08-03 09:10:31 +00:00
|
|
|
|
|
|
|
isVideoImportEnabled () {
|
2018-08-03 15:00:19 +00:00
|
|
|
return this.serverService.getConfig().import.videos.http.enabled
|
2018-08-03 09:10:31 +00:00
|
|
|
}
|
2016-03-14 12:50:19 +00:00
|
|
|
}
|