diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-20 17:49:58 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-20 17:49:58 +0100 |
commit | 5f0805d39b94eb2de1b73e0f43ac8685ae900994 (patch) | |
tree | cba6c3022caad5e424bd6639bbaaae92113b7b7f /client/src/app/videos/+video-watch/video-download.component.ts | |
parent | cb9244de975909bac2922c4412fd948646ff3ba7 (diff) | |
download | PeerTube-5f0805d39b94eb2de1b73e0f43ac8685ae900994.tar.gz PeerTube-5f0805d39b94eb2de1b73e0f43ac8685ae900994.tar.zst PeerTube-5f0805d39b94eb2de1b73e0f43ac8685ae900994.zip |
Design modals
Diffstat (limited to 'client/src/app/videos/+video-watch/video-download.component.ts')
-rw-r--r-- | client/src/app/videos/+video-watch/video-download.component.ts | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/client/src/app/videos/+video-watch/video-download.component.ts b/client/src/app/videos/+video-watch/video-download.component.ts index 095df1698..44ece986c 100644 --- a/client/src/app/videos/+video-watch/video-download.component.ts +++ b/client/src/app/videos/+video-watch/video-download.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, Input, ViewChild } from '@angular/core' | 1 | import { Component, Input, OnInit, ViewChild } from '@angular/core' |
2 | import { ModalDirective } from 'ngx-bootstrap/modal' | 2 | import { ModalDirective } from 'ngx-bootstrap/modal' |
3 | import { VideoDetails } from '../../shared/video/video-details.model' | 3 | import { VideoDetails } from '../../shared/video/video-details.model' |
4 | 4 | ||
@@ -7,15 +7,22 @@ import { VideoDetails } from '../../shared/video/video-details.model' | |||
7 | templateUrl: './video-download.component.html', | 7 | templateUrl: './video-download.component.html', |
8 | styleUrls: [ './video-download.component.scss' ] | 8 | styleUrls: [ './video-download.component.scss' ] |
9 | }) | 9 | }) |
10 | export class VideoDownloadComponent { | 10 | export class VideoDownloadComponent implements OnInit { |
11 | @Input() video: VideoDetails = null | 11 | @Input() video: VideoDetails = null |
12 | 12 | ||
13 | @ViewChild('modal') modal: ModalDirective | 13 | @ViewChild('modal') modal: ModalDirective |
14 | 14 | ||
15 | downloadType: 'direct' | 'torrent' = 'torrent' | ||
16 | resolution = -1 | ||
17 | |||
15 | constructor () { | 18 | constructor () { |
16 | // empty | 19 | // empty |
17 | } | 20 | } |
18 | 21 | ||
22 | ngOnInit () { | ||
23 | this.resolution = this.video.files[0].resolution | ||
24 | } | ||
25 | |||
19 | show () { | 26 | show () { |
20 | this.modal.show() | 27 | this.modal.show() |
21 | } | 28 | } |
@@ -23,4 +30,15 @@ export class VideoDownloadComponent { | |||
23 | hide () { | 30 | hide () { |
24 | this.modal.hide() | 31 | this.modal.hide() |
25 | } | 32 | } |
33 | |||
34 | download () { | ||
35 | const file = this.video.files.find(f => f.resolution === this.resolution) | ||
36 | if (!file) { | ||
37 | console.error('Could not find file with resolution %d.', this.resolution) | ||
38 | return | ||
39 | } | ||
40 | |||
41 | const link = this.downloadType === 'direct' ? file.fileUrl : file.torrentUrl | ||
42 | window.open(link) | ||
43 | } | ||
26 | } | 44 | } |