diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-27 16:23:10 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-27 16:23:10 +0200 |
commit | 41a2aee38cf812510010da09de9bae53590ec119 (patch) | |
tree | 79d55d6ae0ef6f66ccb88890cf1ef1946dc65fb4 /client/angular/videos/components/add/videos-add.component.ts | |
parent | 157cb9c9713e08ff70078660a32dd77ecb87eabc (diff) | |
download | PeerTube-41a2aee38cf812510010da09de9bae53590ec119.tar.gz PeerTube-41a2aee38cf812510010da09de9bae53590ec119.tar.zst PeerTube-41a2aee38cf812510010da09de9bae53590ec119.zip |
Follow the angular styleguide for the directories structure
Diffstat (limited to 'client/angular/videos/components/add/videos-add.component.ts')
-rw-r--r-- | client/angular/videos/components/add/videos-add.component.ts | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/client/angular/videos/components/add/videos-add.component.ts b/client/angular/videos/components/add/videos-add.component.ts deleted file mode 100644 index f1652be19..000000000 --- a/client/angular/videos/components/add/videos-add.component.ts +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | import { Component, ElementRef, OnInit } from '@angular/core'; | ||
2 | import { Router } from '@angular/router-deprecated'; | ||
3 | |||
4 | import { PROGRESSBAR_DIRECTIVES } from 'ng2-bootstrap/components/progressbar'; | ||
5 | import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'; | ||
6 | |||
7 | import { AuthService } from '../../../users/services/auth.service'; | ||
8 | import { User } from '../../../users/models/user'; | ||
9 | |||
10 | // TODO: import it with systemjs | ||
11 | declare var jQuery:any; | ||
12 | |||
13 | @Component({ | ||
14 | selector: 'my-videos-add', | ||
15 | styleUrls: [ 'app/angular/videos/components/add/videos-add.component.css' ], | ||
16 | templateUrl: 'app/angular/videos/components/add/videos-add.component.html', | ||
17 | directives: [ PROGRESSBAR_DIRECTIVES ], | ||
18 | pipes: [ BytesPipe ] | ||
19 | }) | ||
20 | |||
21 | export class VideosAddComponent implements OnInit { | ||
22 | user: User; | ||
23 | fileToUpload: any; | ||
24 | progressBar: { value: number; max: number; } = { value: 0, max: 0 }; | ||
25 | |||
26 | private _form: any; | ||
27 | |||
28 | constructor( | ||
29 | private _router: Router, private _elementRef: ElementRef, | ||
30 | private _authService: AuthService | ||
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.headers = this._authService.getRequestHeader().toJSON(); | ||
66 | this._form.formData = jQuery(this._elementRef.nativeElement).find('form').serializeArray(); | ||
67 | this._form.submit(); | ||
68 | } | ||
69 | } | ||