X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-watch%2Fmodal%2Fvideo-download.component.ts;h=b1b2c06237714527b792d32d27115e27e274b875;hb=bb5d74289b858fae04975477a9572b57ee6237c5;hp=2de706e47a707bd0b253f22aa4ca28b60e088fac;hpb=5511da6289e80f91daf5dcb3b632068c02a24ccb;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/+video-watch/modal/video-download.component.ts b/client/src/app/videos/+video-watch/modal/video-download.component.ts index 2de706e47..b1b2c0623 100644 --- a/client/src/app/videos/+video-watch/modal/video-download.component.ts +++ b/client/src/app/videos/+video-watch/modal/video-download.component.ts @@ -1,6 +1,8 @@ -import { Component, Input, OnInit, ViewChild } from '@angular/core' -import { ModalDirective } from 'ngx-bootstrap/modal' +import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core' import { VideoDetails } from '../../../shared/video/video-details.model' +import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { NotificationsService } from 'angular2-notifications' @Component({ selector: 'my-video-download', @@ -10,28 +12,30 @@ import { VideoDetails } from '../../../shared/video/video-details.model' export class VideoDownloadComponent implements OnInit { @Input() video: VideoDetails = null - @ViewChild('modal') modal: ModalDirective + @ViewChild('modal') modal: ElementRef downloadType: 'direct' | 'torrent' | 'magnet' = 'torrent' resolutionId: number | string = -1 - constructor () { - // empty - } + constructor ( + private notificationsService: NotificationsService, + private modalService: NgbModal, + private i18n: I18n + ) { } ngOnInit () { this.resolutionId = this.video.files[0].resolution.id } show () { - this.modal.show() + this.modalService.open(this.modal) } - hide () { - this.modal.hide() + download () { + window.location.assign(this.getLink()) } - download () { + getLink () { // HTML select send us a string, so convert it to a number this.resolutionId = parseInt(this.resolutionId.toString(), 10) @@ -54,6 +58,11 @@ export class VideoDownloadComponent implements OnInit { } } })() - window.location.assign(link) + + return link + } + + activateCopiedMessage () { + this.notificationsService.success(this.i18n('Success'), this.i18n('Copied')) } }