1 import {Component, ElementRef, Inject, OnInit} from 'angular2/core';
2 import {Router} from 'angular2/router';
3 import {NgForm} from 'angular2/common';
5 import {Video} from '../../models/video';
7 declare var jQuery:any;
10 selector: 'my-videos-add',
11 styleUrls: [ 'app/angular/videos/components/add/videos-add.component.css' ],
12 templateUrl: 'app/angular/videos/components/add/videos-add.component.html'
15 export class VideosAddComponent implements OnInit {
17 progressBar: { value: number; max: number; } = { value: 0, max: 0 };
21 constructor(private _router: Router, private _elementRef: ElementRef) {}
24 jQuery(this._elementRef.nativeElement).find('#input_video').fileupload({
25 singleFileUploads: true,
27 url: '/api/v1/videos',
32 this.fileToUpload = data['files'][0];
35 progressall: (e, data) => {
36 this.progressBar.value = data.loaded;
37 this.progressBar.max= data.total;
41 console.log('finished');
42 // Print all the videos once it's finished
43 this._router.navigate(['VideosList']);
49 this._form.formData = jQuery(this._elementRef.nativeElement).find('form').serializeArray();