aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/app/videos/video-add/video-add.component.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-06-03 22:08:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-06-03 22:08:03 +0200
commit4a6995be18b15de1834a39c8921a0e4109671bb6 (patch)
treeb659661cea33687fcc6bd8fc2251cb7a15ab9f9d /client/app/videos/video-add/video-add.component.ts
parent468892541175f9662f8b1b977e819dc1a496f282 (diff)
downloadPeerTube-4a6995be18b15de1834a39c8921a0e4109671bb6.tar.gz
PeerTube-4a6995be18b15de1834a39c8921a0e4109671bb6.tar.zst
PeerTube-4a6995be18b15de1834a39c8921a0e4109671bb6.zip
First draft to use webpack instead of systemjs
Diffstat (limited to 'client/app/videos/video-add/video-add.component.ts')
-rw-r--r--client/app/videos/video-add/video-add.component.ts69
1 files changed, 0 insertions, 69 deletions
diff --git a/client/app/videos/video-add/video-add.component.ts b/client/app/videos/video-add/video-add.component.ts
deleted file mode 100644
index e17b1b0f6..000000000
--- a/client/app/videos/video-add/video-add.component.ts
+++ /dev/null
@@ -1,69 +0,0 @@
1/// <reference path="../../../typings/globals/jquery/index.d.ts" />
2/// <reference path="../../../typings/globals/jquery.fileupload/index.d.ts" />
3
4import { Component, ElementRef, OnInit } from '@angular/core';
5import { Router } from '@angular/router-deprecated';
6
7import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
8import { PROGRESSBAR_DIRECTIVES } from 'ng2-bootstrap/components/progressbar';
9
10import { AuthService, User } from '../../shared/index';
11
12@Component({
13 selector: 'my-videos-add',
14 styleUrls: [ 'client/app/videos/video-add/video-add.component.css' ],
15 templateUrl: 'client/app/videos/video-add/video-add.component.html',
16 directives: [ PROGRESSBAR_DIRECTIVES ],
17 pipes: [ BytesPipe ]
18})
19
20export class VideoAddComponent implements OnInit {
21 fileToUpload: any;
22 progressBar: { value: number; max: number; } = { value: 0, max: 0 };
23 user: User;
24
25 private form: any;
26
27 constructor(
28 private authService: AuthService,
29 private elementRef: ElementRef,
30 private router: Router
31 ) {}
32
33 ngOnInit() {
34 this.user = User.load();
35 jQuery(this.elementRef.nativeElement).find('#videofile').fileupload({
36 url: '/api/v1/videos',
37 dataType: 'json',
38 singleFileUploads: true,
39 multipart: true,
40 autoUpload: false,
41
42 add: (e, data) => {
43 this.form = data;
44 this.fileToUpload = data['files'][0];
45 },
46
47 progressall: (e, data) => {
48 this.progressBar.value = data.loaded;
49 // The server is a little bit slow to answer (has to seed the video)
50 // So we add more time to the progress bar (+10%)
51 this.progressBar.max = data.total + (0.1 * data.total);
52 },
53
54 done: (e, data) => {
55 this.progressBar.value = this.progressBar.max;
56 console.log('Video uploaded.');
57
58 // Print all the videos once it's finished
59 this.router.navigate(['VideosList']);
60 }
61 });
62 }
63
64 uploadFile() {
65 this.form.formData = jQuery(this.elementRef.nativeElement).find('form').serializeArray();
66 this.form.headers = this.authService.getRequestHeader().toJSON();
67 this.form.submit();
68 }
69}