1
0
Fork 0
peertube/client/src/app/videos/+video-edit/video-add.component.ts

46 lines
1.8 KiB
TypeScript
Raw Normal View History

import { Component, ViewChild } from '@angular/core'
import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service'
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'
2018-08-06 15:13:39 +00:00
import { VideoImportTorrentComponent } from '@app/videos/+video-edit/video-add-components/video-import-torrent.component'
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',
styleUrls: [ './video-add.component.scss' ]
2016-03-14 12:50:19 +00:00
})
export class VideoAddComponent implements CanComponentDeactivate {
@ViewChild('videoUpload') videoUpload: VideoUploadComponent
2018-08-06 13:18:35 +00:00
@ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent
2018-08-06 15:13:39 +00:00
@ViewChild('videoImportTorrent') videoImportTorrent: VideoImportTorrentComponent
2018-08-06 15:13:39 +00:00
secondStepType: 'upload' | 'import-url' | 'import-torrent'
videoName: string
2018-08-03 09:10:31 +00:00
constructor (
private serverService: ServerService
) {}
2018-08-06 15:13:39 +00:00
onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) {
this.secondStepType = type
this.videoName = videoName
}
canDeactivate () {
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-08-06 15:13:39 +00:00
if (this.secondStepType === 'import-torrent') return this.videoImportTorrent.canDeactivate()
2018-07-12 17:02:00 +00:00
return { canDeactivate: true }
2017-12-07 15:32:06 +00:00
}
2018-08-03 09:10:31 +00:00
2018-08-06 15:13:39 +00:00
isVideoImportHttpEnabled () {
return this.serverService.getConfig().import.videos.http.enabled
}
isVideoImportTorrentEnabled () {
2018-08-07 08:07:53 +00:00
return this.serverService.getConfig().import.videos.torrent.enabled
2018-08-03 09:10:31 +00:00
}
2016-03-14 12:50:19 +00:00
}