]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/angular/videos/components/list/videos-list.component.ts
Extends the search feature by customizing the search field (name,
[github/Chocobozzz/PeerTube.git] / client / angular / videos / components / list / videos-list.component.ts
index eb23ed1ff61d1a9c72bbe228e7d598ff2e2531b2..6fc0c1f04b290f2f79ec271bace64ca04c59c082 100644 (file)
@@ -1,22 +1,27 @@
-import { Component, OnInit } from 'angular2/core';
-import { ROUTER_DIRECTIVES, RouteParams } from 'angular2/router';
+import { Component, OnInit } from '@angular/core';
+import { ROUTER_DIRECTIVES, RouteParams } from '@angular/router-deprecated';
 
-import { VideosService } from '../../services/videos.service';
-import { Video } from '../../models/video';
+import { AuthService } from '../../../users/services/auth.service';
+import { User } from '../../../users/models/user';
+import { VideosService } from '../../videos.service';
+import { Video } from '../../video';
+import { VideoMiniatureComponent } from './video-miniature.component';
 
 @Component({
   selector: 'my-videos-list',
   styleUrls: [ 'app/angular/videos/components/list/videos-list.component.css' ],
   templateUrl: 'app/angular/videos/components/list/videos-list.component.html',
-  directives: [ ROUTER_DIRECTIVES ]
+  directives: [ ROUTER_DIRECTIVES, VideoMiniatureComponent ]
 })
 
 export class VideosListComponent implements OnInit {
-  videos: Video[];
+  user: User = null;
+  videos: Video[] = [];
 
   private search: string;
 
   constructor(
+    private _authService: AuthService,
     private _videosService: VideosService,
     routeParams: RouteParams
   ) {
@@ -24,6 +29,10 @@ export class VideosListComponent implements OnInit {
   }
 
   ngOnInit() {
+    if (this._authService.isLoggedIn()) {
+      this.user = User.load();
+    }
+
     this.getVideos();
   }
 
@@ -33,7 +42,7 @@ export class VideosListComponent implements OnInit {
     if (this.search !== null) {
       observable = this._videosService.searchVideos(this.search);
     } else {
-      observable = this._videosService.getVideos()
+      observable = this._videosService.getVideos();
     }
 
     observable.subscribe(
@@ -42,11 +51,8 @@ export class VideosListComponent implements OnInit {
     );
   }
 
-  removeVideo(id: string) {
-    this._videosService.removeVideo(id).subscribe(
-      status => this.getVideos(),
-      error => alert(error)
-    )
+  onRemoved(video: Video): void {
+    this.videos.splice(this.videos.indexOf(video), 1);
   }
 
 }