]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/angular/videos/components/add/videos-add.component.ts
Some small css modifications
[github/Chocobozzz/PeerTube.git] / client / angular / videos / components / add / videos-add.component.ts
CommitLineData
98b01bac
C
1import { Component, ElementRef, Inject, OnInit } from 'angular2/core';
2import { Router } from 'angular2/router';
3import { NgForm } from 'angular2/common';
dc8bc31b 4
98b01bac 5import { Video } from '../../models/video';
dc8bc31b 6
98b01bac 7// TODO: import it with systemjs
dc8bc31b
C
8declare var jQuery:any;
9
10@Component({
11 selector: 'my-videos-add',
12 styleUrls: [ 'app/angular/videos/components/add/videos-add.component.css' ],
13 templateUrl: 'app/angular/videos/components/add/videos-add.component.html'
14})
15
16export class VideosAddComponent implements OnInit {
17 fileToUpload: any;
18 progressBar: { value: number; max: number; } = { value: 0, max: 0 };
19
20 private _form: any;
21
22 constructor(private _router: Router, private _elementRef: ElementRef) {}
23
24 ngOnInit() {
25 jQuery(this._elementRef.nativeElement).find('#input_video').fileupload({
98b01bac
C
26 url: '/api/v1/videos',
27 dataType: 'json',
dc8bc31b
C
28 singleFileUploads: true,
29 multipart: true,
dc8bc31b
C
30 autoupload: false,
31
32 add: (e, data) => {
33 this._form = data;
34 this.fileToUpload = data['files'][0];
35 },
36
37 progressall: (e, data) => {
38 this.progressBar.value = data.loaded;
763bed9b 39 this.progressBar.max = data.total;
dc8bc31b
C
40 },
41
42 done: (e, data) => {
98b01bac
C
43 console.log('Video uploaded.');
44
dc8bc31b
C
45 // Print all the videos once it's finished
46 this._router.navigate(['VideosList']);
47 }
48 });
49 }
50
51 uploadFile() {
52 this._form.formData = jQuery(this._elementRef.nativeElement).find('form').serializeArray();
53 this._form.submit();
54 }
55}