diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-04-14 22:07:46 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-04-14 22:07:46 +0200 |
commit | 1553e15d82b8a1ec4967a90d43b33274f8215c44 (patch) | |
tree | ee53fdbb32895153a1fd2470e1c51cf1d9a38e77 /client/angular/videos/components | |
parent | 0c1cbbfe29d91c95f9c574b57adf067654b8b5b4 (diff) | |
download | PeerTube-1553e15d82b8a1ec4967a90d43b33274f8215c44.tar.gz PeerTube-1553e15d82b8a1ec4967a90d43b33274f8215c44.tar.zst PeerTube-1553e15d82b8a1ec4967a90d43b33274f8215c44.zip |
Implement user requests autorizations in the client side
Diffstat (limited to 'client/angular/videos/components')
4 files changed, 20 insertions, 5 deletions
diff --git a/client/angular/videos/components/add/videos-add.component.ts b/client/angular/videos/components/add/videos-add.component.ts index 7ae11db22..bc7b4057c 100644 --- a/client/angular/videos/components/add/videos-add.component.ts +++ b/client/angular/videos/components/add/videos-add.component.ts | |||
@@ -1,6 +1,9 @@ | |||
1 | import { Component, ElementRef, OnInit } from 'angular2/core'; | 1 | import { Component, ElementRef, OnInit } from 'angular2/core'; |
2 | import { Router } from 'angular2/router'; | 2 | import { Router } from 'angular2/router'; |
3 | 3 | ||
4 | import { AuthService } from '../../../users/services/auth.service'; | ||
5 | import { User } from '../../../users/models/user'; | ||
6 | |||
4 | // TODO: import it with systemjs | 7 | // TODO: import it with systemjs |
5 | declare var jQuery:any; | 8 | declare var jQuery:any; |
6 | 9 | ||
@@ -11,14 +14,19 @@ declare var jQuery:any; | |||
11 | }) | 14 | }) |
12 | 15 | ||
13 | export class VideosAddComponent implements OnInit { | 16 | export class VideosAddComponent implements OnInit { |
17 | user: User; | ||
14 | fileToUpload: any; | 18 | fileToUpload: any; |
15 | progressBar: { value: number; max: number; } = { value: 0, max: 0 }; | 19 | progressBar: { value: number; max: number; } = { value: 0, max: 0 }; |
16 | 20 | ||
17 | private _form: any; | 21 | private _form: any; |
18 | 22 | ||
19 | constructor(private _router: Router, private _elementRef: ElementRef) {} | 23 | constructor( |
24 | private _router: Router, private _elementRef: ElementRef, | ||
25 | private _authService: AuthService | ||
26 | ) {} | ||
20 | 27 | ||
21 | ngOnInit() { | 28 | ngOnInit() { |
29 | this.user = User.load(); | ||
22 | jQuery(this._elementRef.nativeElement).find('#videofile').fileupload({ | 30 | jQuery(this._elementRef.nativeElement).find('#videofile').fileupload({ |
23 | url: '/api/v1/videos', | 31 | url: '/api/v1/videos', |
24 | dataType: 'json', | 32 | dataType: 'json', |
@@ -49,6 +57,7 @@ export class VideosAddComponent implements OnInit { | |||
49 | } | 57 | } |
50 | 58 | ||
51 | uploadFile() { | 59 | uploadFile() { |
60 | this._form.headers = this._authService.getRequestHeader().toJSON(); | ||
52 | this._form.formData = jQuery(this._elementRef.nativeElement).find('form').serializeArray(); | 61 | this._form.formData = jQuery(this._elementRef.nativeElement).find('form').serializeArray(); |
53 | this._form.submit(); | 62 | this._form.submit(); |
54 | } | 63 | } |
diff --git a/client/angular/videos/components/list/videos-list.component.html b/client/angular/videos/components/list/videos-list.component.html index 38708aff6..75b860f38 100644 --- a/client/angular/videos/components/list/videos-list.component.html +++ b/client/angular/videos/components/list/videos-list.component.html | |||
@@ -2,7 +2,7 @@ | |||
2 | <div> | 2 | <div> |
3 | <a [routerLink]="['VideosWatch', { id: video.id }]" class="video_name">{{ video.name }}</a> | 3 | <a [routerLink]="['VideosWatch', { id: video.id }]" class="video_name">{{ video.name }}</a> |
4 | <span class="video_pod_url">{{ video.podUrl }}</span> | 4 | <span class="video_pod_url">{{ video.podUrl }}</span> |
5 | <span *ngIf="video.isLocal === true" (click)="removeVideo(video.id)" class="video_remove glyphicon glyphicon-remove"></span> | 5 | <span *ngIf="video.isLocal === true && user && video.author === user.username" (click)="removeVideo(video.id)" class="video_remove glyphicon glyphicon-remove"></span> |
6 | </div> | 6 | </div> |
7 | 7 | ||
8 | <div class="video_description"> | 8 | <div class="video_description"> |
diff --git a/client/angular/videos/components/list/videos-list.component.ts b/client/angular/videos/components/list/videos-list.component.ts index ae58f4d7e..b9b440d40 100644 --- a/client/angular/videos/components/list/videos-list.component.ts +++ b/client/angular/videos/components/list/videos-list.component.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | import { Component, OnInit } from 'angular2/core'; | 1 | import { Component, OnInit } from 'angular2/core'; |
2 | import { ROUTER_DIRECTIVES, RouteParams } from 'angular2/router'; | 2 | import { ROUTER_DIRECTIVES, RouteParams } from 'angular2/router'; |
3 | 3 | ||
4 | import { AuthService } from '../../../users/services/auth.service'; | ||
5 | import { User } from '../../../users/models/user'; | ||
4 | import { VideosService } from '../../services/videos.service'; | 6 | import { VideosService } from '../../services/videos.service'; |
5 | import { Video } from '../../models/video'; | 7 | import { Video } from '../../models/video'; |
6 | 8 | ||
@@ -12,11 +14,13 @@ import { Video } from '../../models/video'; | |||
12 | }) | 14 | }) |
13 | 15 | ||
14 | export class VideosListComponent implements OnInit { | 16 | export class VideosListComponent implements OnInit { |
17 | user: User = null; | ||
15 | videos: Video[]; | 18 | videos: Video[]; |
16 | 19 | ||
17 | private search: string; | 20 | private search: string; |
18 | 21 | ||
19 | constructor( | 22 | constructor( |
23 | private _authService: AuthService, | ||
20 | private _videosService: VideosService, | 24 | private _videosService: VideosService, |
21 | routeParams: RouteParams | 25 | routeParams: RouteParams |
22 | ) { | 26 | ) { |
@@ -24,13 +28,17 @@ export class VideosListComponent implements OnInit { | |||
24 | } | 28 | } |
25 | 29 | ||
26 | ngOnInit() { | 30 | ngOnInit() { |
31 | if (this._authService.isLoggedIn()) { | ||
32 | this.user = User.load(); | ||
33 | } | ||
34 | |||
27 | this.getVideos(); | 35 | this.getVideos(); |
28 | } | 36 | } |
29 | 37 | ||
30 | getVideos() { | 38 | getVideos() { |
31 | let observable = null; | 39 | let observable = null; |
32 | 40 | ||
33 | if (this.search !== null) { | 41 | if (this.search !== null) {"" |
34 | observable = this._videosService.searchVideos(this.search); | 42 | observable = this._videosService.searchVideos(this.search); |
35 | } else { | 43 | } else { |
36 | observable = this._videosService.getVideos(); | 44 | observable = this._videosService.getVideos(); |
diff --git a/client/angular/videos/components/watch/videos-watch.component.ts b/client/angular/videos/components/watch/videos-watch.component.ts index 28786ebb9..d1b90c190 100644 --- a/client/angular/videos/components/watch/videos-watch.component.ts +++ b/client/angular/videos/components/watch/videos-watch.component.ts | |||
@@ -1,5 +1,3 @@ | |||
1 | /// <reference path='../../../../typings/browser/ambient/webtorrent/webtorrent.d.ts' /> | ||
2 | |||
3 | import { Component, OnInit, ElementRef } from 'angular2/core'; | 1 | import { Component, OnInit, ElementRef } from 'angular2/core'; |
4 | import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router'; | 2 | import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router'; |
5 | 3 | ||