X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fangular%2Fvideos%2Fcomponents%2Flist%2Fvideos-list.component.ts;h=ae58f4d7e8abf27a4b1330aac1c8d6ff26c11186;hb=44124980c55d5a5ec7dfb8e71bf14d10f0fe975d;hp=e5af87448ac2a50fca4387416816ea48ee137a6f;hpb=dc8bc31be517a53e8fbe7100cfe45cd73f596de0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/angular/videos/components/list/videos-list.component.ts b/client/angular/videos/components/list/videos-list.component.ts index e5af87448..ae58f4d7e 100644 --- a/client/angular/videos/components/list/videos-list.component.ts +++ b/client/angular/videos/components/list/videos-list.component.ts @@ -1,8 +1,8 @@ -import {Component, OnInit} from 'angular2/core'; -import {ROUTER_DIRECTIVES} from 'angular2/router'; +import { Component, OnInit } from 'angular2/core'; +import { ROUTER_DIRECTIVES, RouteParams } from 'angular2/router'; -import {VideosService} from '../../services/videos.service'; -import {Video} from '../../models/video'; +import { VideosService } from '../../services/videos.service'; +import { Video } from '../../models/video'; @Component({ selector: 'my-videos-list', @@ -14,16 +14,29 @@ import {Video} from '../../models/video'; export class VideosListComponent implements OnInit { videos: Video[]; + private search: string; + constructor( - private _videosService: VideosService - ) { } + private _videosService: VideosService, + routeParams: RouteParams + ) { + this.search = routeParams.get('search'); + } ngOnInit() { this.getVideos(); } getVideos() { - this._videosService.getVideos().subscribe( + let observable = null; + + if (this.search !== null) { + observable = this._videosService.searchVideos(this.search); + } else { + observable = this._videosService.getVideos(); + } + + observable.subscribe( videos => this.videos = videos, error => alert(error) ); @@ -33,7 +46,7 @@ export class VideosListComponent implements OnInit { this._videosService.removeVideo(id).subscribe( status => this.getVideos(), error => alert(error) - ) + ); } }