]>
Commit | Line | Data |
---|---|---|
fbad87b0 | 1 | import { Component, ViewChild } from '@angular/core' |
f6a043df | 2 | import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' |
78848714 C |
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' | |
5d08a6a7 | 5 | import { ServerService } from '@app/core' |
ce33919c | 6 | import { VideoImportTorrentComponent } from '@app/videos/+video-edit/video-add-components/video-import-torrent.component' |
1553e15d | 7 | |
dc8bc31b C |
8 | @Component({ |
9 | selector: 'my-videos-add', | |
27e1a06c | 10 | templateUrl: './video-add.component.html', |
fbad87b0 | 11 | styleUrls: [ './video-add.component.scss' ] |
dc8bc31b | 12 | }) |
fbad87b0 C |
13 | export class VideoAddComponent implements CanComponentDeactivate { |
14 | @ViewChild('videoUpload') videoUpload: VideoUploadComponent | |
047559af | 15 | @ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent |
ce33919c | 16 | @ViewChild('videoImportTorrent') videoImportTorrent: VideoImportTorrentComponent |
bfb3a98f | 17 | |
ce33919c | 18 | secondStepType: 'upload' | 'import-url' | 'import-torrent' |
fbad87b0 | 19 | videoName: string |
bbe0f064 | 20 | |
5d08a6a7 C |
21 | constructor ( |
22 | private serverService: ServerService | |
23 | ) {} | |
24 | ||
ce33919c | 25 | onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) { |
fbad87b0 C |
26 | this.secondStepType = type |
27 | this.videoName = videoName | |
f6a043df C |
28 | } |
29 | ||
529479f9 | 30 | canDeactivate () { |
fbad87b0 | 31 | if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate() |
047559af | 32 | if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate() |
ce33919c | 33 | if (this.secondStepType === 'import-torrent') return this.videoImportTorrent.canDeactivate() |
40e87e9e | 34 | |
fbad87b0 | 35 | return { canDeactivate: true } |
27e1a06c | 36 | } |
5d08a6a7 | 37 | |
ce33919c C |
38 | isVideoImportHttpEnabled () { |
39 | return this.serverService.getConfig().import.videos.http.enabled | |
40 | } | |
41 | ||
42 | isVideoImportTorrentEnabled () { | |
a84b8fa5 | 43 | return this.serverService.getConfig().import.videos.torrent.enabled |
5d08a6a7 | 44 | } |
dc8bc31b | 45 | } |