Implement user requests autorizations in the client side
[oweals/peertube.git] / client / angular / videos / components / list / videos-list.component.ts
index ae58f4d7e8abf27a4b1330aac1c8d6ff26c11186..b9b440d40b3afa5d97030be46e0443c95d1088c3 100644 (file)
@@ -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();