]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/angular/videos/components/add/videos-add.component.ts
Only display "upload video" in the menu if the user is logged in
[github/Chocobozzz/PeerTube.git] / client / angular / videos / components / add / videos-add.component.ts
index 97e3bb3b544797f968c32df92624e9af370f5ec5..0004cfa20f8651471dc3351989e7956be41e530c 100644 (file)
@@ -1,9 +1,10 @@
-import {Component, ElementRef, Inject, OnInit} from 'angular2/core';
-import {Router} from 'angular2/router';
-import {NgForm} from 'angular2/common';
+import { Component, ElementRef, Inject, OnInit } from 'angular2/core';
+import { Router } from 'angular2/router';
+import { NgForm } from 'angular2/common';
 
-import {Video} from '../../models/video';
+import { Video } from '../../models/video';
 
+// TODO: import it with systemjs
 declare var jQuery:any;
 
 @Component({
@@ -21,10 +22,11 @@ export class VideosAddComponent implements OnInit {
   constructor(private _router: Router, private _elementRef: ElementRef) {}
 
   ngOnInit() {
-    jQuery(this._elementRef.nativeElement).find('#input_video').fileupload({
+    jQuery(this._elementRef.nativeElement).find('#videofile').fileupload({
+      url: '/api/v1/videos',
+      dataType: 'json',
       singleFileUploads: true,
       multipart: true,
-      url: '/api/v1/videos',
       autoupload: false,
 
       add: (e, data) => {
@@ -34,11 +36,15 @@ export class VideosAddComponent implements OnInit {
 
       progressall: (e, data) => {
         this.progressBar.value = data.loaded;
-        this.progressBar.max= data.total;
+        // The server is a little bit slow to answer (has to seed the video)
+        // So we add more time to the progress bar (+10%)
+        this.progressBar.max = data.total + (0.1 * data.total);
       },
 
       done: (e, data) => {
-        console.log('finished');
+        this.progressBar.value = this.progressBar.max;
+        console.log('Video uploaded.');
+
         // Print all the videos once it's finished
         this._router.navigate(['VideosList']);
       }