From 990b6a0b0c4fbebc165e5cf7cec8fbc1cbaa6c66 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 7 Aug 2018 09:54:36 +0200 Subject: Import torrents with webtorrent --- .../my-account-video-imports.component.html | 7 +++++-- .../video-import-torrent.component.html | 12 ++++++++++-- .../video-import-torrent.component.scss | 20 ++++++++++++++++++++ .../video-import-torrent.component.ts | 16 ++++++++++++---- .../video-import-url.component.ts | 2 +- .../app/videos/+video-edit/video-add.component.scss | 2 +- 6 files changed, 49 insertions(+), 10 deletions(-) (limited to 'client') diff --git a/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html index 00b2d7cb0..b2b6c3d60 100644 --- a/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html +++ b/client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.html @@ -5,7 +5,7 @@ - URL + Target Video State Created @@ -22,7 +22,10 @@ - {{ videoImport.targetUrl }} + {{ videoImport.targetUrl }} + + {{ videoImport.torrentName || videoImport.magnetUri }} + diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.html b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.html index 409e4de5e..2f0c9abb5 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.html +++ b/client/src/app/videos/+video-edit/video-add-components/video-import-torrent.component.html @@ -2,8 +2,16 @@
-
- +
+ Select the torrent to import + +
+ (.torrent) + +
Or
+ +
+ () + @ViewChild('torrentfileInput') torrentfileInput videoFileName: string magnetUri = '' @@ -33,7 +34,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca video: VideoEdit - protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PRIVATE + protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC constructor ( protected formValidatorService: FormValidatorService, @@ -62,7 +63,14 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca return !!this.magnetUri } - importVideo () { + fileChange () { + const torrentfile = this.torrentfileInput.nativeElement.files[0] as File + if (!torrentfile) return + + this.importVideo(torrentfile) + } + + importVideo (torrentfile?: Blob) { this.isImportingVideo = true const videoUpdate: VideoUpdate = { @@ -74,7 +82,7 @@ export class VideoImportTorrentComponent extends VideoSend implements OnInit, Ca this.loadingBar.start() - this.videoImportService.importVideoTorrent(this.magnetUri, videoUpdate).subscribe( + this.videoImportService.importVideoTorrent(torrentfile || this.magnetUri, videoUpdate).subscribe( res => { this.loadingBar.complete() this.firstStepDone.emit(res.video.name) diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts index 842ede732..97b402bfe 100644 --- a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts +++ b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts @@ -33,7 +33,7 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom video: VideoEdit - protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PRIVATE + protected readonly DEFAULT_VIDEO_PRIVACY = VideoPrivacy.PUBLIC constructor ( protected formValidatorService: FormValidatorService, diff --git a/client/src/app/videos/+video-edit/video-add.component.scss b/client/src/app/videos/+video-edit/video-add.component.scss index 02ee295f9..443361f50 100644 --- a/client/src/app/videos/+video-edit/video-add.component.scss +++ b/client/src/app/videos/+video-edit/video-add.component.scss @@ -49,7 +49,7 @@ $background-color: #F7F7F7; background-color: $background-color; border-radius: 3px; width: 100%; - height: 440px; + min-height: 440px; display: flex; justify-content: center; align-items: center; -- cgit v1.2.3