aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/video-add.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-23 14:49:20 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-06-23 16:00:49 +0200
commit1942f11d5ee6926ad93dc1b79fae18325ba5de18 (patch)
tree3f2a3cd9466a56c419d197ac832a3e9cbc86bec4 /client/src/app/videos/+video-edit/video-add.component.ts
parent67ed6552b831df66713bac9e672738796128d33f (diff)
downloadPeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.gz
PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.zst
PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.zip
Lazy load all routes
Diffstat (limited to 'client/src/app/videos/+video-edit/video-add.component.ts')
-rw-r--r--client/src/app/videos/+video-edit/video-add.component.ts77
1 files changed, 0 insertions, 77 deletions
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts
deleted file mode 100644
index 5bd768809..000000000
--- a/client/src/app/videos/+video-edit/video-add.component.ts
+++ /dev/null
@@ -1,77 +0,0 @@
1import { Component, HostListener, OnInit, ViewChild } from '@angular/core'
2import { AuthService, CanComponentDeactivate, ServerService } from '@app/core'
3import { ServerConfig } from '@shared/models'
4import { VideoImportTorrentComponent } from './video-add-components/video-import-torrent.component'
5import { VideoImportUrlComponent } from './video-add-components/video-import-url.component'
6import { VideoUploadComponent } from './video-add-components/video-upload.component'
7
8@Component({
9 selector: 'my-videos-add',
10 templateUrl: './video-add.component.html',
11 styleUrls: [ './video-add.component.scss' ]
12})
13export class VideoAddComponent implements OnInit, CanComponentDeactivate {
14 @ViewChild('videoUpload') videoUpload: VideoUploadComponent
15 @ViewChild('videoImportUrl') videoImportUrl: VideoImportUrlComponent
16 @ViewChild('videoImportTorrent') videoImportTorrent: VideoImportTorrentComponent
17
18 secondStepType: 'upload' | 'import-url' | 'import-torrent'
19 videoName: string
20 serverConfig: ServerConfig
21
22 constructor (
23 private auth: AuthService,
24 private serverService: ServerService
25 ) {}
26
27 ngOnInit () {
28 this.serverConfig = this.serverService.getTmpConfig()
29
30 this.serverService.getConfig()
31 .subscribe(config => this.serverConfig = config)
32 }
33
34 onFirstStepDone (type: 'upload' | 'import-url' | 'import-torrent', videoName: string) {
35 this.secondStepType = type
36 this.videoName = videoName
37 }
38
39 onError () {
40 this.videoName = undefined
41 this.secondStepType = undefined
42 }
43
44 @HostListener('window:beforeunload', [ '$event' ])
45 onUnload (event: any) {
46 const { text, canDeactivate } = this.canDeactivate()
47
48 if (canDeactivate) return
49
50 event.returnValue = text
51 return text
52 }
53
54 canDeactivate (): { canDeactivate: boolean, text?: string} {
55 if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate()
56 if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate()
57 if (this.secondStepType === 'import-torrent') return this.videoImportTorrent.canDeactivate()
58
59 return { canDeactivate: true }
60 }
61
62 isVideoImportHttpEnabled () {
63 return this.serverConfig.import.videos.http.enabled
64 }
65
66 isVideoImportTorrentEnabled () {
67 return this.serverConfig.import.videos.torrent.enabled
68 }
69
70 isInSecondStep () {
71 return !!this.secondStepType
72 }
73
74 isRootUser () {
75 return this.auth.getUser().username === 'root'
76 }
77}