mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Implement user requests autorizations in the client side
This commit is contained in:
parent
0c1cbbfe29
commit
1553e15d82
10 changed files with 122 additions and 33 deletions
|
@ -1,6 +1,9 @@
|
|||
import { Component, ElementRef, OnInit } from 'angular2/core';
|
||||
import { Router } from 'angular2/router';
|
||||
|
||||
import { AuthService } from '../../../users/services/auth.service';
|
||||
import { User } from '../../../users/models/user';
|
||||
|
||||
// TODO: import it with systemjs
|
||||
declare var jQuery:any;
|
||||
|
||||
|
@ -11,14 +14,19 @@ declare var jQuery:any;
|
|||
})
|
||||
|
||||
export class VideosAddComponent implements OnInit {
|
||||
user: User;
|
||||
fileToUpload: any;
|
||||
progressBar: { value: number; max: number; } = { value: 0, max: 0 };
|
||||
|
||||
private _form: any;
|
||||
|
||||
constructor(private _router: Router, private _elementRef: ElementRef) {}
|
||||
constructor(
|
||||
private _router: Router, private _elementRef: ElementRef,
|
||||
private _authService: AuthService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.user = User.load();
|
||||
jQuery(this._elementRef.nativeElement).find('#videofile').fileupload({
|
||||
url: '/api/v1/videos',
|
||||
dataType: 'json',
|
||||
|
@ -49,6 +57,7 @@ export class VideosAddComponent implements OnInit {
|
|||
}
|
||||
|
||||
uploadFile() {
|
||||
this._form.headers = this._authService.getRequestHeader().toJSON();
|
||||
this._form.formData = jQuery(this._elementRef.nativeElement).find('form').serializeArray();
|
||||
this._form.submit();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div>
|
||||
<a [routerLink]="['VideosWatch', { id: video.id }]" class="video_name">{{ video.name }}</a>
|
||||
<span class="video_pod_url">{{ video.podUrl }}</span>
|
||||
<span *ngIf="video.isLocal === true" (click)="removeVideo(video.id)" class="video_remove glyphicon glyphicon-remove"></span>
|
||||
<span *ngIf="video.isLocal === true && user && video.author === user.username" (click)="removeVideo(video.id)" class="video_remove glyphicon glyphicon-remove"></span>
|
||||
</div>
|
||||
|
||||
<div class="video_description">
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { Component, OnInit } from 'angular2/core';
|
||||
import { ROUTER_DIRECTIVES, RouteParams } from 'angular2/router';
|
||||
|
||||
import { AuthService } from '../../../users/services/auth.service';
|
||||
import { User } from '../../../users/models/user';
|
||||
import { VideosService } from '../../services/videos.service';
|
||||
import { Video } from '../../models/video';
|
||||
|
||||
|
@ -12,11 +14,13 @@ import { Video } from '../../models/video';
|
|||
})
|
||||
|
||||
export class VideosListComponent implements OnInit {
|
||||
user: User = null;
|
||||
videos: Video[];
|
||||
|
||||
private search: string;
|
||||
|
||||
constructor(
|
||||
private _authService: AuthService,
|
||||
private _videosService: VideosService,
|
||||
routeParams: RouteParams
|
||||
) {
|
||||
|
@ -24,13 +28,17 @@ export class VideosListComponent implements OnInit {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this._authService.isLoggedIn()) {
|
||||
this.user = User.load();
|
||||
}
|
||||
|
||||
this.getVideos();
|
||||
}
|
||||
|
||||
getVideos() {
|
||||
let observable = null;
|
||||
|
||||
if (this.search !== null) {
|
||||
if (this.search !== null) {""
|
||||
observable = this._videosService.searchVideos(this.search);
|
||||
} else {
|
||||
observable = this._videosService.getVideos();
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/// <reference path='../../../../typings/browser/ambient/webtorrent/webtorrent.d.ts' />
|
||||
|
||||
import { Component, OnInit, ElementRef } from 'angular2/core';
|
||||
import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue